Timer Problem - 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)
+--- Thread: Timer Problem (
/showthread.php?tid=412028)
Timer Stops Working After Player Join. -
Admigo - 31.01.2013
Hi all,
I have a problem with my gamemode.
Sometimes when someone is joining on the server
this timer wont continue anymore(The timer stops).
When i reconnect server the timer continues.
pawn Код:
forward OneSecondTimer();
//ongamemodeinit
SetTimer("OneSecondTimer",1000,1);//An One Second Timer That Keeps Running On The Server
//
public OneSecondTimer()//
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Variable[i]>0)
{
Variable[i]--;
}
}
}
}
I dont kill the timer.
How can i fix this?
I also using all filterscripts in one gamemode like house and vehicle system.
Is that a problem?
Thanks Admigo
Re: Timer Problem -
Amora187 - 31.01.2013
Better if you use SetTimerEx(funcname[], interval, repeating, const format[], {Float,_}:...); so it will work default timer, For more information see the link:
https://sampwiki.blast.hk/wiki/SetTimerEx
Re : Timer Problem -
yusei - 31.01.2013
PHP код:
forward OneSecondTimer(playerid);
SetTimerEx("OneSecondTimer", 1000, false, "i", playerid);
public OneSecondTimer( playerid)//
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Variable[i]>0)
{
Variable[i]--;
}
}
}
}
Re: Re : Timer Problem -
Amora187 - 31.01.2013
Delete
Re: Re : Timer Problem -
Amora187 - 31.01.2013
Quote:
Originally Posted by yusei
PHP код:
forward OneSecondTimer(playerid);
SetTimerEx("OneSecondTimer", 1000, false, "i", playerid);
public OneSecondTimer( playerid)//
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Variable[i]>0)
{
Variable[i]--;
}
}
}
}
|
i think the right one is this as will skip multiple players in one player:
PHP код:
forward OneSecondTimer(playerid);
SetTimerEx("OneSecondTimer", 1000, false, "i", playerid);
public OneSecondTimer( playerid)//
{
if(IsPlayerConnected(playerid))
{
if(Variable[playerid]>0)
{
Variable[playerid]--;
}
}
}
Re: Timer Problem -
Admigo - 31.01.2013
Is it possible to make an one second timer with GetTickCount()?