Pass Object in eventHandler

axeman

OpenDayZ Rockstar!
I am kind of pulling my hair out here so hoping someone can point me in the right direction..

I have created a bus with two AI troops, all in the same group, I load the units as driver and cargo and send them on their merry way around a set of waypoints, all good..

I want to react to the bus being hijacked so am adding an eventHandler to the driver using:
Code:
_driverKilled = busUnit addEventHandler ["killed", {_this execVM "busroute\driverKilled.sqf"}];

that's the simple version, I have been trying to pass the bus object and the second (passenger) unit so I can command the passenger to get in the drivers seat.

So I tried
Code:
_driverKilled = busUnit addEventHandler ["killed", {[_this,[_bus],[_driversMate]] execVM "busroute\driverKilled.sqf"}];
but am getting an array, I want the actual object, is this possible. Am pretty sure have done it with addAction but every different thing seems to work differently with this coding..
 
dont use the brackets around _bus and _driversMate.

Code:
_driverKilled = busUnit addEventHandler ["killed", {[_this,[_bus],[_driversMate]] execVM "busroute\driverKilled.sqf"}];

try

Code:
_driverKilled = busUnit addEventHandler ["killed", {[_this,_bus,_driversMate] execVM "busroute\driverKilled.sqf"}];

cheers

Sarge
 
Got it, thank you. :cool:

I think the reason I was getting lost was because my passenger was just sitting there when I told him to get in the drivers seat, am going to try and disembark him first.

Just got the bus engine to start from a trigger when killing the driver who, for test purposes, is currently waiting outside. I wasted time chasing the bus around just to shoot the driver, restarting the server every time I want to debug is a pain enough..

DOes declaring the variable as private in the first .sqf cause problens do you know ?
 
There is some weird behaviour when telling AI what to do ... check the corresponding posts on the Arma2 biki. Did you use getinDriver or moveInDriver?

Variable: which one? _this or _driverkilled?

Check addMPEventhandler .... i would use this in a MP environment.

using the normal event handler, afaik this will fire on the machine the AI is local to only - and thats the server ...
 
I needed assignAsDriver, he jumps back in now and drives off. Now I am trying to get a proper killer object.. Keep getting object expected errors..
 
How are you getting a variable for the bus? I'm trying to do something similar with a chopper, but if I do a 'createvehicle' in the script, the server kills it because it doesn't have an ID.

Never mind; i commented out that part of the server_cleanup.fsm that was killing it.
 
Back
Top