Home   Help Search Login Register  

Author Topic: passing units weapon loadout to killed eventhandler  (Read 792 times)

0 Members and 1 Guest are viewing this topic.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
passing units weapon loadout to killed eventhandler
« 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.
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Re:passing units weapon loadout to killed eventhandler
« Reply #1 on: 18 Sep 2005, 16:59:40 »
Code: [Select]
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:
http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:passing units weapon loadout to killed eventhandler
« Reply #2 on: 18 Sep 2005, 20:07:32 »
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
« Last Edit: 18 Sep 2005, 20:22:44 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Kyle Sarnik

  • Guest
Re:passing units weapon loadout to killed eventhandler
« Reply #3 on: 18 Sep 2005, 20:22:30 »
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:
Code: [Select]
Array1 = Array1 + [ [this,weapons this,magazines this]]

And call it like this:

killed.sqs:
Code: [Select]
_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


Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:passing units weapon loadout to killed eventhandler
« Reply #4 on: 18 Sep 2005, 20:29:34 »
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
« Last Edit: 18 Sep 2005, 20:30:44 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Re:passing units weapon loadout to killed eventhandler
« Reply #5 on: 18 Sep 2005, 20:30:26 »
Code: [Select]

firstweapons=format ["%1",weapons this] ; firstmags = format ["%1",magazines this] ; this addeventhandler["killed", {(_this + [firstweapons] + [firstmags]) exec "playerdead.sqs"}]  
http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:passing units weapon loadout to killed eventhandler
« Reply #6 on: 18 Sep 2005, 20:31:36 »
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
« Last Edit: 18 Sep 2005, 20:33:11 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Re:passing units weapon loadout to killed eventhandler
« Reply #7 on: 18 Sep 2005, 21:01:33 »
Hmm I knew it,if Terox is stucked it has to be really complicated  :D

Can U do something with the Function "Equipment"?

http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:passing units weapon loadout to killed eventhandler
« Reply #8 on: 18 Sep 2005, 21:02:11 »

 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
« Last Edit: 18 Sep 2005, 21:22:01 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123