SA-MP Forums Archive
little help delay teleport or /class - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: little help delay teleport or /class (/showthread.php?tid=475837)



little help delay teleport or /class - enzo27 - 15.11.2013

Hi how do I make delay teleport or class delay? Coz I am currently making a DM server and I don't want them to abuse teleport or switch class when they get hit or almost killed.

Let say if a player use a command teleport, then wait start 10 seconds countdown teleport to which player choose a place. If player who use the teleport got hit while countdown is being process then cancel the teleport.


Re: little help delay teleport or /class - dominik523 - 15.11.2013

I would make it something like this, try to modify it to your needs:
Код:
// top of the script 
new TeleportTime[MAX_PLAYERS];

// on gamemodeinit
SetTimer("OneSecTimer",1000,true);

// under onplayerconnect
TeleportTime[playerid] = -1;

// under your command
TeleportTime[playerid] = 10;

public OneSecTimer()
{
     foreach(Player, i)
     {
           if(TeleportTime[i] > 0 && TeleportTime[i] != -1)
           TeleportTime[i] --;
           else if(TeleportTime[i] == 0)
           // place here a stock or something for teleporting
      }
}
// and onplayertakedamage
if(TeleportTime[playerid] > 0) 
TeleportTime[playerid] = 0;



Re: little help delay teleport or /class - enzo27 - 15.11.2013

Quote:
Originally Posted by dominik523
Посмотреть сообщение
I would make it something like this, try to modify it to your needs:
Код:
// top of the script 
new TeleportTime[MAX_PLAYERS];

// on gamemodeinit
SetTimer("OneSecTimer",1000,true);

// under onplayerconnect
TeleportTime[playerid] = -1;

// under your command
TeleportTime[playerid] = 10;

public OneSecTimer()
{
     foreach(Player, i)
     {
           if(TeleportTime[i] > 0 && TeleportTime[i] != -1)
           TeleportTime[i] --;
           else if(TeleportTime[i] == 0)
           // place here a stock or something for teleporting
      }
}
// and onplayertakedamage
if(TeleportTime[playerid] > 0) 
TeleportTime[playerid] = 0;
Why it just teleport me without the countdown?


Re: little help delay teleport or /class - dominik523 - 15.11.2013

Did you put anything here?
Код:
public OneSecTimer()
{
     foreach(Player, i)
     {
           if(TeleportTime[i] > 0 && TeleportTime[i] != -1)
           TeleportTime[i] --;
           else if(TeleportTime[i] == 0)
           {
                 TeleportTime[i] = -1;
                 SetPlayerPos.... and so on
           }
      }
}