Destroy Vehicle -lil problem -
FlawL3x - 14.02.2012
hi
i have a car spawner in my server.
its basic
top of script
the cmd
pawn Код:
CMD:v(playerid,params[])
{
//code to spawn vehicle by name, blabla
destroyvehicle(carvar[playerid]);
carvar[playerid] = createvehicle(...);
return 1;
}
it works but sometimes it delete the wrong car! (and the normal...so it delete 2 xD)
oh...
i have a private car system(car ownership)
the var is
pawn Код:
new PrivateCar[MAX_PLAYERS];
and when a player spawn a car with /V , SOMETIMES it delete a player private vehicle ...
i have no idea why... please help me xD
thanks
Re: Destroy Vehicle -lil problem -
Jefff - 14.02.2012
Try
if(carvar[playerid]) {
destroyvehicle(carvar[playerid]);
}
Re: Destroy Vehicle -lil problem -
FlawL3x - 14.02.2012
my destroyvehicle stock
pawn Код:
stock DestroyPVehicle(playerid, bool:destroycaralways = false)
{
if(carvar[playerid] == INVALID_VEHICLE_ID) return 0;
if(destroycaralways == true)
{
DestroyVehicle(carvar[playerid]);
}
else
{
if(!IsVehicleOccupied(carvar[playerid]))
{
DestroyVehicle(carvar[playerid]);
}
else return 0;
}
carvar[playerid] = INVALID_VEHICLE_ID;
return 1;
}
Re: Destroy Vehicle -lil problem -
Toreno - 14.02.2012
I don't know exactly whether this command will work well or not, yet check it.
pawn Код:
new VehicleSpawned[MAX_PLAYERS], IsSpawningFirstTime[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid) {
IsSpawningFirstTime[playerid] = 0;
return 1;
}
pawn Код:
CMD:v(playerid, params[]) {
new P[3];
GetPlayerPos(playerid, P[0], P[1], P[2]); // Use this positions to create the vehicle at your position.
if(!IsSpawningFirstTime[playerid]) {
VehicleSpawned[playerid] = CreateVehicle(...); // Continue this one as in your current command.
PutPlayerInVehicle(playerid, VehicleSpawned[playerid], 0); // Places the playerid in the vehicle he created.
IsSpawningFirstTime[playerid] = 1;
return 1;
}
DestroyVehicle(VehicleSpawned[playerid]);
VehicleSpawned[playerid] = CreateVehicle(...); // Continue this one as in your current command.
PutPlayerInVehicle(playerid, VehicleSpawned[playerid], 0); // Places the playerid in the vehicle he created.
return 1;
}
Re: Destroy Vehicle -lil problem -
FlawL3x - 14.02.2012
i tried it in lots of ways...yours too
i think that destroyvehicle is bugged here -.-
Re: Destroy Vehicle -lil problem -
Toreno - 14.02.2012
Maybe it conflicts with your car ownership...
Re: Destroy Vehicle -lil problem -
FlawL3x - 15.02.2012
it doesnt.
:/
the var is different...
Re: Destroy Vehicle -lil problem -
FlawL3x - 16.02.2012
BUMP