Score Timer
#1

Hey guys,i want a script that give +1 score every 1 hour.
I watched the tutorials about the score timer like +1 score every 1 hour but i didn't understood, can someone do
it for me or explain it to me please?
Reply
#2

Here you go, have a look at this I've just created:
pawn Код:
new pTimeOnline[MAX_PLAYERS];

public OnGameModeInit()
{
    SetTimer("Timer_Second", 1000, true);
}

forward Timer_Second();
public Timer_Second()
{
    for(new i = 0; i != MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(pTimeOnline[i] == 3600)
            {
                pTimeOnline[i] = 0;
                SetPlayerScore(i, GetPlayerScore(i) + 1);
            } else
                pTimeOnline[i]++;
        }
    }
}

public OnPlayerConnect(playerid)
{
    pTimeOnline[playerid] = 0;
    return 1;
}
Reply
#3

Why not just:
pawn Код:
#define AddScore(%0) SetPlayerScore(%0, GetPlayerScore(%0) + 1)

public OnGameModeInit()
{
    SetTimer("Timer", 3_600_000, true); // 1 hour
}

forward Timer();
public Timer()
{
    for(new i = 0; i != MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        AddScore(i);
    }
}
Reply
#4

Because if someone joined a few seconds before the interval was about to tick 60 minutes, they would also get +1 score.
Reply
#5

Okay guys thanks, +Rep
Reply
#6

Quote:
Originally Posted by eblood1
Посмотреть сообщение
Because if someone joined a few seconds before the interval was about to tick 60 minutes, they would also get +1 score.
Yes, but that's not what he asked for.
He wanted a simple timer (1 hour) that adds the players 1 score, not by checking if they were online for 1 hour.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)