Jump to content
Sign in to follow this  
ezremake

Getting local scripts to fire once at a time

Recommended Posts

I've been using repeatable triggers that spawn in AI units based on a player's distance to the trigger,

 

For instance, for the G1 trigger, which checks and lists Independent faction members, has the condition field is as follows:

({alive _x} count units Group1) <= 0 && player distance G1 <= 400  && player distance G1 >= 200 && ({alive _x} count thisList) <= 1

This works exactly as it should if a player enters the area; so long as there are no current Group1 members alive, and no other Independents in the area - the AI are spawned in at the marker location "Group1".

 

The AI are spawned locally, as to not overwhelm the server with AI computations.

 

 

The problem: If two or more players trip the trigger simultaneously, which is mostly seen with players riding in vehicles together, the trigger will run multiple times, as technically Group1 doesn't have any units yet.

 

How can I prevent this type of overlap without having to revert to spawning units server side?

Share this post


Link to post
Share on other sites

And just as I posted this I came up with an idea to try, someone correct me if I'm wrong.

 

Since execVM puts scripts in scheduled environment, wouldn't this issue be solved if I moved the

({alive _x} count units Group1) <= 0

To the script itself, instead of the trigger condition which is non-scheduled?

 

That way the distance conditions can run multiple times all they want, but because the scripts are scheduled, all instances run after the first won't spawn in units?

Share this post


Link to post
Share on other sites

Sadly this turned out not to be the solution, the script will still fire multiple times if tripped simultaneously.

 

Any ideas?

Share this post


Link to post
Share on other sites

Scripted trigger on a single client?

 

init.sqf:

if (!isServer && // client condition here) then {   // create scripted trigger };

 

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  

×