Jump to content
  • 0

Delay Script


Airwaves Man

Question

Hey guys,

Im tying to delay a script. That means my script tests if a player is near 500m from a defined position. If a player is in the 500m radius the script will stop and should go on when no player is in the 500m radius. But I dont get that working. The script stops and does not continue after the player leaves the area. That is the beginning to the script and it should test only on the beginning that no player is near the position. After checking that no player ist near and continuing with the rest of the script it should not test again. Can someone help me out?

_coords = [14514,10424,0];

_timer = true;
while {_timer} do {
_playerNear = {isPlayer _x} count (_coords nearEntities ["CAManBase", 500]) > 0;
 waituntil {!_playerNear};
_timer=false;
};

Rest of the script

..

..

..

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 1

maybe if u need stop the script if thers players into the area.. then

//create a function with all your units,vehicles...

fn_spawn_all {
//create all here
};

_mission = true;
_playerPresent = false;
_timer = false;

_coords = [14514,10424,0];


while {_mission} do {
    sleep 10;
    
    {
    if((isPlayer _x) && (_x distance _coords <= 500)) then {_playerPresent = true};
    }forEach playableUnits;//check for nearest players
    
};

if (_playerPresent) then {

//Deletevehicle _i dont know... all into fn_spawnall  or maybe you wanna freeze they.

waitUntil{{isPlayer _x && _x distance _coords > 500  } count playableunits > 0}; 
_timer=true;
      _playerPresent = false;
};

if (_timer) then {
call fn_spawn_all;
};
Link to comment
Share on other sites

  • 0

@A Man

try:


_mission = true;
_playerPresent = false;
_timer = true;
_coords = [14514,10424,0];

while {_mission} do {
    sleep 10;
    
    {if((isPlayer _x) && (_x distance _coords <= 500)) then {_playerPresent = true};}forEach playableUnits;//check for nearest players
    
};

if (_playerPresent) then {

waitUntil{{isPlayer _x && _x distance _coords > 500  } count playableunits > 0}; 
_timer=false;
};

 

Link to comment
Share on other sites

  • 0

Big thx @juandayz and thx @BigEgg for your offer.

that code works as well:

 

_mission = true;
_playerPresent = false;
_timer = true;

_coords = [14514,10424,0];

while {_mission} do {
    sleep 10;
    
    {
    if((isPlayer _x) && (_x distance _coords <= 500)) then {
	_playerPresent = true
	} else {
	_mission = false;
	_timer = false;
	};
    }forEach playableUnits;//check for nearest players
    
};

if (_playerPresent) then {

waitUntil{{isPlayer _x && _x distance _coords > 500  } count playableunits > 0};
_timer=false;
};

if !(_timer) then {
      script code
      };

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...