Connected Time
#10

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
The above code should work fine (not tested). As it is not saving player Time, when the player player connects his time will be set according to his id.
Example: Player ID 1 left and another player joined with ID 1 his time will be same as previous player.
Reply


Messages In This Thread
Connected Time - by TheWay - 27.03.2015, 14:37
Re: Connected Time - by De4dpOol - 27.03.2015, 14:46
Re: Connected Time - by CalvinC - 27.03.2015, 14:47
Re: Connected Time - by TheWay - 27.03.2015, 14:48
Re: Connected Time - by CalvinC - 27.03.2015, 14:57
Re: Connected Time - by TheWay - 27.03.2015, 15:00
Re: Connected Time - by CalvinC - 27.03.2015, 15:07
Re: Connected Time - by PowerPC603 - 27.03.2015, 17:37
Re: Connected Time - by TheWay - 28.03.2015, 06:28
Re: Connected Time - by De4dpOol - 28.03.2015, 07:57

Forum Jump:


Users browsing this thread: 4 Guest(s)