#1

Hello , how do i give a player +5 score every minute ?

Thanks .

is this code good ?

Код:
new seconds[MAX_PLAYERS];
public OnGameModeInit()
{
    SetTimer("scoretimer", 1000, true);
    return 1;
}
public OnPlayerConnect(playerid)
{
    seconds[playerid] = 0;
    return 1;
}


forward scoretimer();
public scoretimer()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        seconds[i] ++;
        if(seconds[i] == 60) 
        {
            SetPlayerScore(i, GetPlayerScore(i) + 5);
            seconds[i] = 0;
        }
    }
    return 1;
}
Reply
#2

PHP код:
new ptimer[max_players];
OnPlayerConnect(playerid)
ptimer[playerid] = SetTimerEx("MyFunc"60000true"i"playerid), return 1;
OnPlayerDisconnect(playerid)
KillTimer(ptimer[playerid]),
return ;
forward MyFunc(playerid);
public 
MyFunc(playerid)
{
if(
IsPlayerConnected(playerid))
SetPlayerScore(playeridGetPlayerScore(playerid)+5);

Basic thing, just to give you a idea of how to do it.
Reply
#3

Just set the timer's interval to be 60000 milliseconds which is 1 minute and that's it. For player-loops, use GetPlayerPoolSize.
Reply
#4

Okay guys thanks gonna rep both of you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)