Timer Problem
#1

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
Reply
#2

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
Reply
#3

PHP код:
forward OneSecondTimer(playerid);
SetTimerEx("OneSecondTimer"1000false"i"playerid);
public 
OneSecondTimerplayerid)//
{
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
                    if(
Variable[i]>0)
                        {
                            
Variable[i]--;
                        }
                }
         }

Reply
#4

Delete
Reply
#5

Quote:
Originally Posted by yusei
Посмотреть сообщение
PHP код:
forward OneSecondTimer(playerid);
SetTimerEx("OneSecondTimer"1000false"i"playerid);
public 
OneSecondTimerplayerid)//
{
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        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"1000false"i"playerid);
public 
OneSecondTimerplayerid)//
{
if(
IsPlayerConnected(playerid))
{
if(
Variable[playerid]>0)
{
Variable[playerid]--;
}
}

Reply
#6

Is it possible to make an one second timer with GetTickCount()?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)