new HasAttemptedToLoadPackagesRecently[MAX_PLAYERS]; //Under Includes - Global
public OnGameModeInit() //Or FilterScriptInit() if you're using a FilterScript
{
SetTimer("Check", 1000, true);
return 1;
}
//LOADPACKAGES COMMAND HERE
{
//Add other code here
if(HasAttemptedToLoadPackagesRecently[playerid] > 0)
return SendClientMessage(playerid, 0xFF0000AA, "You must wait 30 minutes before attempting to load packages again.");
//When player loads the packages
HasAttemptedToLoadPackagesRecently[playerid] = 1800000;
}
forward Check();
public Check()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(HasAttemptedToLoadPackagesRecently[i] >= 1)
{
HasAttemptedToLoadPackagesRecently[i] --;
}
}
}
return ;
}
pawn Код:
|
new PackageLoading[MAX_PLAYERS]; // Beginning of mode with other 'new' variables
SetTimer("Check", 1000, true); // I added this under another SetTimer under OnGameModeInIt
CMD:loadpackages(playerid, params[]) // This is my /loadpackages command, everything is fine here.
{
new string[128], packages;
// L1: 0 | L2: 100 | L3: 300 | L4: 700 | L5: 1200
if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 100) packages = 5; //If under level 2
else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 300) packages = 10; //If under level 3
else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 700) packages = 15; //If under level 4
else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 1200) packages = 20; //If under level 5
else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] >= 1200) packages = 25; //If equals to or over level 5
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first before using this command.");
if(PlayerInfo[playerid][pJob] != JOB_TRUCKER && PlayerInfo[playerid][pVIPJob] != JOB_TRUCKER) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not a Trucker.");
if(!IsPlayerInAnyVehicle(playerid) || !IsTruckerVehicle(GetPlayerVehicleID(playerid)) || !IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not in a Trucker vehicle or you have no trailer attached.");
if(!IsPlayerInRangeOfPoint(playerid, 5, -1037.3890,-629.9038,32.0078)) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not near a packages pickup.");
if(PlayerInfo[playerid][pMoney] < packages*3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have any cash on you.");
if(PackageLoading[playerid] > 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "You need to wait for upto 30 minutes before loading more packages.");
return 1;
}
PlayerInfo[playerid][pTPackages] ++;
GiveZaiatMoney(playerid, -(packages*3));
PlayerInfo[playerid][pDeliverTruck] = GetPlayerVehicleID(playerid);
TruckPackages[GetPlayerVehicleID(playerid)] = playerid;
format(string, sizeof(string), "%s has loaded %d product packages from the pickup into the truck.", RPN(playerid), packages);
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
format(string, sizeof(string), "You have loaded {FF6347}%d product{33CCFF} packages for {FF6347}$%d{33CCFF}, deliver them to the drop off. (Checkpoint)", packages, packages*5);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
if(PlayerInfo[playerid][pTPackages] >= 1)
{
PackageLoading[playerid] = 60000;
}
SetPlayerCheckpoint(playerid, 2488.9246,-2080.2800,13.5469, 2);
return 1;
}
// Then..
forward Check(); // I have this under where it checks if pay check is done
public Check()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PackageLoading[i] >= 1)
{
PackageLoading[i] --;
}
}
}
return ;
}
public OnPlayerDisconnect(playerid)
{
//Save to user file (PackageLoading[playerid])
return 1;
}
public OnPlayerConnect(playerid)
{
PackageLoading[playerid] = //Get Players User file and read.
return 1;
}