CMD:dropcar(playerid, params[])
{
if(GetPlayerVehicleID(playerid) != 0)
{
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, 2505.8506, -2629.0144, 13.2944, 5);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "Drop the car at the crane!");
dropping[playerid] = true;
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(dropping[playerid] == true)
{
DisablePlayerCheckpoint(playerid);
new string[128], price;
price = random (100);
format(string, sizeof(string), "*You've earned {FF6347}$%d{33CCFF} from dropping a car!", price);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid, price);
dropping[playerid] = false;
SetTimerEx("DropTimer", 20000, false, "i", playerid);
}
new dropping[MAX_PLAYERS]; //At the top of your script
public OnPlayerConnect(playerid)
{
dropping[playerid] = INVALID_VEHICLE_ID;
//Rest of code...
return 1;
}
CMD:dropcar(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
if(!vehicleid) return SendClientMessage(playerid, 0xFF0000FF, "You must be inside a vehicle to use this command.");
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, 2505.8506, -2629.0144, 13.2944, 5);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "Drop the car at the crane!");
dropping[playerid] = vehicleid;
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
new vid = GetPlayerVehicleID(playerid);
if(dropping[playerid] == vid && vid != INVALID_VEHICLE_ID)
{
DisablePlayerCheckpoint(playerid);
new string[60], price = random(100);
format(string, sizeof(string), "*You've earned {FF6347}$%d{33CCFF} from dropping a car!", price);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid, price);
dropping[playerid] = INVALID_VEHICLE_ID;
SetTimerEx("DropTimer", 20000, false, "i", playerid);
DestroyVehicle(vid);
}
//rest of code...
return 1;
}
pawn Код:
|
//Dropcar
new DropTime[MAX_PLAYERS];
new bool:dropping[MAX_PLAYERS];
//Public variables
DropTime[playerid] = 0;
CMD:dropcar(playerid, params[])
{
new string[128];
new vehicleid = GetPlayerVehicleID(playerid);
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!vehicleid) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You must be inside a vehicle to use this command.");
else if(dropping[playerid] == false)
{
format(string, sizeof(string), "You need to wait {FF6347}%d{33CCFF} more seconds before doing dropcar again.", DropTime[playerid]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
if(GetPlayerVehicleID(playerid) != 0)
{
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, 2505.8506, -2629.0144, 13.2944, 5);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "Deliver car to the Los Santos Docks!");
dropping[playerid] = true;
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(dropping[playerid] == true)
{
DisablePlayerCheckpoint(playerid);
new vehicleid = GetPlayerVehicleID(playerid);
new string[128], playerb, amount;
amount = random (100);
format(string, sizeof(string), "*You've earned {FF6347}$%d{33CCFF} from dropping a car!", amount);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
GiveDodMoney(playerb, amount);
SetVehicleToRespawn(vehicleid);
dropping[playerid] = true;
DropTime[playerid] = 60*20;
SetTimerEx("DropcarTime", 1000, false, "i", playerid);
}