OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Terox on 18 Sep 2005, 16:20:25
-
Using the init field of a unit, i want to pass the weapons and magazines loadout that the unit has on mission start to the units Killed eventhandler also declared in its init field
I cant seem to get the syntax correct, can anyone help me please.
-
this addeventhandler["killed", {(_this + weapons (_this select 0)+magazines (_this select 0)) exec "playerdead.sqs"}]
seems to work.
Btw Happy Birthday old man ;D
:cheers:
-
actually the code you posted only returns the units weapon loadout at death, i need to capture the unit loadout at the start of the mission and then pass that onto the killed eventhandler script
its either that or i have to create a nested array setup for some 30 odd units
-
actually the code you posted only returns the units weapon loadout at death, i need to capture the unit loadout at the start of the mission and then pass that onto the killed eventhandler script
I would use an array, place the units weapons and magazines into an array like so:
In the init:
Array1 = Array1 + [ [this,weapons this,magazines this]]
And call it like this:
killed.sqs:
_unit = _this select 0
_n = 0
#FindUnit
_current = Array1 select _n
_n = _n + 1
? (_current select 0) != _unit : goto "FindUnit"
_weapons = _current select 1
_magazines = _current select 2
; whatever you want after this
-
thx kyle, but thats what i am trying to avoid
a) i dont want 30 odd unit loadout arrays
b) i dont want to rewrite those unit arrays if i decide to change a unit class of its weapons loadout
-
firstweapons=format ["%1",weapons this] ; firstmags = format ["%1",magazines this] ; this addeventhandler["killed", {(_this + [firstweapons] + [firstmags]) exec "playerdead.sqs"}]
-
lol, cant use a global variable for more than 1 unit, its gotta be ai and player compatible
#but now we are on the right path
-
Hmm I knew it,if Terox is stucked it has to be really complicated :D
Can U do something with the Function "Equipment"?
-
this addEventHandler["killed",format[{_this+[%1]+[%2]exec"tx_sys\client\unitkilled.sqs"},weapons this,magazines this]]
that then returns
units weapon array as _this select 2
units magazine array as _this select 3
Big thanks goes to Killswitch