if(ispr[GetPlayerVehicleID(playerid)] == 1)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(PlayerInfo[playerid][Pid] == CarInfo[CarID][Carid] || PlayerInfo[playerid][Vehkey] == CarInfo[CarID][Carid] || PlayerInfo[playerid][Vehkey2] == CarInfo[CarID][Carid] || PlayerInfo[playerid][Vehkey3] == CarInfo[CarID][Carid])
{
SendClientMessage(playerid, COLOR_ORANGE, "Welcome back to your vehicle!");
}
else
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, 0x999999AA, "You don't have the key of this vehicle.");
}
}
CMD:savemycar(playerid,params[])
{
if(PlayerInfo[playerid][Vehicle] != GetPlayerVehicleID(playerid)) return SendClientMessage(playerid,-1,EMBED_RED"[ERROR]: "EMBED_WHITE"You need to be in your vehicle.");
new Float:cp[3];
GetPlayerPos(playerid,cp[0],cp[1],cp[2]);
PlayerInfo[playerid][CarX] = cp[0];
PlayerInfo[playerid][CarY] = cp[1];
PlayerInfo[playerid][CarZ] = cp[2];
SendClientMessage(playerid,COLOR_GRAY,">> Vehicle Saved");
return 1;
}
Heres my CMD:
pawn Код:
|
CMD:buycar(playerid,params[])
{
if(CARSPAWNED[playerid] == 1) return SendClientMessage(playerid,-1,EMBED_RED"[ERROR]: You must have your car despawned before purchasing a new one!");
new car = GetPlayerVehicleID(playerid);
if(car == dealercar[0])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"hotring"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 494;
PlayerInfo[playerid][Money] -= 120000;
CreateVehicle(494,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[1])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"cheetah"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 415;
PlayerInfo[playerid][Money] -= 90000;
CreateVehicle(415,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[2])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"banshee"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 429;
PlayerInfo[playerid][Money] -= 100000;
CreateVehicle(429,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[3])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"bullet"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 541;
PlayerInfo[playerid][Money] -= 105000;
CreateVehicle(541,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[4])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"buffalo"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 402;
PlayerInfo[playerid][Money] -= 92000;
CreateVehicle(402,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[5])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"ZR-350"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 477;
PlayerInfo[playerid][Money] -= 85000;
CreateVehicle(477,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[6])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"windsor"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 555;
PlayerInfo[playerid][Money] -= 250000;
CreateVehicle(555,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[7])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"FCR-900"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 521;
PlayerInfo[playerid][Money] -= 75000;
CreateVehicle(521,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[8])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"NRG-900"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 522;
PlayerInfo[playerid][Money] -= 98000;
CreateVehicle(522,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[9])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"freeway"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 463;
PlayerInfo[playerid][Money] -= 75000;
CreateVehicle(463,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[10])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"wayfarer"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 486;
PlayerInfo[playerid][Money] -= 43000;
CreateVehicle(486,-1969.5432,258.5425,34.7968,358.2475,0,0,99999);
}
if(car == dealercar[11])
{
SendClientMessage(playerid,-1,EMBED_CYAN"[DEALERSHIP]: "EMBED_WHITE"You've purchased a "EMBED_GREEN"PCJ-600"EMBED_WHITE".");
PlayerInfo[playerid][Vehicle] = 461;
PlayerInfo[playerid][Money] -= 88000;
CreateVehicle(461,-1969.5432,258.5425,34.7968,358.2475,0,0,999999);
}
CARSPAWNED[playerid] = 1;
RemovePlayerFromVehicle(playerid);
SetTimer("Unfreeze",1500,0);
return 1;
}
CMD:savemycar(playerid,params[])
{
new Float:cp[4];
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][Vehicle])
{
GetPlayerPos(playerid,cp[0],cp[1],cp[2]);
PlayerInfo[playerid][CarX] = cp[0];
PlayerInfo[playerid][CarY] = cp[1];
PlayerInfo[playerid][CarZ] = cp[2];
PlayerInfo[playerid][CarA] = cp[3];
SendClientMessage(playerid,COLOR_GRAY,">> Vehicle Saved");
}
return 1;
}
else return SendClientMessage(playerid, *ur color here*, "You are not in your own vehicle!");
Heres my /savemycar cmd, but it doesn't work when I add if(GetPlayerVehicleID blah blah)
pawn Код:
|
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == PlayerInfo[playerid][Vehicle])
{
//code
}
Because PlayerInfo[playerid][Vehicle] stores the model of the vehicle and not the id.
pawn Код:
|
CMD:park(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][Vehkey] || GetPlayerVehicleID(playerid) == PlayerInfo[playerid][Vehkey2] || GetPlayerVehicleID(playerid) == PlayerInfo[playerid][Vehkey3]))
{
new videoid = GetPlayerVehicleID(playerid)
new Float:ux, Float:uy, Float:uz, Float:angle;
new string[128], vehicle[24];
GetVehicleName(videoid, vehicle, sizeof(vehicle));
GetPlayerFacingAngle(playerid, angle);
GetPlayerPos(playerid, ux, uy, uz);
format(file4, sizeof(file4), "realityrp/vehicles/%d.ini", videoid);
dini_FloatSet(file4, "vehx", ux);
dini_FloatSet(file4, "vehy", uy);
dini_FloatSet(file4, "vehz", uz);
dini_FloatSet(file4, "rot", angle);
format(string, sizeof(string), "You parked your %s here! ((It will respawn here on death))", vehicle);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}
else return SendClientMessage(playerid, COLOR_GREY, "This is not your vehicle!");
}
else return SendClientMessage(playerid, COLOR_GREY, "You are not in your vehicle!");
}