Hey guy's,
i'm trying to make an Event handler "Killed" Global, so everyone on a Dedicated server will see whats happend, if a object was killed and the Event handler was triggered.
So far i made a hundreds of tests using the ECP way:
Create a file "Load.sqs" which is executed in the init.sqs of the mission
Load.sqs
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
? (isServer) : exit
_explosions = [1,2,3,5]
_fire = [1,2,3,5]
#Start
; Create Global variable
GL2Plus_Spawn_Script = -1
; Wait till GL2Plus_Spawn_Script is not -1
@GL2Plus_Spawn_Script != -1
; ########### DEBUG =\SNKMAN/= ###########
;hint format["DEBUG: Spawn # : %1\nDEBUG: Spawn Object: %2",GL2Plus_Spawn_Script,GL2Plus_Spawn_Script_ Object]
; ########################################
; Check if GL2Plus_SmokeEffect are enabled, if yes run script with GL2Plus_Spawn_Script_Object
? (GL2Plus_SmokeEffect && GL2Plus_Spawn_Script in _explosions) : [GL2Plus_Spawn_Script_Object] exec "GL2Plus\GL2Plus_Effects\Explosion\ ;Init.sqs"
; Check if GL2Plus_SmokeEffect are enabled, if yes run script with GL2Plus_Spawn_Script_Object
? (GL2Plus_FireEffect && GL2Plus_Spawn_Script in _fire) : [GL2Plus_Spawn_Script_Object] exec "GL2Plus\GL2Plus_Effects\Fire\Fire .sqs"
; Check if GL2Plus_SmokeEffect are enabled, if yes run script with GL2Plus_Spawn_Script_Object
? (GL2Plus_FireEffect && GL2Plus_Spawn_Script in _fire) : [GL2Plus_Spawn_Script_Object] exec "GL2Plus\GL2Plus_Effects\Fire\Fire _Damage.sqs"
; Do it all over
goto "Start"[/QUOTE]
Then in a script i add the Event handler "Killed" to each vehicle:
EventHandler.sqs
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
// Check if FX should be used, if yes add EventHandler "Killed"
if (GL2Plus_SpecialFX) then {{_x AddEventHandler ["Killed", {
if (GL2Plus_SmokeEffect && (_this select 0) isKindOf "LandVehicle") then {_this exec "GL2Plus\GL2Plus_Effects\Explosion\ ;Init.sqs"; GL2Plus_Spawn_Script_Object = (_this select 0); publicvariable "GL2Plus_Spawn_Script_Object"; GL2Plus_Spawn_Script = 1; publicvariable "GL2Plus_Spawn_Script"};
if (GL2Plus_FireEffect && (_this select 0) isKindOf "LandVehicle") then {_this exec "GL2Plus\GL2Plus_Effects\Fire\Fire .sqs"; GL2Plus_Spawn_Script_Object = (_this select 0); publicvariable "GL2Plus_Spawn_Script_Object"; GL2Plus_Spawn_Script + 2; publicvariable "GL2Plus_Spawn_Script"};
if (GL2Plus_FireEffect && (_this select 0) isKindOf "Man") then {_this exec "GL2Plus\GL2Plus_Effects\Fire\Fire _Damage.sqs"; GL2Plus_Spawn_Script_Object = (_this select 0); publicvariable "GL2Plus_Spawn_Script_Object"; GL2Plus_Spawn_Script + 3; publicvariable "GL2Plus_Spawn_Script"}}]}
} forEach vehicles;
[/QUOTE]
Now after an Event handler was triggered ( A vehicle was destroyed ) the Event handler will public the object (_this select 0), which was destroyed and the lock (GL2Plus_Spawn_Script) to run the "Load.sqs"
Then in "Load.sqs" the brodcasted object will run the script.
Well basically this should work, it do on a local hosted server, where i'm the server but i doesn't work on a Dedicated server.
May someone of you know why or has a other way how to do this.
HOME
Reply With Quote






