Jump to content
Luckyas

Trigger script not working correctly in MP

Recommended Posts

Hello everyone.

 

I am trying to make a small minigames to play with my friends. The gamemode is pretty much the same as battle royal. A FFA arena where you have to kill everyone, and stay in the zone that is shrinking constantly. I got everything working now except for the triggers. 

 

My script is creating 2 triggers at the same place. The first trigger is getting activated when "ANY PLAYER" is "NOT PRESENT". It will then give you a hint that you should return to the zone in 10 seconds. The second trigger is getting activated when "ANY PLAYER" is "NOT PRESENT". It will then kill the player if he is out the zone and the "TIMEOUT" has reached 10 seconds.

 

When testing this with my friend I found out that it is working correctly for me, but not for my friend. The triggers doesn't affect him.

 

Could anyone please help me out?

 

trg1 = createTrigger ["EmptyDetector", getMarkerPos "Marker1"];
	trg1 setTriggerArea [500, 500, 0, false];
	trg1 setTriggerActivation ["ANYPLAYER", "NOT PRESENT", true];
	trg1 setTriggerStatements ["this", "hint 'You have 10 seconds to get back in the zone!'", "hint ''"];
trg1kill = createTrigger ["EmptyDetector", getMarkerPos "Marker1"];
	trg1kill setTriggerArea [500, 500, 0, false];
	trg1kill setTriggerTimeout [10, 10, 10, true];
	trg1kill setTriggerActivation ["ANYPLAYER", "NOT PRESENT", true];
	trg1kill setTriggerStatements ["this", "player setDamage 1", ""];

 

Share this post


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

Hello everyone.

 

I am trying to make a small minigames to play with my friends. The gamemode is pretty much the same as battle royal. A FFA arena where you have to kill everyone, and stay in the zone that is shrinking constantly. I got everything working now except for the triggers. 

 

My script is creating 2 triggers at the same place. The first trigger is getting activated when "ANY PLAYER" is "NOT PRESENT". It will then give you a hint that you should return to the zone in 10 seconds. The second trigger is getting activated when "ANY PLAYER" is "NOT PRESENT". It will then kill the player if he is out the zone and the "TIMEOUT" has reached 10 seconds.

 

When testing this with my friend I found out that it is working correctly for me, but not for my friend. The triggers doesn't affect him.

 

Could anyone please help me out?

 


trg1 = createTrigger ["EmptyDetector", getMarkerPos "Marker1"];
	trg1 setTriggerArea [500, 500, 0, false];
	trg1 setTriggerActivation ["ANYPLAYER", "NOT PRESENT", true];
	trg1 setTriggerStatements ["this", "hint 'You have 10 seconds to get back in the zone!'", "hint ''"];
trg1kill = createTrigger ["EmptyDetector", getMarkerPos "Marker1"];
	trg1kill setTriggerArea [500, 500, 0, false];
	trg1kill setTriggerTimeout [10, 10, 10, true];
	trg1kill setTriggerActivation ["ANYPLAYER", "NOT PRESENT", true];
	trg1kill setTriggerStatements ["this", "player setDamage 1", ""];

 

 

Which file is the trigger being called from??

Share this post


Link to post
Share on other sites
Just now, BlacKnightBK said:

Which file is the trigger being called from??

The init.sqf is calling the script.

 [] execVM "zone.sqf"

Share this post


Link to post
Share on other sites

Call it in initPlayerLocal.sqf and onPlayerRespawn.sqf

I am guessing you are the server right??

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, BlacKnightBK said:

Call it in initPlayerLocal.sqf and onPlayerRespawn.sqf

I am guessing you are the server right??

Yes. I am indeed the server.

Il try calling it in initPlayerLocal.sqf and onPlayerRespawn.sqf. But this will create the trigger for everyone right? I think il get into some trouble then with timing. Because the script is full of timing of when the zone will shrink. Also at the start of the script a random start point is being determined. 

strpos = [str1, str2, str3, str4, str5, str6, str7] call BIS_fnc_selectRandom;

If the script is being called on every client it will not be synced with the other people. 

Share this post


Link to post
Share on other sites
Just now, Luckyas said:

Yes. I am indeed the server.

Il try calling it in initPlayerLocal.sqf and onPlayerRespawn.sqf. But this will create the trigger for everyone right? I think il get into some trouble then with timing. Because the script is full of timing of when the zone will shrink. Also at the start of the script a random start point is being determined. 


strpos = [str1, str2, str3, str4, str5, str6, str7] call BIS_fnc_selectRandom;

If the script is being called on every client it will not be synced with the other people. 

 

hmm, you are absolutely right, call it from initServer in that case and let's see how it goes.

  • Like 1

Share this post


Link to post
Share on other sites
Just now, BlacKnightBK said:

hmm, you are absolutely right, call it from initServer in that case and let's see how it goes.

Okay. Il try that. Only problem is that I can't test it right now. Il have to wait on my friend to come online :dozingoff:

 

Thank you very much already.

Il keep you updated once i've tested it!

 

Share this post


Link to post
Share on other sites
Just now, Luckyas said:

Okay. Il try that. Only problem is that I can't test it right now. Il have to wait on my friend to come online :dozingoff:

 

Thank you very much already.

Il keep you updated once i've tested it!

 

 

I would love to test it but my router does not have UPNP option :(

  • Like 1

Share this post


Link to post
Share on other sites
Just now, BlacKnightBK said:

I would love to test it but my router does not have UPNP option :(

What does UPNP mean?

Share this post


Link to post
Share on other sites
Just now, Luckyas said:

What does UPNP mean?

You know when you are hosting a server and check that box that says UPNP. 

If you can host a server means your router has UPNP enabled in it and that allows you to share data over the network. People like me who don't have routers that support that option cannot host servers

  • Like 1

Share this post


Link to post
Share on other sites
Just now, BlacKnightBK said:

You know when you are hosting a server and check that box that says UPNP. 

If you can host a server means your router has UPNP enabled in it and that allows you to share data over the network. People like me who don't have routers that support that option cannot host servers

Okay. But I have my ports forwarded, would that help? Or is that something different.

Share this post


Link to post
Share on other sites
1 minute ago, Luckyas said:

Okay. But I have my ports forwarded, would that help? Or is that something different.

you can only do that if you have a router with the UPNP option :)

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, BlacKnightBK said:

you can only do that if you have a router with the UPNP option :)

Ahh okay.

Well il try once my friend comes online. Thank you very much so far.

Share this post


Link to post
Share on other sites
1 minute ago, Luckyas said:

Ahh okay.

Well il try once my friend comes online. Thank you very much so far.

 

No worries. I am a noob myself but thanks to the people here I learnt a lot. So I try to repay by doing the same with others :)

  • Like 1

Share this post


Link to post
Share on other sites

Your problem could be the trigger is firing with the first player entering the area then, no matter if a second player enters, the trigger is not rearmed by deactivation.

So, your best bet is to create a trigger on each PC, locally. Then you will not have to remoteExec the hint for instance.

So, let all your stuff in init.sqf (as this file runs for any JIP + server), and just createTrigger locally:

trg1 = createTrigger ["EmptyDetector", getMarkerPos "Marker1",false]; // add false as 3rd argument

 

  • Like 1

Share this post


Link to post
Share on other sites

@Luckyas Dude, you need to make your trigger global 


trg1 = createTrigger ["EmptyDetector", getMarkerPos "Marker1",true];

 

Share this post


Link to post
Share on other sites

@blacknightBK     No! I explained why.

If you can read,

- first: you can admit the createTrigger is global by default, so, true in 3rd argument or nothing like LuckyAs attempted to do, is same;

- Second: firing a  trigger means to rearm it by deactivation. In this case (player presence), it's more difficult in MP with a global one.

 

Share this post


Link to post
Share on other sites
1 minute ago, pierremgi said:

@blacknightBK     No! I explained why.

If you can read,

- first: you can admit the createTrigger is global by default, so, true in 3rd argument or nothing like LuckyAs attempted to do, is same;

- Second: firing a  trigger means to rearm it by deactivation. In this case (player presence), it's more difficult in MP.

 

 

Like I said, I am  noob, ignore me

Share this post


Link to post
Share on other sites
53 minutes ago, pierremgi said:

Your problem could be the trigger is firing with the first player entering the area then, no matter if a second player enters, the trigger is not rearmed by deactivation.

So, your best bet is to create a trigger on each PC, locally. Then you will not have to remoteExec the hint for instance.

So, let all your stuff in init.sqf (as this file runs for any JIP + server), and just createTrigger locally:


trg1 = createTrigger ["EmptyDetector", getMarkerPos "Marker1",false]; // add false as 3rd argument

 

Hey man. That does indeed make allot of sence. How did I not see that at the beginning. Like I said il try it once my friend comes online.

Thank you very much.

Share this post


Link to post
Share on other sites
20 hours ago, pierremgi said:

Your problem could be the trigger is firing with the first player entering the area then, no matter if a second player enters, the trigger is not rearmed by deactivation.

So, your best bet is to create a trigger on each PC, locally. Then you will not have to remoteExec the hint for instance.

So, let all your stuff in init.sqf (as this file runs for any JIP + server), and just createTrigger locally:


trg1 = createTrigger ["EmptyDetector", getMarkerPos "Marker1",false]; // add false as 3rd argument

 

Hey man. I just tested it with my friend but it doesn't work. I am still the only one getting affected by the trigger.

if (isServer) then {
execVM "airsiren.sqf";
mkr1 = createMarker ["Marker1", markerPos "vMarker1"];
	"Marker1" setMarkerShape "ELLIPSE";
	"Marker1" setMarkerSize [500, 500];
	"Marker1" setMarkerBrush "DiagGrid";
	"Marker1" setMarkerColor "ColorBlue";
trg1 = createTrigger ["EmptyDetector", getMarkerPos "Marker1", false];
	trg1 setTriggerArea [500, 500, 0, false];
	trg1 setTriggerActivation ["ANYPLAYER", "NOT PRESENT", true];
	trg1 setTriggerStatements ["this", "hint 'You have 10 seconds to get back in the zone!'", "hint ''"];
trg1kill = createTrigger ["EmptyDetector", getMarkerPos "Marker1", false];
	trg1kill setTriggerArea [500, 500, 0, false];
	trg1kill setTriggerTimeout [10, 10, 10, true];
	trg1kill setTriggerActivation ["ANYPLAYER", "NOT PRESENT", true];
	trg1kill setTriggerStatements ["this", "player setDamage 1", ""];
};

Do you know a possible solution for this problem?

Share this post


Link to post
Share on other sites
8 minutes ago, Luckyas said:

Hey man. I just tested it with my friend but it doesn't work. I am still the only one getting affected by the trigger.


if (isServer) then {
execVM "airsiren.sqf";
mkr1 = createMarker ["Marker1", markerPos "vMarker1"];
	"Marker1" setMarkerShape "ELLIPSE";
	"Marker1" setMarkerSize [500, 500];
	"Marker1" setMarkerBrush "DiagGrid";
	"Marker1" setMarkerColor "ColorBlue";
trg1 = createTrigger ["EmptyDetector", getMarkerPos "Marker1", false];
	trg1 setTriggerArea [500, 500, 0, false];
	trg1 setTriggerActivation ["ANYPLAYER", "NOT PRESENT", true];
	trg1 setTriggerStatements ["this", "hint 'You have 10 seconds to get back in the zone!'", "hint ''"];
trg1kill = createTrigger ["EmptyDetector", getMarkerPos "Marker1", false];
	trg1kill setTriggerArea [500, 500, 0, false];
	trg1kill setTriggerTimeout [10, 10, 10, true];
	trg1kill setTriggerActivation ["ANYPLAYER", "NOT PRESENT", true];
	trg1kill setTriggerStatements ["this", "player setDamage 1", ""];
};

Do you know a possible solution for this problem?

 

Where did you create the trigger??

Share this post


Link to post
Share on other sites
18 minutes ago, BlacKnightBK said:

Where did you create the trigger??

It sais it in the script. The trigger is being made at the position of the marker.

Share this post


Link to post
Share on other sites
Just now, Luckyas said:

It sais it in the script. The trigger is being made at the position of the marker.

I mean the file mate. What file did you create it in?

Share this post


Link to post
Share on other sites
Just now, BlacKnightBK said:

I mean the file mate. What file did you create it in?

In a script called blackfish.sqf. And that script is being called by the init.sqf

Share this post


Link to post
Share on other sites
Just now, Luckyas said:

In a script called blackfish.sqf. And that script is being called by the init.sqf

Try to create the trigger in the initplayerlocal.sqf

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

×