Jump to content
  • 0

Help with timer!


SadBoy1981

Question

I have 300x300 m  land where players after 240 seconds must be teleported away, but sometimes when timer is end, start counting like -1 -2 -3 ....... and teleporting away dont work!

Here is code

labirint_enter = getPlayerUID player;

labirint = [

	[
		[3420,2076],
		[3670,2337], 
		["xxxxxxx","xxxxxxxx"]
	]	
	
																				 
];

_timer = 240;
while {true} do { 
	if( labirint_enter in ["1111","2222"] ) then {  //admins
		while{true}do{};
	};
	_position = getPos player;
	_px = _position select 0;//X
	_py = _position select 1;//Y
	_flag = false;
	{
		_cx1 = (_x select 0) select 0;
		_cy1 = (_x select 0) select 1;
		_cx2 = (_x select 1) select 0;
		_cy2 = (_x select 1) select 1;
		_allowed = _x select 2; 
		if ( _px > _cx1 && _px < _cx2 && _py > _cy1 && _py < _cy2 && !(labirint_enter in _allowed)) then {
			_flag = true;
		};
	}forEach labirint;
	if ( _flag && alive player ) then {	
		titleText [format ["%1",_timer],"PLAIN",0];
		_timer = _timer - 1;
	}else{
		_timer = 240;
	};
	if ( _timer == -1 ) then {
    [] execVM "custom\spawning\locations\eject.sqf";
		titleText ["","PLAIN",0];
	};
	sleep 1;
};

b_560_95_1.png

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hm, maybe I don't understand it after a quick read...but how should this ever get true?

if ( _px > _cx1 && _px < _cx2 && _py > _cy1 && _py < _cy2 && !(labirint_enter in _allowed)) then {
            _flag = true;
        };

 

The forEach loop runs first with [3420,2076] and in the second iteration with [3670,2337].

_x is the current element processed.

So you never get both coordinate pairs in one iteration to get this:

       _cx1 = (_x select 0) select 0;
        _cy1 = (_x select 0) select 1;
        _cx2 = (_x select 1) select 0;
        _cy2 = (_x select 1) select 1;

 

As far as I understand this this is done one after another. Maybe for some reason this gets true. But not controlled by you. Or?

Link to comment
Share on other sites

  • 0

Hm, maybe I don't understand it after a quick read...but how should this ever get true?

if ( _px > _cx1 && _px < _cx2 && _py > _cy1 && _py < _cy2 && !(labirint_enter in _allowed)) then {

            _flag = true;

        };

 

The forEach loop runs first with [3420,2076] and in the second iteration with [3670,2337].

_x is the current element processed.

So you never get both coordinate pairs in one iteration to get this:

       _cx1 = (_x select 0) select 0;

        _cy1 = (_x select 0) select 1;

        _cx2 = (_x select 1) select 0;

        _cy2 = (_x select 1) select 1;

 

As far as I understand this this is done one after another. Maybe for some reason this gets true. But not controlled by you. Or?

 

Fixed

in my file   [] execVM "custom\spawning\locations\eject.sqf";  was line where script not allow teleport when in combat mode.

 

First lines from that file:

private ["_ebayrandomspawn"];
if (dayz_combat == 1) then {
titleText ["You can't use teleport while in combat.", "PLAIN DOWN", 3];
sleep 5;
titleFadeOut 1;
} else {
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...