KillTimer
#1

Im having a problem with killing my timer.. Its excecuting the second timer but its not killing DrugHealth


pawn Код:
SetTimerEx("DrugHealth", 5_000, true, "if", playerid, h);
pawn Код:
public DrugHealth(playerid, float)
{
    new Float:h;
    GetPlayerHealth(playerid, h);
    if(h < 100)
    {
        SetPlayerHealth(playerid, h+10);
        Info[playerid][Grams]--;
    }
    else if (h >= 100) return SetTimerEx("DrugHealthDone", 1_000, false, "if",playerid, float);
    return 1;
}
public DrugHealthDone(playerid, float)
{
    SendClientMessage(playerid, COLOR_GREEN, "The drugs have replenished your health");
    SetPlayerDrunkLevel(playerid, 0);
    KillTimer(DrugHealth(playerid, float));
    return 1;
}
Reply
#2

Because you didn't create it as anything.


pawn Код:
new DrugHealth
pawn Код:
DrugHealth = SetTimerEx("DrugHealthDone", 1_000, false, "if",playerid, float);

As example.


EDIT: Then kill is as KillTimer(DrugHealth);
Reply
#3

there's quite a few things I'd like to point out there.

Quote:

SetTimerEx("DrugHealth", 5_000, true, "if", playerid, h);

5_000? what's that? lol, shouldn't it be 5000?

second of all:

when you wanna kill a timer, you should define it first, like
pawn Код:
new Timer[ MAX_PLAYERS char ];
Timer{ playerid } = SetTimerEx( ... );

// then in the drughealthdone:
KillTimer( Timer{ playerid } );
Reply
#4

Quote:
Originally Posted by Blast3r
Посмотреть сообщение
Because you didn't create it as anything.


pawn Код:
new DrugHealth
pawn Код:
DrugHealth = SetTimerEx("DrugHealthDone", 1_000, false, "if",playerid, float);

As example.


EDIT: Then kill is as KillTimer(DrugHealth);
Thank you

Quote:
Originally Posted by Smileys
Посмотреть сообщение
there's quite a few things I'd like to point out there.


5_000? what's that? lol, shouldn't it be 5000?

second of all:

when you wanna kill a timer, you should define it first, like
pawn Код:
new Timer[ MAX_PLAYERS char ];
Timer{ playerid } = SetTimerEx( ... );

// then in the drughealthdone:
KillTimer( Timer{ playerid } );
5_000 is the same exact thing as 5000, i prefer doing it that way
Thank you, also
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)