5 points per minute
#1

I can I make it that a person earns 5 points for every minute they are on the server??
thanks!
Reply
#2

Sure you can.
You'll need this and this.
Reply
#3

OnPlayerConnect

SetTimer("GivePoints",60000,true);
pawn Код:
public GivePoints()
{
     for(new i; i=0; i <MAX_PLAYERS; i++)
    {
          SetPlayerScore(i,+5);
    }
    return 1;
}
Reply
#4

Under OnGameModeInit (if it is a gamemode) make a timer that gets called every minute. Like
pawn Код:
new PlayerPoint[MAX_PLAYERS];
public OnGameModeInit()
{
    SetTimer("Add5Points", 5000, true);
    return 1;
}
forward Add5Points();
public Add5Points()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayerPoint[i] += 5;
        }
    }
    return 1;
}
Sorry if there's some incorrect code there, I just fast made it.

If you want to set their score. Minimal changes though.
pawn Код:
public OnGameModeInit()
{
    SetTimer("Add5Points", 5000, true);
    return 1;
}
forward Add5Points();
public Add5Points()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetPlayerScore(i, GetPlayerScore(i)+5);
        }
    }
    return 1;
}
Reply
#5

Why new functions like PlayerPoint lol, you can use SetPlayerScore
Reply
#6

Quote:
Originally Posted by alpha500delta
Посмотреть сообщение
Why new functions like PlayerPoint lol, you can use SetPlayerScore
That's correct, but as he said "points" I didn't think of "score" so I just made the PlayerPoint.
Reply
#7

Quote:
Originally Posted by [FU]Victious
Посмотреть сообщение
OnPlayerConnect

SetTimer("GivePoints",60000,true);
pawn Код:
public GivePoints()
{
     for(new i; i=0; i <MAX_PLAYERS; i++)
    {
          SetPlayerScore(i,+5);
    }
    return 1;
}
For every player online wouldn't that give them 5 score? so 2 players = 10 score.

pawn Код:
//under OnPlayerconnect
timerDaily[playerid] = SetTimerEx ("dailyScore", 60000, true, "d", playerid);

//under OnPlayerDisconnect
KillTimer(timerDaily[playerid]);
//bottom of the script
forward dailyScore (playerid);
public dailyScore (playerid)
{
    SetPlayerScore (playerid, GetPlayerScore(playerid) + 5);
    return 1;
}
worked like a charm for me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)