Agian Timer Problems! [NEED HELP]
#1

Ok, So today i add a new command and i dont know why this wont work. I've got some other's teleports with Timer and they are working, I'll copy the same code to this and this doesnt work :/

Here's the code

pawn Код:
on top of script
new stunt2timer;
pawn Код:
and on playerdissconnect
KillTimer(stunt2timer);
pawn Код:
if(strcmp("/stunt2", cmdtext, true, 10) == 0)
    {
    SetPlayerInterior(playerid,0);
    GameTextForPlayer(playerid, "Objects Loading..", 1000, 1);
    stunt2timer = SetTimerEx("FreezeTimer",3000,0,"d",playerid);
    SetPlayerPos(playerid, 465.7092,-2250.7974,24.2511);
    SendClientMessage(playerid, COLOR_YELLOW, "You have been teleported!");
    return 1;
It just do nothing, The GameTextForPlayer appear and the timer doesnt work
Reply
#2

pawn Код:
//top of script:
new stunt2timer;
//under ongamemodeinit:
stunt2timer = SetTimerEx("FreezeTimer",3000,0,"d",playerid);

if(strcmp("/stunt2", cmdtext, true, 10) == 0)
    {
    SetPlayerInterior(playerid,0);
    GameTextForPlayer(playerid, "Objects Loading..", 1000, 1);
    SetTimerEx("FreezeTimer",3000,0,"d",playerid);
    SetPlayerPos(playerid, 465.7092,-2250.7974,24.2511);
    SendClientMessage(playerid, COLOR_YELLOW, "You have been teleported!");
    return 1;
}
Reply
#3

Quote:
Originally Posted by ikarus
Посмотреть сообщение
pawn Код:
//top of script:
new stunt2timer;
//under ongamemodeinit:
stunt2timer = SetTimerEx("FreezeTimer",3000,0,"d",playerid);

if(strcmp("/stunt2", cmdtext, true, 10) == 0)
    {
    SetPlayerInterior(playerid,0);
    GameTextForPlayer(playerid, "Objects Loading..", 1000, 1);
    SetTimerEx("FreezeTimer",3000,0,"d",playerid);
    SetPlayerPos(playerid, 465.7092,-2250.7974,24.2511);
    SendClientMessage(playerid, COLOR_YELLOW, "You have been teleported!");
    return 1;
}
Should I delete the timer from the cmd?
Reply
#4

Why do you even need to store the timers ID, it's not repeating so you won't be needing to kill it.

Can we see public FreezeTimer function please? Also shouldn't that teleport be more like

pawn Код:
if(strcmp("/stunt2", cmdtext, true, 10) == 0)
{
    SetPlayerInterior(playerid,0);
    GameTextForPlayer(playerid, "Objects Loading..", 1000, 1);
    TogglePlayerControllable(playerid,false);
    SetTimerEx("FreezeTimer",3000,0,"d",playerid);
    SetPlayerPos(playerid, 465.7092,-2250.7974,24.2511);
    SendClientMessage(playerid, COLOR_YELLOW, "You have been teleported!");
    return 1;
}
Since I assume you're trying to freeze them for 3 seconds then unfreeze them with FreezeTimer...?

There's no need for stunt2timer variable for this timer.
Reply
#5

pawn Код:
public FreezeTimer(playerid)
{
  TogglePlayerControllable(playerid,1);
  return 1;
}
Reply
#6

Quote:
Originally Posted by matthewdriftking
Посмотреть сообщение
pawn Код:
public FreezeTimer(playerid)
{
  TogglePlayerControllable(playerid,1);
  return 1;
}
Then all you need is this

pawn Код:
if(strcmp("/stunt2", cmdtext, true, 10) == 0)
{
    SetPlayerInterior(playerid,0);
    GameTextForPlayer(playerid, "Objects Loading..", 1000, 1);
    TogglePlayerControllable(playerid,false);
    SetTimerEx("FreezeTimer",3000,0,"d",playerid);
    SetPlayerPos(playerid, 465.7092,-2250.7974,24.2511);
    SendClientMessage(playerid, COLOR_YELLOW, "You have been teleported!");
    return 1;
}
Forget about KillTimer and new stunt2timer.
Reply
#7

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Then all you need is this

pawn Код:
if(strcmp("/stunt2", cmdtext, true, 10) == 0)
{
    SetPlayerInterior(playerid,0);
    GameTextForPlayer(playerid, "Objects Loading..", 1000, 1);
    TogglePlayerControllable(playerid,false);
    SetTimerEx("FreezeTimer",3000,0,"d",playerid);
    SetPlayerPos(playerid, 465.7092,-2250.7974,24.2511);
    SendClientMessage(playerid, COLOR_YELLOW, "You have been teleported!");
    return 1;
}
Forget about KillTimer and new stunt2timer.
Oh Thanks alot man, Only kill the timers when i have SetTimer(...); only?
Reply
#8

Quote:
Originally Posted by matthewdriftking
Посмотреть сообщение
Oh Thanks alot man, Only kill the timers when i have SetTimer(...); only?
You only really need to kill timers if they repeat or are quite long.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)