Jump to content
Sign in to follow this  
tpw

Adding eventhandler to civilians spawned by script-created ALICE module

Recommended Posts

Phew - long winded title!

I'm cooking up my own customised ALICE2 setup for spawning civilians. This involves using a script to generate city center location logics, and then an ALICE module to populate them.

I create the appropriate civilian center and a civilian group

_tpwcivcenter = createCenter civilian;
_tpwmodules = creategroup civilian;

Then I create an ALICE2 module

_tpwcivilianmodule = _tpwmodules createUnit ["Alice2Manager",[0,0,0],[],0,"NONE"];

Now I'd like to add some code to add a killed eventhandler to each spawned civ. If I'm using an editor placed ALICE2 module I put the following in its init, and it works fine.

this setvariable ["ALICE_civilianinit", [{_this addeventhandler ["killed",{null = _this execVM "scripts\civkilled.sqf";}]}]] call bis_fnc_variablespaceadd;

However I just can't get it to work with the script generated ALICE module

_tpwcivilianmodule setvariable [["ALICE_civilianinit", [{_this addeventhandler ["killed",{null = _this execVM "scripts\civkilled.sqf";}]}]] call bis_fnc_variablespaceadd];

Anyone point me in the right direction? Thanks in advance.

EDIT:

OK, a bit more trial and error got this to work:

_tpwcivilianmodule setVariable ["ALICE_civilianinit",[{_this addeventhandler ["Killed",{null = _this execvm "scripts\tw_civkilled.sqf"}];}]];

Edited by tpw

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×