Destory vehicle problem -
Duck4coder - 04.01.2014
Hello, I've been making a command to destroy the vehicle that the player is in for
my server, but I keep getting the problem where the command doesn't actually work, and sends the
"You need to be in a vehicle" text and then unknown command text, So i changed it to the new
command below and i keep getting the error: error 017: undefined symbol "GetPlayerVehicledID"
Код:
CMD:dveh(playerid, params[])
{
new
vehicleid = GetPlayerVehicledID(playerid),
string[128];
if(IsPlayerInVehicle(playerid, vehicleid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
DestroyVehicle(vehicleid);
format(string, sizeof(string), "The %s has been destroyed.", VehicleName(vehicleid));
SendClientMessage(playerid, YELLOW, string);
}
}
else(SendClientMessage(playerid, RED, "You need to be in a vehicle to destroy it."));
}
Re: Destory vehicle problem -
Sawalha - 04.01.2014
Remove the "d" from the GetPlayerVehicledID, correct is GetPlayerVehicleID
Re: Destory vehicle problem -
Duck4coder - 04.01.2014
Well that fixed the deletion problem, but whenever I do the command, it still comes up with the unknown command error :/
Re: Destory vehicle problem -
Sawalha - 04.01.2014
Under "else return etc.."
do return 1;
Sorry for lately help
Re: Destory vehicle problem -
Stefand - 04.01.2014
You always have to return a command to something, else you will keep getting that unknown command thing and it wont work.
pawn Код:
CMD:dveh(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid), string[128];
if(IsPlayerInVehicle(playerid, vehicleid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
DestroyVehicle(vehicleid);
format(string, sizeof(string), "The %s has been destroyed.", VehicleName(vehicleid));
SendClientMessage(playerid, YELLOW, string);
}
}else{SendClientMessage(playerid, RED, "You need to be in a vehicle to destroy it.");}
return 1;
}
Fixed your issue here I think.
Re: Destory vehicle problem -
PowerPC603 - 04.01.2014
You're also doing too many checks.
First you use GetVehicleID, then you re-check if the same player is inside the same vehicle.
pawn Код:
CMD:dveh(playerid, params[])
{
// If the player isn't the driver of a vehicle, exit the command
if(GetPlayerVehicleSeat(playerid) != 0) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You need to be in a vehicle to destroy it.");
new vehicleid = GetPlayerVehicleID(playerid), string[128];
DestroyVehicle(vehicleid);
format(string, sizeof(string), "The %s has been destroyed.", VehicleName(vehicleid));
SendClientMessage(playerid, YELLOW, string);
return 1;
}
Re: Destory vehicle problem -
Konstantinos - 04.01.2014
The above will fail too because you destroy the vehicle and then you call VehicleName. The modelid of the vehicleid will be 0 so array index out of bounds for accessing negative element at -400.
Array index out of bounds may cause the unknown command too, if it is still displayed after returning true at the end of the command so the solution will be to check if the model is valid before getting the name.
Re: Destory vehicle problem -
Stefand - 05.01.2014
He already stored the id, It will work:
new vehicleid = GetPlayerVehicleID(playerid);