25.09.2016, 19:14
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(playerid, params[])
{
new Vehicle = GetPlayerVehicleID(playerid);
if(GetVehicleModel(Vehicle) == 496)
{
if((gettime()-WaitTimeForCMD[playerid]) > 60)
{
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;
WaitTimeForCMD[playerid] = gettime();
}
else
{
new str[128];
format(str, sizeof str,"ERROR: You need to wait %d seconds before using this command again",(WaitTimeForCMD[playerid]+60) - gettime());
SendClientMessage(playerid, -1, str);
}
}
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;
}