Jump to content
Luckyas

Trigger script not working correctly in MP

Recommended Posts

Just now, BlacKnightBK said:

Try to create the trigger in the initplayerlocal.sqf

That would give the same result.

Share this post


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

That would give the same result.

Have you tried it? Because the initplayerlocal runs the script inside it for every player when they join the mission

Share this post


Link to post
Share on other sites

Make a local trigger and think about who must activate it.

Any player or only one player...

Share this post


Link to post
Share on other sites

Sorry, I didn't pay attention to last posts. If you write if (isServer) then {...}; obviously the code will run on server only (hosted one I guess)

That's not what is intended.

So think about each line of code!

In init.sqf, everything will work fine on each PC if you create your trigger locally (false).

Remark: same for airSiren.sqf. This code must run on each PC I presume. For markers, if you create a marker (not local), it will be visible everywhere. So, the server here is a good place. I'm not sure why you're creating a marker "marker1" on an already existing marker: "vmarker1".

 

And, as far as you want to be sure that player variable is consistent locally, you have two ways:

in initPlayerLocal, the script runs locally when the player is already defined. So, the script for triggers is OK here,

in init.sqf, you can add: waitUntil {local player}; or waitUntil {!isNull player}; before your code.

Share this post


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

Sorry, I didn't pay attention to last posts. If you write if (isServer) then {...}; obviously the code will run on server only (hosted one I guess)

That's not what is intended.

So think about each line of code!

In init.sqf, everything will work fine on each PC if you create your trigger locally (false).

Remark: same for airSiren.sqf. This code must run on each PC I presume. For markers, if you create a marker (not local), it will be visible everywhere. So, the server here is a good place. I'm not sure why you're creating a marker "marker1" on an already existing marker: "vmarker1".

 

And, as far as you want to be sure that player variable is consistent locally, you have two ways:

in initPlayerLocal, the script runs locally when the player is already defined. So, the script for triggers is OK here,

in init.sqf, you can add: waitUntil {local player}; or waitUntil {!isNull player}; before your code.

Thank you very much. Il test it out tomorrow. And for the airsiren.sqf, this is a simple script that will play a airsiren sound across the map. So that should be isServer aswell.

Share this post


Link to post
Share on other sites
On 11-4-2017 at 7:17 PM, pierremgi said:

Sorry, I didn't pay attention to last posts. If you write if (isServer) then {...}; obviously the code will run on server only (hosted one I guess)

That's not what is intended.

So think about each line of code!

In init.sqf, everything will work fine on each PC if you create your trigger locally (false).

Remark: same for airSiren.sqf. This code must run on each PC I presume. For markers, if you create a marker (not local), it will be visible everywhere. So, the server here is a good place. I'm not sure why you're creating a marker "marker1" on an already existing marker: "vmarker1".

 

And, as far as you want to be sure that player variable is consistent locally, you have two ways:

in initPlayerLocal, the script runs locally when the player is already defined. So, the script for triggers is OK here,

in init.sqf, you can add: waitUntil {local player}; or waitUntil {!isNull player}; before your code.

Hey man. This week I didn't have any time to test it, but yesterday I made a whole new script since it still doesn't work. Only problem is that this script also doesn't work. 

 

I made 2 script. 

"initServer.sqf" = This script creates the markers on the map, displays text and has all the timing in it. Once some time is over it will make a global variable become "true".

"initPlayerLocal.sqf" = This script will wait untill the global variables from "InitServer.sqf" become true. It will then create local triggers on the markers.

 

I tested this with my friend today, and he doesn't get affected by the triggers. They are not created by him I think.

Do you know how I can make this work?

 

Scripts:

https://pastebin.com/S5RJ7rce initPlayerLocal.sqf

https://pastebin.com/vrgvGAe7 initServer.sqf

Share this post


Link to post
Share on other sites

initServer runs on server only. A global variable is global (for each scripts) but local (on PCs where these scripts run). A common variable for all players is public.

But it's just an info. So, initPlayerLocal can wait a looong time your global but not public variable.

Just proceed like this:

zoneSchrink1 = true;

publicVariable "zoneSchrink1";

 

 

Share this post


Link to post
Share on other sites
On 11.4.2017 at 7:03 PM, Lucullus said:

Make a local trigger and think about who must activate it.

Any player or only one player...

 

You want a local effect on one client.

Why ask for "ANYPLAYER" ?

Share this post


Link to post
Share on other sites
1 hour ago, Lucullus said:

 

You want a local effect on one client.

Why ask for "ANYPLAYER" ?

 

I changed my previous post for more precision.

ANYPLAYER wraps all players. The first who meets, the trigger fires. On the other hand, don't ask me why, the trigger seems to rearm if you kill the "winner". It's weird as far as a dead player stays a player, in allPlayers command so far.

Anyway, you hit a point. ANYPLAYER will fire triggers, local or not.

ANYPLAYER is handy because it sorts player units among plenty of others. You can use BLUFOR or ANYBODY to obtain a working list.

But, for a specific firing on one PC only:

replace <this> in cond field by:

count (thislist select {local _x}) > 0

 

 

 

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

×