DestroyVehicle; Problem
#1

Right basically after fixing my computer (at last) i started to help a friend script since I lost my gm.

I made a vehicle spawning system which works fine, however wen I wish to delete the vehicle I have spawned the command wont work.

The script compiles fine, I can spawn but not delete the vehicle. I have tried several ways, being in the car and using the vehicle ID to delete. But it isnt working for some reason. Reckon you could help?

Below is the code:

pawn Код:
[Edit: command removed due to it not needed]


CMD:delveh(playerid, params[])
{
new vehid;
if(sscanf(params,"i", vehid)) return SendClientMessage(playerid, RED,"Correct usage: /DelVeh [VehicleID]");
DestroyVehicle(vehid);
SendClientMessage(playerid, YELLOW, "Vehicle Succesfully deleted.");
return 1;
}
Reply
#2

pawn Код:
CMD:delveh(playerid, params[])
{
new vehid;
if(sscanf(params,"i", vehid)) return SendClientMessage(playerid, RED,"Correct usage: /DelVeh [VehicleID]");
DestroyVehicle(vehid);
SendClientMessage(playerid, YELLOW, "Vehicle Succesfully deleted.");
return 1;
}
to

pawn Код:
CMD:delveh(playerid, params[])
{
new vehid = GetPlayerVehicleID(playerid);
if(sscanf(params,"i", vehid)) return SendClientMessage(playerid, RED,"Correct usage: /DelVeh [VehicleID]");
DestroyVehicle(vehid);
SendClientMessage(playerid, YELLOW, "Vehicle Succesfully deleted.");
return 1;
}
Reply
#3

Ah seems so simple now ><
Strange how it foiled both me and my mate.

Thanks a bunch man.
Reply
#4

Quote:
Originally Posted by L.Hudson
Посмотреть сообщение
pawn Код:
CMD:delveh(playerid, params[])
{
new vehid;
if(sscanf(params,"i", vehid)) return SendClientMessage(playerid, RED,"Correct usage: /DelVeh [VehicleID]");
DestroyVehicle(vehid);
SendClientMessage(playerid, YELLOW, "Vehicle Succesfully deleted.");
return 1;
}
to

pawn Код:
CMD:delveh(playerid, params[])
{
new vehid = GetPlayerVehicleID(playerid);
if(sscanf(params,"i", vehid)) return SendClientMessage(playerid, RED,"Correct usage: /DelVeh [VehicleID]");
DestroyVehicle(vehid);
SendClientMessage(playerid, YELLOW, "Vehicle Succesfully deleted.");
return 1;
}
hmmm that code will mess up - theres basically no difference between that and what you had before because if sscanf is successful it will rewrite the vehid value before it gets used.

The code above assumes ur sitting in the vehicle you want deleted but didnt go far enough and will bug out just the same as what you had before.

this is the correct version if you want do delete the vehicle you are sitting in:
pawn Код:
CMD:delveh(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED,"You are not in a vehicle and cannot use this command");
    DestroyVehicle(GetPlayerVehicleID(playerid));
    return SendClientMessage(playerid, YELLOW, "Vehicle Succesfully deleted.");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)