Help timers
#1

Why i Have problem with timers ? I Used y_timers in my filterscript,, The problem is : I Make 300000 for 1 coins // 300second.. But The Times is not work ,, Sometimes the timers Not 300 second but give players for 1 coins in 14 second..etc !! are you have SOME IDEA ? for this bug ?
Reply
#2

Show us the code.
Reply
#3

Quote:

timer CoinHour[300000](playerid)
{
SendClientMessage(playerid, COLOR_GREEN, "LUCKY DRAW: You've got 1 Coins that can be used in /luckydraw");
DataPlayer[playerid][pcoin] += 1;
new INI:File = INI_Open(LDPath(playerid));
INI_SetTag(File,"DataPlayer");
INI_WriteInt(File,"Coins",DataPlayer[playerid][pcoin]);
INI_Close(File);
}

I Know the problem From Where ? But Maybe from here or My include
Reply
#4

Can you show me the code where you call the timer?
Reply
#5

Quote:

public OnPlayerConnect(playerid)
{
DrawOn[playerid] = 0;
repeat CoinHour(playerid);
if(fexist(LDPath(playerid)))
{
INI_ParseFile(LDPath(playerid), "LoadPlayer_%s", .bExtra = true, .extra = playerid);
}
return 1;
}

Here
Reply
#6

PHP код:
public OnPlayerConnect(playerid)
{
     
DrawOn[playerid] = 0;
    
repeat CoinHour(playerid);
    if(
fexist(LDPath(playerid)))
    {
        
INI_ParseFile(LDPath(playerid), "LoadPlayer_%s", .bExtra true, .extra playerid);
    }
    return 
1;

Here ! The bug is : Player get Coins not On 300 second But Not Certainly
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)