05.08.2016, 09:12
I've made a vehicle spawning command however, once the vehicle explodes or is destroyed it respawns back to the place where the user spawned the vehicle. Is there any way that once a player has spawned a vehicle that it doesn't respawn after it's destroyed? Here is my code.
PHP код:
CMD:vehicle(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new msg[128], string[200], vehiclename[30], Float:a;
new Float:x, Float:y, Float:z;
if(sscanf(params,"s[30]",vehiclename)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /vehicle [Name]");
new vehicle = GetVehicleModelIDFromName(vehiclename);
if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, COLOR_RED, "Error: Invalid Vehicle Model");
GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x,y,z);
if(IsPlayerInAnyVehicle(playerid) == 1)
{
GetXYInFrontOfPlayer(playerid,x,y,8);
}
else
{
GetXYInFrontOfPlayer(playerid,x,y,5);
}
new PlayersVehicle = CreateVehicle(vehicle, x, y, z+2, a+90, -1, -1, -1);
LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));
format(string,sizeof(string), "You have spawned a %s", VehicleNames[vehicle - 400]);
SendClientMessage(playerid, COLOR_BLUE, string);
format(msg,sizeof(msg), "[Admin Log]: %s has used the command /vehicle. Spawning a %s", GetName(playerid), VehicleNames[vehicle - 400]);
ABroadCast(COLOR_ADMIN, msg, 1);
}
else
{
return 0;
}
return 1;
}