29.01.2013, 12:42
This happens a lot on my server, basically you need to do checks under OnPlayerDisconnect and under the command /v. For example:
Same on Onplayerdisconnect...
Also make sure you reset the variable to an INVALID_VEHICLE_ID OnPlayerConnect.
pawn Код:
CMD:v(playerid, params[])
{
//Whatever you have here
if(PlayerCar[playerid] != -1) //If they have a car spawned
{
DestroyVehicle(PlayerCar[playerid]); //Destroy the car they have spawned
PlayerCar[playerid] = -1; //Reset for debugging purposes
}
PlayerCar[playerid] = CreateVehicle(...
//Code continues...
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
if(PlayerCar[playerid] != -1)
{
DestroyVehicle(PlayerCar[playerid]);
PlayerCar[playerid] = -1;
}
return 1;
}