Jump to content
sh4rP

Trigger works on host, but not client.

Recommended Posts

Hello, so i'am making a survival style mission, so i have setup shrinks, each shrink looks something like this:

// shrink.sqf

sleep 2;
nul = "Warning message" spawn bis_fnc_titleText;
sleep 2;
"shrinkmarker" setMarkerSize [2200,2200];
sleep 118;
_shrinktrigger2= createTrigger ["EmptyDetector",getMarkerPos "shrinkmarker"];
_shrinktrigger2 setTriggerArea [2200, 2200, 0, false];
_shrinktrigger2 setTriggerStatements ["not(vehicle player in thisList) && not(player in thisList)", "player SetDamage 1;",""];
_shrinktrigger2 setTriggerActivation ["ANY", "PRESENT", true];
sleep 1;
nul = "Shrinked" spawn bis_fnc_titleText;
skiptime 1;
sleep 60;
if (isServer) then
{
null=[]execVM "spawncar.sqf";
};

so everything works, trigger gets created on same position as marker is called "shrinkmarker". So i player hosted the mission , the VM got executed in init.sqf, via: 

sleep 60;
null=[]execVM "shrink.sqf";

so me and my friend after 60seconds got the warning message, in that case the marker size showed us where the shrink would happen, so we both stood around ~300m outside the marker, after 118 seconds, the trigger got created, remember (we both stood near each other, 1meter difference OUTSIDE the marker, meaning we should both die since we are not in area where trigger is created), and for some reason, i died, but my friend did not. We were both in CIV side.

Share this post


Link to post
Share on other sites
4 minutes ago, sh4rP said:

Hello, so i'am making a survival style mission, so i have setup shrinks, each shrink looks something like this:


// shrink.sqf

sleep 2;
nul = "Warning message" spawn bis_fnc_titleText;
sleep 2;
"shrinkmarker" setMarkerSize [2200,2200];
sleep 118;
_shrinktrigger2= createTrigger ["EmptyDetector",getMarkerPos "shrinkmarker"];
_shrinktrigger2 setTriggerArea [2200, 2200, 0, false];
_shrinktrigger2 setTriggerStatements ["not(vehicle player in thisList) && not(player in thisList)", "player SetDamage 1;",""];
_shrinktrigger2 setTriggerActivation ["ANY", "PRESENT", true];
sleep 1;
nul = "Shrinked" spawn bis_fnc_titleText;
skiptime 1;
sleep 60;
if (isServer) then
{
null=[]execVM "spawncar.sqf";
};

so everything works, trigger gets created on same position as marker is called "shrinkmarker". So i player hosted the mission , the VM got executed in init.sqf, via: 


sleep 60;
null=[]execVM "shrink.sqf";

so me and my friend after 60seconds got the warning message, in that case the marker size showed us where the shrink would happen, so we both stood around ~300m outside the marker, after 118 seconds, the trigger got created, remember (we both stood near each other, 1meter difference OUTSIDE the marker, meaning we should both die since we are not in area where trigger is created), and for some reason, i died, but my friend did not. We were both in CIV side.

 

The trigger is activated by the first person to get onto it and even though both of you were standing on it together before it was created you are the host and therefore you activated it first. For him to activate it again it needs to get deactivated.

 

There is a way to get around this though and that is to create the triggers locally.

 

Cheers

Share this post


Link to post
Share on other sites

Triggers condition is , whenever a player or vehicle player goes outside of trigger, it will activate, and the player or vehicle player would die, repeatable trigger, so of my understanding what u said, if i go out of trigger area i would die, then he (my friend) to get the trigger deactivated  would need to get back into trigger ,then go out of trigger  ,in this case he would die? would test this with him ,but hes offline, and i doubt he wont come online today.

Share this post


Link to post
Share on other sites

Erm, maybe do this in the initServer.sqf instead,

you may just have JIP issues.

 

Share this post


Link to post
Share on other sites

Just consider BlacknighBK answer. You have two solutions: a local trigger (add false as 3rd argument for createTrigger command) and put the code into initPlayerLocal.sqf, or rearm your trigger:

in cond: this && isNil "blabla"

in onAct: your code; blabla = true;

in ondeAct: 0 = [] spawn {sleep sometime; blabla = nil};

 

Why rearming on server? Just because your players are civilian/any. And, as always, thisList is a like a "photography" (short film in fact) of the first unit(s) who met the condition. that means not updated and generally limited to the event within 0.5 sec (time slot of the trigger's check). If 2 units satisfy the condition within this slot, thisList will have 2 objects.

So, here, you are checking for "any". When a player dies, it stays "any" (civilian), and you don't deactivate your trigger as the condition stays met.

On the other hand, with blufor units presence for example, you shouldn't have to "manually" rearm it, because the blufor presence fails for a dead man (civilian).

If on server, the trigger must be global (it is by default), but as midnighters said, you don't want to have multiple triggers on each player joining. So wrap the entire code into if (isServer) then {...} or run it from initServer.sqf. (same).

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

×