Jump to content
Sign in to follow this  
brians200

Problem with adding eventhandlers to server created objects

Recommended Posts

Hello,

I am currently having issues with adding event handlers to objects that the server spawns during the init. For people that are in the server when it starts, they do not receive the event handlers for the first 15 or so items. Any JIP or if the original people leave and come back, they have the event handlers. Does anybody see what I am doing wrong? I know it is creating event handlers for the first 15 items, because as the host (isserver), I have all the event handlers.

Here is a simplified version of the flow of the program. All sqf files are turned into functions using "compile preprocessFileLineNumbers" before this point.

init.sqf

if(isserver) then { [...]  call IED;];

Ied.sqf

//for each location...
[...] spawn CREATE_RANDOM_IEDS;

CreateRandomIeds.sqf

//for each individual IED
[...] call CREATE_IED;

CreateIed.sqf

//here is the relevant portion
call compile format ['ied_%1 = _iedType createVehicle _iedPos;
					ied_%1 setDir (random 360);
					ied_%1 enableSimulation false;
					ied_%1 setPos _iedPos;
					ied_%1 allowDamage false;
					publicVariable "ied_%1";
				', _iedNumber];

call compile format [' t_%1 = createTrigger["EmptyDetector", _iedPos];
t_%1 setTriggerArea[11,11,0,true];
t_%1 setTriggerActivation [_side,"PRESENT",false];
t_%1 setTriggerStatements ["[this, thislist, %2, %1] call EXPLOSION_CHECK && (alive ied_%1)","terminate pd_%1; [%2, ied_%1, %1,%4] spawn EXPLOSIVESEQUENCE_%3; deleteVehicle thisTrigger;",""];
publicVariable "t_%1";
',_iedNumber, _iedPos,_iedSize, _side];

call compile format ['[["ied_%1","%2",%3,"%4","t_%1",%1], "EXPLOSION_EVENT_HANDLER_ADDER", true, true] spawn BIS_fnc_MP;	', _iedNumber,_iedSize, _iedPos, _side];

EventHandlerAdder.sqf

waituntil{sleep .3; (!isnull player)};
_ied = _this select 0;
_iedSize = _this select 1;
_iedPosition = _this select 2;
_side = _this select 3;
_trigger = _this select 4;
_iedNumber = _this select 5;
player sidechat format["%1 and %2", compile _trigger, compile _ied];       //These do not show up for the first 15 or so..
waituntil{sleep .3; (!isnull(call compile _trigger) and !isnull(call compile _ied))};

call compile format['%1 addEventHandler ["HitPart", {[_this, %1, "%2", %3, %6, "%4",%5] call EXPLOSION_EVENT_HANDLER;}];',_ied,_iedSize, _iedPosition, _side,_trigger,_iedNumber];

Edited by brians200

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  

×