Auto Updater..
#1

Hello, I have attempted to make an auto updater for the players scores and to set the world time, my code just doesn't seem to work, it prints out the time like I have scripted it to:

pawn Код:
forward secondupdater(playerid);
public secondupdater(playerid)
{
    new hour, minute, second;
    gettime(hour, minute, second);
    if(minute == 60 && second == 0)
    {
        hour++;
        SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
        SetWorldTime(hour);
        if(hour == 24)
        {
            hour = 0;
        }
    }
    printf("Hour: %d, Minutes: %d, Seconds: %d.", hour, minute, second);
    if(minute == 60 && second == 0)
    {
        printf("New Hour: %d.", hour);
    }
    return 1;
}
I just don't understand it, should it be a SetTimer or SetTimerEx also?
Reply
#2

Maybe you should run a loop in there and just have it as a standalone function which you should then run on SetTimerEx..? Give it a whirl.
Reply
#3

Doesn't seem to work.
Reply
#4

Hm. Show me all the code ... like how are you implementing the function..?
Reply
#5

pawn Код:
forward secondupdater();
public secondupdater()
{
    new hour, minute, second;
    gettime(hour, minute, second);
    for(new i; i < MAX_PLAYERS; i ++)
    {
        if(minute == 60 && second == 0)
        {
            hour++;
            SetPlayerScore(i, GetPlayerScore(i) + 1);
            SetWorldTime(hour);
            if(hour == 24)
            {
                hour = 0;
            }
        }
    }
    printf("Hour: %d, Minutes: %d, Seconds: %d.", hour, minute, second);
    if(minute == 60 && second == 0)
    {
        printf("New Hour: %d.", hour);
    }
    return 1;
}
Reply
#6

I have no idea.. If that doesn't work then I don't know what's going on... try running it on SetTimer now you have a loop.
Reply
#7

I'm 99% sure, that there is no 60'th minute.
Do it my way:
pawn Код:
new CurrentHour;
// on top

forward secondtimer();
public secondtimer()
{
    new hour,minute,second;
    gettime(hour,minute,second);
    if(hour != CurrentHour)
    {
       CurrentHour=hour;
       for(new playerid;playerid<MAX_PLAYERS;playerid++) if(IsPlayerConnected(playerid) SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
       SetWorldTime(hour);
    }

}
// And it should be done like this OnGameModeInit.
SetTimer("secondtimer",1000,false);
Reply
#8

Shit... the fuck. This is true..........
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)