Jump to content
Sign in to follow this  
Whisperdrive

Teleport script with individual cooldowns for players

Recommended Posts

Hello everyone,

In my MP zeus mission I am trying to establish a 2-way teleport system using flagpoles at point A and Point B. As an addaction I can easily enough get players to scroll wheel and teleport themselves from Point A to Point B and back again using the flagpoles

Quote

 this addAction ["Teleport", {player setPos (getPos object)}];

 

However, I was wondering if it is possible to introduce a delay/sleep timer of about a minute to the teleport script (maybe with a hint that says "teleport in cooldown") that is for each player. For example,  player 1 teleports from flagpole A to flagpole B and is then unable to teleport back for 1 min while simultaneously player 2 is still able to interact with flagpole B to get themselves to A (and similar delay to teleport back).

Apologies if this is kind of question is not allowed, i'm somewhat new to Arma and im learning as much as I can on YT tutorials but this seems a bit beyond me. If anyone can help that would be amazing.

Share this post


Link to post
Share on other sites

Something like this might do the trick:

 

//put this in initPlayerLocal.sqf
GOM_fnc_initTeleport = {
	params ["_from","_to"];
	_from addAction [format ["Teleport to %2",_to],{
		params ["_object","_caller","_ID","_args"];
		_args params ["_from","_to"];
		if (_caller getVariable ["GOM_fnc_timeOut",-60] < time) then {
			_caller setPosATL getPosATL _to;
			_caller setVariable ["GOM_fnc_timeOut",time + 60];
		} else {
			systemchat format ["Teleport still in cooldown! %1s left!",round (time - (_caller getVariable ["GOM_fnc_timeOut",-60])) * -1 ];
		};
	},[_from,_to]];
};

_teleport1 = [flag1,flag2] call GOM_fnc_initTeleport;//enables teleport from flag1 to flag2
_teleport1 = [flag2,flag1] call GOM_fnc_initTeleport;//enables teleport from flag2 to flag1

Cheers

  • Like 3

Share this post


Link to post
Share on other sites
18 minutes ago, Grumpy Old Man said:

Something like this might do the trick:

 


//put this in initPlayerLocal.sqf
GOM_fnc_initTeleport = {
	params ["_from","_to"];
	_from addAction [format ["Teleport to %2",_to],{
		params ["_object","_caller","_ID","_args"];
		_args params ["_from","_to"];
		if (_caller getVariable ["GOM_fnc_timeOut",-60] < time) then {
			_caller setPosATL getPosATL _to;
			_caller setVariable ["GOM_fnc_timeOut",time + 60];
		} else {
			systemchat format ["Teleport still in cooldown! %1s left!",round (time - (_caller getVariable ["GOM_fnc_timeOut",-60])) * -1 ];
		};
	},[_from,_to]];
};

_teleport1 = [flag1,flag2] call GOM_fnc_initTeleport;//enables teleport from flag1 to flag2
_teleport1 = [flag2,flag1] call GOM_fnc_initTeleport;//enables teleport from flag2 to flag1

Cheers


Hey, thanks for the reply. I tried the code but alas it didn't work. I put the code in, placed down two flagpoles from the CUP mod and renamed it 'flag 1' and 'flag 2' but I couldn't interact with them. The addAction didnt seem to give me the teleport prompt, as the script would suggest.
Let me know if I am being a real dingus and missed a critical step :/

Cheers

Share this post


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


Hey, thanks for the reply. I tried the code but alas it didn't work. I put the code in, placed down two flagpoles from the CUP mod and renamed it 'flag 1' and 'flag 2' but I couldn't interact with them. The addAction didnt seem to give me the teleport prompt, as the script would suggest.
Let me know if I am being a real dingus and missed a critical step :/

Cheers

Variable names have to be single words, so 'flag 1' and 'flag 2' won't work.

 

Cheers

Share this post


Link to post
Share on other sites
1 hour ago, Grumpy Old Man said:

Variable names have to be single words, so 'flag 1' and 'flag 2' won't work.

 

Cheers

Sorry, I mistyped it here - in the editor ive wriiten it as indicated; flag1 and flag2 (like so) but I cant get it to work. When I try and test it on MP, I get an error that says this 
I can't seem to fathom why its indicating a ; is required at line 5, as 

GOM_fnc_initTeleport = {

doesn't need to be closed. I assume that the error in question is what is buggering the code from running but I have no idea what I should do to address it as the script looks fine to me, then again I am not very knowledgeable in this area so I might be missing a glaring problem. :eh:

Share this post


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

Sorry, I mistyped it here - in the editor ive wriiten it as indicated; flag1 and flag2 (like so) but I cant get it to work. When I try and test it on MP, I get an error that says this 
I can't seem to fathom why its indicating a ; is required at line 5, as 


GOM_fnc_initTeleport = {

doesn't need to be closed. I assume that the error in question is what is buggering the code from running but I have no idea what I should do to address it as the script looks fine to me, then again I am not very knowledgeable in this area so I might be missing a glaring problem. :eh:

Like Grumpy said - you are missing a semicolon somewhere before 


GOM_fnc_initTeleport = {

either in a line of code -or- you failed to comment a line properly. Eitherway, test the code out on its own without any other script in the initPlayerLocal.sqf and see if it works, because there isn't anything wrong with the code that I can see.

  • Thanks 1

Share this post


Link to post
Share on other sites

I just removed everything in the  initPlayerLocal.sqf and pasted the code and it seemed to work. Dunno why but thanks everyone for the help

  • Like 1

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  

×