KillTimer doesnt work...
#1

So I made a place for AFK users whenever the system checks if the player is in the same position for 1 minute, everything works except the timers, they don't stop.

Here's the afk system
Код:
     if(AFK[i] == 60)      {
        AFK[i] = 0;         IsAFK[i] = true;
        SendClientMessage(i, -1, "{cc99ff}(afk) Don't go afk in public places, go /lounge instead.");
        SendClientMessage(i, -1, "{cc99ff}(lounge) Type /back once you are back to the game.");
        KillTimer(dmgtimer);
        KillTimer(AFKTime[i]);
        KillTimer(respecttimer);
		SetPlayerPos(i, -794.806396,497.738037,1376.195312);
		SetPlayerInterior(i, 1);
		SetPlayerVirtualWorld(i,10);
		IsPlayerInLobby[i] = 1;
		SetPlayerHealth(i, 99999);
		ResetPlayerWeapons(i);
      }
Timers I want to stop:

Код:
new dmgtimer;
new respecttimer;
new AFKTime[MAX_PLAYERS];

	AFKTime[playerid] = SetTimer("AFKCheck",1000,1);
	dmgtimer = SetTimerEx("CountPlayerDamage", 900000, 1, "i", playerid); 
	respecttimer = SetTimerEx("CountPlayerRespect", 360000, 1, "i", playerid);
Reply
#2

for what timer KillTimer dont work?
Reply
#3

It needs to kill it, and suddenly stop working. until I get back from lounge.
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
My guess would be you need an array of timers, as you probably keep overwriting that variable for each player.

Also: A handy hint for the future. When you are writing code and it doesn't work, the problem is probably NOT the function used by thousands of people for decades, but probably something you did. "KillTimer" works perfectly, next time please look to your own code for the issue.
Sure I will, I just don't understand why would I need using arrays and how I am overwriting the variable if it's only shown when he's afk.
Reply
#5

Quote:
Originally Posted by severance
Посмотреть сообщение
Sure I will, I just don't understand why would I need using arrays and how I am overwriting the variable if it's only shown when he's afk.
PHP код:
    dmgtimer SetTimerEx("CountPlayerDamage"9000001"i"playerid); 
    
respecttimer SetTimerEx("CountPlayerRespect"3600001"i"playerid); 
Your timers are per player but your variables aren't

PHP код:
new dmgtimer[MAX_PLAYERS];
new 
respecttimer[MAX_PLAYERS];
new 
AFKTime[MAX_PLAYERS];
    
AFKTime[playerid] = SetTimer("AFKCheck",1000,1);
    
dmgtimer[playerid] = SetTimerEx("CountPlayerDamage"9000001"i"playerid); 
    
respecttimer[playerid] = SetTimerEx("CountPlayerRespect"3600001"i"playerid); 
and later
PHP код:
     if(AFK[i] == 60)      {
        
AFK[i] = 0;         IsAFK[i] = true;
        
SendClientMessage(i, -1"{cc99ff}(afk) Don't go afk in public places, go /lounge instead.");
        
SendClientMessage(i, -1"{cc99ff}(lounge) Type /back once you are back to the game.");
        
KillTimer(dmgtimer[i]);
        
KillTimer(AFKTime[i]);
        
KillTimer(respecttimer[i]);
        
SetPlayerPos(i, -794.806396,497.738037,1376.195312);
        
SetPlayerInterior(i1);
        
SetPlayerVirtualWorld(i,10);
        
IsPlayerInLobby[i] = 1;
        
SetPlayerHealth(i99999);
        
ResetPlayerWeapons(i);
      } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)