KillTimer not work
#1

PHP код:
    TextDrawShowForPlayer(playerid, TimeBank[playerid]);
        
Time[playerid] = 10;
    
SetTimerEx("CountDown", 1000, 1, "i",playerid);
forward CountDown(playerid);
public 
CountDown(playerid)
{
    new 
string[30];
    if(
Time[playerid] == 0)
    {
        
ResetRobbery(playerid, 1);
        
TextDrawHideForPlayer(playerid, TimeBank[playerid]);
        
KillTimer(TimerCount[playerid]);
        
TimerCount[playerid] = -1;
        
SendClientMessage(playerid, 0xFFFFFFFF, "0");
        return;
    }
    
Time[playerid] --;
    
format(string, sizeof string, "%s",ConvertToMinutes(Time[playerid]));
    
TextDrawSetString(TimeBank[playerid], string);
} 
chatlog.txt
PHP код:
[14:12:22] 0
[14:12:23] 0
[14:12:24] 0
[14:12:25] 0
[14:12:26] 0
[14:12:27] 0
[14:12:28] 0
[14:12:29] 0 
Why not work?
Reply
#2

Change
Код:
SetTimerEx("CountDown", 1000, 1, "i",playerid);
to
Код:
TimerCount[playerid] = SetTimerEx("CountDown", 1000, 1, "i",playerid);
Reply
#3

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
Change
Код:
SetTimerEx("CountDown", 1000, 1, "i",playerid);
to
Код:
TimerCount[playerid] = SetTimerEx("CountDown", 1000, 1, "i",playerid);
Thanks.i forget TimerCount[playerid]
Reply
#4

Why this timer not kill?
PHP код:
    if(UseCmd[playerid] == 5)
    {
        
TimerCMD[playerid] = SetTimerEx("EnableUse", 12000, true, "d", playerid);
        return 
1;
    } 
PHP код:

forward EnableUse
(playerid);
public 
EnableUse(playerid)
{
    if(
UseCmd[playerid] == 0)
    {
        
KillTimer(TimerCMD[playerid]);
        
TimerCMD[playerid] = -1;
        
SendClientMessage(playerid,COLOR_ERROR,"0");
        return 
1;
    }
    
UseCmd[playerid] --;
    return 
1;
} 
chatlog
PHP код:
[14:46:06] 0
[14:46:11] 0
[14:46:14] 0
[14:46:20] 0
[14:46:24] 0
[14:46:27] 0 
Reply
#5

Maybe you start the timer more than one time?
Reply
#6

try this

PHP код:
forward EnableUse(playerid);
public 
EnableUse(playerid)
{
    if(
UseCmd[playerid] != 0)
    {
        
UseCmd[playerid] --;
        if(
UseCmd[playerid] == 0)
        {
            
KillTimer(TimerCMD[playerid]);
            
TimerCMD[playerid] = -1;
            
SendClientMessage(playerid,COLOR_ERROR,"0");
        }
    }
    return 
1;
} 
Reply
#7

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Maybe you start the timer more than one time?
Yes,When UseCmd for player is 5 and again use cmd,Timer create again.
PHP код:
    if(UseCmd[playerid] == 5) 
    { 
        
TimerCMD[playerid] = SetTimerEx("EnableUse", 12000, true, "d", playerid); 
        return 
1; 
    } 
How to check timer is valid?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)