Job Timer
#3

You've already put WaitTimeForCMD but you didn't know how to use it, you can use gettime() function to do that like how I did in below codes.
PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf>
#define COLOR_ORANGE 0xFFA54F
#define COLOR_RED 0xCD3333
new Checkpoint[MAX_PLAYERS],
    
WaitTimeForCMD[MAX_PLAYERS];
new 
bool:ResJob[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
Checkpoint[playerid] = 0;
    
WaitTimeForCMD[playerid] = 0;
    
ResJob[playerid] = false;
    return 
1;
}
CMD:restaurantjob(playeridparams[])
{
      new 
Vehicle GetPlayerVehicleID(playerid);
      if(
GetVehicleModel(Vehicle) == 496)
      {
        if((
gettime()-WaitTimeForCMD[playerid]) > 60)
        {
              
SendClientMessage(playeridCOLOR_ORANGE"Минете през всички маркери.");
              
SetPlayerRaceCheckpoint(playerid0800.2274,-1629.5649,13.1646877.6833,-1570.6782,13.24343);
              
ResJob[playerid] = true;
              
Checkpoint[playerid] = 0;
              
WaitTimeForCMD[playerid] = gettime();
        }
        else
        {
            new 
str[128];
            
format(strsizeof str,"ERROR: You need to wait %d seconds before using this command again",(WaitTimeForCMD[playerid]+60) - gettime());
            
SendClientMessage(playerid, -1str);
        }
      }
      else
      {
          
SendClientMessage(playeridCOLOR_RED"Ти не си в колата за доставки!");
    }
      return 
1;
}
public 
OnPlayerEnterRaceCheckpoint(playerid)
{
    if(
ResJob[playerid] == true)
    {
        
DisablePlayerRaceCheckpoint(playerid);
        switch(
Checkpoint[playerid])
        {
            case 
0:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0877.6833,-1570.6782,13.2434964.7712,-1612.6074,14.9410);
            }
            case 
1:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0964.7712,-1612.6074,14.9410866.4911,-1798.7052,13.81463);
            }
            case 
2:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0866.4911,-1798.7052,13.8146791.4638,-1753.5942,13.45133);
            }
            case 
3:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0791.4638,-1753.5942,13.4513768.0756,-1655.8152,5.60943);
            }
            case 
4:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0768.0756,-1655.8152,5.6094648.8566,-1536.4940,14.93303);
            }
            case 
5:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0648.8566,-1536.4940,14.9330783.0842,-1464.3086,13.54693);
            }
            case 
6:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0783.0842,-1464.3086,13.5469901.7432,-1514.8398,14.36953);
            }
            case 
7:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0901.7432,-1514.8398,14.3695789.2873,-1597.8925,13.16463);
            }
            case 
8:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0789.2873,-1597.8925,13.1646788.2137,-1634.3579,13.16463);
            }
            case 
9:
            {
                
Checkpoint[playerid] ++;
                
SetPlayerRaceCheckpoint(playerid0788.2137,-1634.3579,13.1646788.2137,-1634.3579,13.16463);
            }
            case 
10:
            {
                
SendClientMessage(playeridCOLOR_ORANGE"Ти мина през всияки маркери и получи 7923$");
                   
SendClientMessage(playeridCOLOR_ORANGE"Можеш да започнеш отново работа след 15 минути.");
                
GivePlayerMoney(playerid7923);
                
ResJob[playerid] = false;
                
Checkpoint[playerid] = 0;
                
RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 
1;

Reply


Messages In This Thread
Job Timer - by humalunga - 25.09.2016, 14:58
Re: Job Timer - by humalunga - 25.09.2016, 19:09
Re: Job Timer - by jlalt - 25.09.2016, 19:14
Re: Job Timer - by humalunga - 25.09.2016, 20:10
Re: Job Timer - by humalunga - 27.09.2016, 11:19
Re: Job Timer - by humalunga - 30.09.2016, 17:10

Forum Jump:


Users browsing this thread: 2 Guest(s)