[HOW] Delete Vehicle -
RollTi - 19.04.2012
How to delete the last spawned vehicle from /v?
if there is no more last spawned vehicle the /deletev will stop
How to do it?
pawn Код:
CMD:v(playerid, params[])
{
new vid = GetPlayerVehicleID(playerid);
new veh = GetVehicleModel(vid);
new string[128], Float:x, Float:y, Float:z, Float:ang, vehicle;
if(pInfo[playerid][Admin] < 1) return SendClientMessage(playerid, COLOR_GREY, " You are not organize to use this command! ");
if(sscanf(params, "i", veh)) return SendClientMessage(playerid, COLOR_GREY, "SYNTAX: /v [vehicleid]");
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, ang);
if(veh > 400 || veh < 611) return SendClientMessage(playerid, COLOR_GREY, " Invalid VehicleID ");
vehicle = CreateVehicle(veh, x, y, z, 0, -1, -1, 0);
PutPlayerInVehicle(playerid, vehicle, 0);
format(string, sizeof(string), "You've spawned vehicle id '%i'", veh);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
EDIT:
i have also problem with /v why when ever i type valid vehicle id it gives me
" Invalid VehicleID "
Re: [HOW] Delete Vehicle -
Jonny5 - 19.04.2012
EDIT:
youll need to store the last created vehicle id,
and then use
https://sampwiki.blast.hk/wiki/DestroyVehicle to delete it at the top of your command.
Re: [HOW] Delete Vehicle -
ViniBorn - 19.04.2012
Maybe it can help you
pawn Код:
//Top
new LastCarCreated = -1;
// /v
LastCarCreated = CreateVehicle(veh, x, y, z, 0, -1, -1, 0);
pawn Код:
CMD:v(playerid, params[])
{
if(LastCarCreated == -1)
SendClientMessage(playerid, COLOR_YELLOW, "No car created");
DestroyVehicle(LastCarCreated);
SendClientMessage(playerid, COLOR_YELLOW, "You deleted the last created car.");
LastCarCreated = -1;
return true;
}
Re: [HOW] Delete Vehicle -
RollTi - 19.04.2012
Quote:
Originally Posted by Viniborn
Maybe it can help you
pawn Код:
//Top new LastCarCreated = -1;
// /v LastCarCreated = CreateVehicle(veh, x, y, z, 0, -1, -1, 0);
pawn Код:
CMD:v(playerid, params[]) { if(LastCarCreated == -1) SendClientMessage(playerid, COLOR_YELLOW, "No car created");
DestroyVehicle(LastCarCreated); SendClientMessage(playerid, COLOR_YELLOW, "You deleted the last created car."); LastCarCreated = -1; return true; }
|
Thanks how about the
" Invalid VehicleID " issue?
i try what Jonny5 says it didn't work but when i try the valid vehicle id it spawns normal
except when i type /v 0 it says
"You've spawned vehicle id '0'"
Re: [HOW] Delete Vehicle -
ViniBorn - 19.04.2012
Replace for this
pawn Код:
if(veh < 400 || veh > 611) return SendClientMessage(playerid, COLOR_GREY, " Invalid VehicleID ");
pawn Код:
format(string, sizeof(string), "You've spawned vehicle id '%i'", vehicleid);
Re: [HOW] Delete Vehicle -
RollTi - 19.04.2012
Thanks Viniborn and Jonny5 for help
i cannot believe to say this:
Rep both of you!