Help timers
#7

I personally would put this in a global task rather than an individual timer. The code underneath is using foreach:

PHP код:
public OnGameModeInit() {
    
HourTimer();
    return 
1;
}
task HourTimer[3600000]() {
    foreach(new 
Player) {
        
// Coin draw
        
SendClientMessage(iCOLOR_GREEN"LUCKY DRAW: You've got 1 coin that can be used in /luckydraw!");
        
DataPlayer[i][pcoin] ++;
        new 
INI:File INI_Open(LDPath(i));
        
INI_SetTag(File"DataPlayer");
        
INI_WriteInt(File"Coins"DataPlayer[i][pcoin]);
        
INI_Close(File);
    }

Alternatively (and I actually recommend it), you can check whether the player is logged in or not. If your script makes use of this, of course.

PHP код:
task HourTimer[3600000]() {
    foreach(new 
Player) {
        if(!
DataPlayer[i][ploggedin]) {
            continue;
        }
        
        
// Coin draw
        
SendClientMessage(iCOLOR_GREEN"LUCKY DRAW: You've got 1 coin that can be used in /luckydraw!");
        
DataPlayer[i][pcoin] ++;
        new 
INI:File INI_Open(LDPath(i));
        
INI_SetTag(File"DataPlayer");
        
INI_WriteInt(File"Coins"DataPlayer[i][pcoin]);
        
INI_Close(File);
    }

Reply


Messages In This Thread
Help timers - by Amunra - 28.12.2015, 12:32
Re: Help timers - by AndySedeyn - 28.12.2015, 12:32
Re: Help timers - by Amunra - 28.12.2015, 12:37
Re: Help timers - by AndySedeyn - 28.12.2015, 12:42
Re: Help timers - by Amunra - 28.12.2015, 12:43
Re: Help timers - by Amunra - 28.12.2015, 12:45
Re: Help timers - by AndySedeyn - 28.12.2015, 12:55

Forum Jump:


Users browsing this thread: 1 Guest(s)