Destroy Vehicle -lil problem
#1

hi
i have a car spawner in my server.
its basic

top of script
pawn Код:
new CarVar[MAX_PLAYERS];
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
Reply
#2

Try
if(carvar[playerid]) {
destroyvehicle(carvar[playerid]);
}
Reply
#3

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;
}
Reply
#4

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;
}
Reply
#5

i tried it in lots of ways...yours too
i think that destroyvehicle is bugged here -.-
Reply
#6

Maybe it conflicts with your car ownership...
Reply
#7

it doesnt.
:/
the var is different...
Reply
#8

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)