Job Timer
#1

Hi. I need help with adding timers to my job, because everyone can farm it.
I am new to pawno so that's why I am asking for help.
Here's the code for my job:
Код:
#include <a_samp>
#include <zcmd>
#include <sscanf>

#define COLOR_ORANGE 0xFFA54F
#define COLOR_RED 0xCD3333
new Checkpoint[MAX_PLAYERS];
new bool:ResJob[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
	Checkpoint[playerid] = 0;
	ResJob[playerid] = false;
	return 1;
}

CMD:restaurantjob(playerid, params[])
{
  	new Vehicle = GetPlayerVehicleID(playerid);
  	if(GetVehicleModel(Vehicle) == 496)
  	{
        if((GetTickCount()-WaitTimeForCMD[playerid])>900000)
  		SendClientMessage(playerid, COLOR_ORANGE, "Минете през всички маркери.");
  		SetPlayerRaceCheckpoint(playerid, 0, 800.2274,-1629.5649,13.1646, 877.6833,-1570.6782,13.2434, 3);
  		ResJob[playerid] = true;
  		Checkpoint[playerid] = 0;
  	}
  	else
  	{
  		SendClientMessage(playerid, COLOR_RED, "Ти не си в колата за доставки!");
	}
  	return 1;
}


public OnPlayerEnterRaceCheckpoint(playerid)
{
	if(ResJob[playerid] == true)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		switch(Checkpoint[playerid])
		{
			case 0:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 877.6833,-1570.6782,13.2434, 964.7712,-1612.6074,14.9410, 3 );
			}
			case 1:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 964.7712,-1612.6074,14.9410, 866.4911,-1798.7052,13.8146, 3);
			}
			case 2:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 866.4911,-1798.7052,13.8146, 791.4638,-1753.5942,13.4513, 3);
			}
			case 3:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 791.4638,-1753.5942,13.4513, 768.0756,-1655.8152,5.6094, 3);
			}
			case 4:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 768.0756,-1655.8152,5.6094, 648.8566,-1536.4940,14.9330, 3);
			}
			case 5:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 648.8566,-1536.4940,14.9330, 783.0842,-1464.3086,13.5469, 3);
			}
			case 6:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 783.0842,-1464.3086,13.5469, 901.7432,-1514.8398,14.3695, 3);
			}
			case 7:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 901.7432,-1514.8398,14.3695, 789.2873,-1597.8925,13.1646, 3);
			}
			case 8:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 789.2873,-1597.8925,13.1646, 788.2137,-1634.3579,13.1646, 3);
			}
			case 9:
			{
				Checkpoint[playerid] ++;
				SetPlayerRaceCheckpoint(playerid, 0, 788.2137,-1634.3579,13.1646, 788.2137,-1634.3579,13.1646, 3);
			}
			case 10:
			{
			
				SendClientMessage(playerid, COLOR_ORANGE, "Ти мина през всияки маркери и получи 7923$");
   				SendClientMessage(playerid, COLOR_ORANGE, "Можеш да започнеш отново работа след 15 минути.");
				GivePlayerMoney(playerid, 7923);
				ResJob[playerid] = false;
				Checkpoint[playerid] = 0;
				RemovePlayerFromVehicle(playerid);
			}
		}
	}
	return 1;
}
Reply
#2

I need help ! +rep for the person who help me first.
Reply
#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
#4

It doesn't work
Reply
#5

Help, PLEASE!
Reply
#6

HEEEEELP...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)