Howdy Sefe, can't keep me a away. I left, then came back, now just write scripts for people, occasionally come up with an idea that is sufficiently good it warrants making into a mission. And of course I lurk around alot so I dont get told off.
I think I fixed my script, it took alot of trial and error but it seems to be working. I had to come up with a work-a-round for the variable problem, but you say AddAction already parses the name of the unit? That would be excellent to know. What I came up with is;
;***************************************
;* Radio check script *
;* By [icarus_uk] *
;* http://furryclan.net *
;***************************************
#start
?artyfire: goto "inprogress"
_group = _this select 0
_count = 0
#checkone
_unit = units _group select _count
?_unit hasweapon "bas_satcom" : goto "hasradio"
?_count == 9 : goto "noradio"
_count = _count + 1
goto "checkone"
#hasradio
"_X RemoveAction firerqst" foreach units playergroup
?!(alive _unit) : goto "noradio"
firerqst = _unit addaction ["Radio Fire Mission", "firemission.sqs"]
RadioUnit = _unit
#noradio
~1.5
goto "start"
#inprogress
~6
goto "start"I found this first loop checking all the units to see who has a radio goes by so fast that its not noticable, so fast infact there isnt enough time to display a hint as the loop goes around. I decided that this was acceptable. After 1.5 seconds, it rechecks, and if the action is used, then it loops every 6 seconds. It works quite well without any noticable slowing. The only gripe I did have, is that I had to make the name of the unit into a public variable
RadioUnit as I didnt know how to parse _unit to the next script. I take it from your post that _unit is parsed automaticaly, so the question is, is it select 0, 1 , 2?
This way, the script works great, If the unit drops the radio, someone else can pick it up and use it (call firemission.sqs). I have eventhandlers so when the unit carrying the radio dies the radio is destroyed (as though shot to peices) otherwise when the radio unit respawns there would be dozens of working radios around the island, that would be bad
While Im on the subject, I noticed a very annoying "bug"/"feature" when you add a action to a unit, another other units close enough, and looking at said first unit, also get the action. Is there away around this? Or do I just hape to put up with it?