SA-MP Forums Archive
Timer Not working. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer Not working. (/showthread.php?tid=276246)



Timer Not working. - Alex_Obando - 13.08.2011

When I launch the command it teleports the players to me (Which is good)
But the timer is not working, I want them to teleport to me in 10 seconds.

http://pastebin.com/rLgmrxzN


Re: Timer Not working. - grand.Theft.Otto - 13.08.2011

Try this:

pawn Код:
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
    new string[100];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerPos(playerid, x, y, z);
    format(string, sizeof(string), "~g~Admin ~w~%s started a war ~n~ You will be teleported in ~r~10 seconds!. ", name);
    GameTextForAll(string, 5000, 5 );

    SetTimerEx("Teleport",10000,false,"d",playerid);
    print(string);
    return 1;
}

forward Teleport(playerid);
public Teleport(playerid)
{
    new Float:x, Float:y, Float:z;
    SetPlayerPos(playerid, x, y, z);
    return 1;
}



Respuesta: Timer Not working. - Alex_Obando - 13.08.2011

pawn Код:
forward Teleport(playerid);
public Teleport(playerid)
{
    new Float:x, Float:y, Float:z;
    SetPlayerPos(playerid, x, y, z);
    return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
 if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
    new string[100];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerPos(playerid, x, y, z);
    format(string, sizeof(string), "~g~Admin ~w~%s started a war ~n~ You will be teleported in ~r~10 seconds!. ", name);
    GameTextForAll(string, 5000, 5 );
    SetTimerEx("Teleport",10000,false,"d",playerid);
    print(string);
    return 1;
}
    return 0;
}
pawn Код:
C:\Users\Alex\Desktop\Otros\CodSamp\codsamp_aw\filterscripts\AntiHH.pwn(102) : error 017: undefined symbol "x"
C:\Users\Alex\Desktop\Otros\CodSamp\codsamp_aw\filterscripts\AntiHH.pwn(109) : warning 217: loose indentation
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.



Re: Timer Not working. - Scenario - 13.08.2011

Try this:

pawn Код:
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
    new szString[128], Float:Position[3], szName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, szName, sizeof(szName));
    GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
    format(szString, sizeof(szString), "~g~Admin ~w~%s started a war ~n~ You will be teleported in ~r~10 seconds!. ", szName);
    GameTextForAll(szString, 5000, 5 );

    SetTimerEx("TeleportPlayers", 10000, false, "d", playerid, Position[0], Position[1], Position[2]);
    return 1;
}

forward TeleportPlayers(playerid, Float:X, Float:Y, Float:Z);
public TeleportPlayers(playerid, Float:X, Float:Y, Float:Z)
{
    for(new i = 0; i < MAX_PLAYERS; i++) SetPlayerPos(i, X, Y, Z);
    return 1;
}



Re: Timer Not working. - [L3th4l] - 13.08.2011

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Try this:
You will need to pass the floats too, and you don't need the playerid in the function.

pawn Код:
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
    new szString[128], Float:Position[3], szName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, szName, sizeof(szName));
    GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
    format(szString, sizeof(szString), "~g~Admin ~w~%s started a war ~n~ You will be teleported in ~r~10 seconds!. ", szName);
    GameTextForAll(szString, 5000, 5 );

    SetTimerEx("TeleportPlayers", 10000, false, "fff", Position[0], Position[1], Position[2]);
    return 1;
}

forward TeleportPlayers(Float:X, Float:Y, Float:Z);
public TeleportPlayers(Float:X, Float:Y, Float:Z)
{
    for(new i = 0; i < MAX_PLAYERS; i++) SetPlayerPos(i, X, Y, Z);
    return 1;
}



Re: Timer Not working. - Scenario - 13.08.2011

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
You will need to pass the floats too, and you don't need the playerid in the function.

pawn Код:
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
    new szString[128], Float:Position[3], szName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, szName, sizeof(szName));
    GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
    format(szString, sizeof(szString), "~g~Admin ~w~%s started a war ~n~ You will be teleported in ~r~10 seconds!. ", szName);
    GameTextForAll(szString, 5000, 5 );

    SetTimerEx("TeleportPlayers", 10000, false, "fff", Position[0], Position[1], Position[2]);
    return 1;
}

forward TeleportPlayers(Float:X, Float:Y, Float:Z);
public TeleportPlayers(Float:X, Float:Y, Float:Z)
{
    for(new i = 0; i < MAX_PLAYERS; i++) SetPlayerPos(i, X, Y, Z);
    return 1;
}
Oh wait, that's right! I forgot about that...