Ok guys i made this script today for my hummers with m2 to be used in the BHD MOD.
basically the function of this script is to check whatever the gunner is dead or not, then replace it with another soldier of the same group that is in cargo position.
I also added a part in which I've defined what sounds should randomly be played when gunner has been killed
now the strange thing I get is:
A soldier is effectively randomly chosen from the crew of the hummer, and he says effectively a randomly chosen sound, but when speaking of moving to gunner position, nothing happens, he doesn't do the job...
whyyy?
?
here is the script that is called via
[nameofvehicle, (gunner nameofvehicle)] exec "check_deadgunner.sqs";check_deadGunner.sqs
_veh = _this select 0
_gunner = _this select 1
_grp = (group (driver _veh))
_count = count units _grp
_num_count = (random _count)
_leader = leader _gunner
;------------------------------------------
;Start of the script
;------------------------------------------
#START
;------------------------------------------
_arr_sounds = ["UScry1","UScry3","UScry4","UScry5","UScry6","UScry7","UScry8","UScry9","UScry10","UScry11","UScry12","UScry13"]
_count_arr = count _arr_sounds
;random count sounds to play
_items = random _count_arr
_number_items = _items - (_items mod 1)
;------------------------------------------
?!(alive _gunner) : goto "Deadgunner"
~1
goto "START"
#Deadgunner
_number_soldiers = _num_count - (_num_count mod 1)
_selected_soldier = ((units _grp) select _number_soldiers)
_selected_soldier say (_arr_sounds select _number_items)
;if (_leader == _gunner) then {((units _grp) select _number_soldiers) say (_arr_sounds select _number_items)} else {_leader say (_arr_sounds select _number_items)}
;[_gunner] join grPnull
_selected_soldier moveInGunner _veh
exit
as I said, the script work till it reaches the last line,
_selected_soldier moveInGunner _vehhelp help help help help help