SA-MP Forums Archive
KillTimer bug - 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: KillTimer bug (/showthread.php?tid=264891)



KillTimer bug - Edga - 28.06.2011

Ok so i have this problem, where my timer wont kill itself. The easiest way will be just to show you.

This is what i have in my GM.

pawn Код:
forward Game(playerid);// at the top
new gamet[MAX_PLAYERS];// at the top
new playing[MAX_PLAYERS];// at the top
new minute[MAX_PLAYERS];// at the top

public OnPlayerConnect(playerid)
{
new HH, MM, SS;
gettime(HH, MM, SS);
minute[playerid]= MM;

LoadPlayerData(playerid); // This sets playing[playerid] = 1;
gamet[playerid]=SetTimerEx("Game",60*1000,true,"i",playerid);
return 1;
}

public OnPlayerDisconnect(playerid,reason)
{
playing[playerid] = 0;
KillTimer(gamet[playerid]);
KillTimer(gamet[playerid]);
KillTimer(gamet[playerid]);
return 1;
}

public Game(playerid)
{
new HR,MNT,SC;
gettime(HR,MNT,SC);
if(MNT==minute[playerid]){return 1;}
playerid[minute]=MNT;
if(!IsPlayerConnected(playerid)){KillTimer(gamet[playerid]); printf("[ID %i] Game Offline [1]",playerid);
return 1;}
if(playing[playerid] != 1){KillTimer(gamet[playerid]); printf("[ID %i] Game Offline [2]",playerid); return 1;}
print("Game");
// Stuff happens here  if online
return 1;
}
But after 24hrs with over 300 people who played in my server this is what the serverlog looks like.

Quote:

[01:22:57] [ID 101] Game Offline [1]
[01:22:58] Game
[01:22:59] [kill] Marius_Leonavicius killed Paulius_Typeris M4
[01:22:59] Game
[01:23:00] [ID 61] Game Offline [1]
[01:23:00] [COMM] Simis_Ofenas: /zvejoti
[01:23:01] OnPlayerEnterCheckpoint
[01:23:01] [ID 75] Game Offline [1]
[01:23:01] Game
[01:23:01] [chat] [Paulius_Ratkevicius]: kviesk
[01:23:02] [chat] [Dziugas_Dogital]: dw pakviecam ?
[01:23:02] [ID 53] Game Offline [1]
[01:23:03] [ID 85] Game Offline [1]
[01:23:03] OnPlayerSpawn
[01:23:03] [ID 113] Game Offline [1]
[01:23:04] Game
[01:23:04] Game
[01:23:04] [ID 94] Game Offline [1]
[01:23:04] Game
[01:23:05] [ID 97] Game Offline [1]
[01:23:05] [ID 67] Game Offline [1]
[01:23:05] [ID 45] Game Offline [1]
[01:23:06] OnPlayerEnterCheckpoint
[01:23:06] [ID 56] Game Offline [1]
[01:23:06] [ID 27] Game Offline [1]
[01:23:06] [ID 92] Game Offline [1]
[01:23:07] [COMM] Laurynas_Santos: /sms ovis baikit tas nesamones
[01:23:07] [ID 18] Game Offline [1]
[01:23:07] [ID 89] Game Offline [1]
[01:23:08] [chat] [Paulius_Ratkevicius]: davai'D
[01:23:08] [ID 69] Game Offline [1]
[01:23:08] Crash
[01:23:08] [part] Povilas_Trol has left the server (0:0)
[01:23:08] [ID 17] Game Offline [1]
[01:23:09] Game
[01:23:09] [ID 109] Game Offline [1]
[01:23:09] [ID 28] Game Offline [1]
[01:23:10] Game
[01:23:10] Game
[01:23:10] [COMM] Dziugas_Dogital: /r reike taxsi
[01:23:10] [ID 82] Game Offline [1]
[01:23:10] OnPlayerEnterCheckpoint
[01:23:10] Game
[01:23:10] [ID 81] Game Offline [1]
[01:23:11] [COMM] Simis_Ofenas: /zvejoti
[01:23:11] [ID 11] Game Offline [1]
[01:23:11] [ID 34] Game Offline [1]
[01:23:11] Game
[01:23:12] [ID 47] Game Offline [1]
[01:23:12] [ID 93] Game Offline [1]

This was'nt a problem before because i did'nt have 100+ people playing on my server but now it is as the people number increased. Does anybody know why it does'nt kill the timer ?!


Re: KillTimer bug - Edga - 28.06.2011

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
I had a similar problem, easy fix:

Run a global timer and just loop players in that, plus it's way more efficient because you're just calling one function every interval.

And don't forget to use IsPlayerConnected in your function, and definitely make sure you have edited your MAX_PLAYERS in a_samp.inc OR using foreach for loops.
Good idea but the last time i did that except i used it for jail and for every second it only worked for the first player (ID 0). I think its because i used return 1; after every loop ? could that be true ?


Re: KillTimer bug - Edga - 28.06.2011

Quote:
Originally Posted by ******
Посмотреть сообщение
Why do try kill to three times?
Cuz it wont kill it DD