[HELP]Time in the teleportation
#1

please help me to add a command in time to teleport the player to teleport only every 30 seconds.

Код:
if(strcmp(cmdtext,"/lv",true)==0)
  {
    SendClientMessage(playerid, COLOR_YELLOW,"Welcome to Las Venturas");
		ResetPlayerWeapons(playerid);
		TeleportPlayer(playerid, 2127.4023, 2364.2280, 10.8203);
    SetPlayerInterior(playerid,0);
		return 1;
  }
Reply
#2

Use Variables and a Timer; For Example.


Go to the top and Create the Just Teleported Variable:

pawn Код:
new JustTeleported[MAX_PLAYERS];
This will be set to '1' in the command and will be reseted to 0 with a timer, while if its 1 you will not be allowed to use the teleport.

_________________________________________________

Now, Set it as 0 When a new Player Connects under OnPlayerConnect Callback:

pawn Код:
JustTeleported[playerid] = 0;
If a player logs out, the variable stays saved on the memory, then you must set it to 0.

_________________________________________________

Now you're ready to apply and create the Timer to reset this variable.

pawn Код:
if(strcmp(cmdtext,"/lv",true)==0)
{
    if(JustTeleported[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You have teleported Recently!"); // here you do the check if the player got teleported recently
    SendClientMessage(playerid, COLOR_YELLOW,"Welcome to Las Venturas");
    ResetPlayerWeapons(playerid);
    TeleportPlayer(playerid, 2127.4023, 2364.2280, 10.8203);
    SetPlayerInterior(playerid,0);
    JustTeleported[playerid] = 1; // Here you set the variable that will be checked on the command and reseted on the timer
    SetTimerEx("ResetTeleport",30000,false,"i",playerid); // Here you set the timer so when its going to get reseted to 0
    return 1;
}
_________________________________________________

now you proceed with the timer

pawn Код:
forward ResetTeleport(playerid);
public ResetTeleport(playerid)
{
    new plname[24]; // Checking for The Name - Delete if the debug goes correctly
    GetPlayerName(playerid, plname, sizeof(plname)); // Checking for The Name - Delete if the debug goes correctly
    JustTeleported[playerid] = 0;
    print("30 Seconds has just Passed and %s is allowed to teleport!",plname); // Debug to check if this works correctly - Delete if the debug goes correctly
    return 1;
}
Reply
#3

Line with error

print("30 Seconds has just Passed and %s is allowed to teleport!",plname);

Код:
 warning 202: number of arguments does not match definition
Reply
#4

Just remove the print line from it, it's not necessary.

pawn Код:
forward ResetTeleport(playerid);
public ResetTeleport(playerid)
{
    new plname[24]; // Checking for The Name - Delete if the debug goes correctly
    GetPlayerName(playerid, plname, sizeof(plname)); // Checking for The Name - Delete if the debug goes correctly
    JustTeleported[playerid] = 0;
    return 1;
}
Reply
#5

use
pawn Код:
printf("30 Seconds has just Passed and %s is allowed to teleport!",plname);
instead

pawn Код:
print("30 Seconds has just Passed and %s is allowed to teleport!",plname);
Reply
#6

thank you works here
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)