Jump to content
Nutzgo

Spawn and disable spawn on command

Recommended Posts

So I'm making a kind of "shooting range"-scenario with live targets. On one place, I want the players to have the possibility to spawn enemy units.

Per now I have a laptop with Init ->

Quote

this addAction ["Spawn",{spawned=true;publicVariable "Spawned";}];


I have a SpawnAI-module with VariableName "spawn1", synced with a trigger with condition ->"Spawned" - that starts spawning of 1 enemy AI. When he dies, a new one spawns after 15 seconds.
But I can't figure out a 'temporary disable' function. 

Help? :dontgetit:

Share this post


Link to post
Share on other sites
  1. Make your trigger repeatable.
  2. (Define your variable spawned on mission start, eg in the init of the module)
  3. Change your laptop init to this:
this addAction ["Toggle Spawn",{spawned = [true,false] select spawned; publicVariable "spawned"}];

Explanation:

spawned = [true,false] select spawned;

same as 

spawned = if (spawned) then {true} else {false};

but faster. true values will be treated as 1 and false values as 0.

You may want to add a tag to your global variables as "spawned" is very generic and might be used by the game or another script.

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, 7erra said:

spawned = [true,false] select spawned;

same as 


spawned = if (spawned) then {false} else {true};

 

fixed IF statement in quote as it was round the wrong way )

Just...

spawned = !spawned
  • Like 3
  • Confused 1

Share this post


Link to post
Share on other sites
4 hours ago, Larrow said:

fixed IF statement in quote as it was round the wrong way )

Just...


spawned = !spawned

As simple as it gets.

Also the fastest way to flick a switch so to speak.

spawned = if (spawned) then {false} else {true};//0.0014ms
spawned = [true,false] select spawned;//0.0011ms
spawned = !spawned;//0.0006ms

 

Cheers

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks guys! :) I'll try it out

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

×