28.03.2015, 07:57
pawn Код:
//Out side all the call backs//
new PlayedTimer[MAX_PLAYERS];//Creating a variable, it is used to kill the timer.
new Time[MAX_PLAYERS] = 0;
forward IncreaseTime(playerid);//forwarding IncreaseTime(playerid).
forward Payday();
public IncreaseTime(playerid)
{
Time[playerid]++;//Increasing Time by 1 every minute.
}
public Payday()
{
for(new i = 0, i < MAX_PLAYERS; i++)
{
GivePlayerMoney(i, Time[i]/100);//if he played for 20 minute. He will get 0.20$,
Time[i] = 0;
}
}
//under OnGameModeInit//
SetTimer("Payday", 1000*60*60, 1); //Setting a timer of 1 hour
//Under OnPlayerConnect and your /back cmd (you have it right?)//
PlayerTimer[playerid] = SetTimerEx("IncreaseTime", 1000 * 60, 1, "i", playerid);//Making a one minute timer.
//In /sleep and Under OnPlayerDisconnect//
KillTimer(PlayerTimer[playerid]);//Killing the Timer
Example: Player ID 1 left and another player joined with ID 1 his time will be same as previous player.