Personal vehicle
#1

Hey, i am working on this carstore but whenever 2 players have bought a car the old car vanishes.
This is at the top of the script
pawn Код:
new PVeh[ MAX_PLAYERS ];
further down in the public carspawner i made
pawn Код:
DestroyVehicle(PVeh[playerid]);
    PVeh[playerid] = CreateVehicle(model, VehicleX, VehicleY, VehicleZ, VehicleAngle, -1, -1, -1);
So what am i doing wrong?
What i want here is if the player has a car already, that one is supposed to be replaced.
not others' cars.
Reply
#2

I would add something like..

pawn Код:
if(PVeh[playerid] != 0) DestroyVehicle(PVeh[playerid]);
So you're not destroying vehicle ID 0. There could also be another problem with this if the player's vehicle is actually ID 0, so I would suggest making PVeh's value to -1 when they connect, and after all info saves, on disconnect.
Reply
#3

Please tell me how that line works
Reply
#4

If player's vehicle is not 0, then destroy the vehicle. But as I stated above, you need to make sure if they do not own a vehicle that PVeh is set to -1 so ID 0 isn't destroyed.
Reply
#5

I did add this one on disconnect and connect
pawn Код:
PVeh[playerid] = -1;
and also this one when spawning a vehicle
pawn Код:
if(PVeh[playerid] != 0) DestroyVehicle(PVeh[playerid]);
The issue is still there. When someone else spawns a vehicle mine dissapears, and the other way around.
Reply
#6

If it's -1, then change that line to:

pawn Код:
if(PVeh[playerid] != -1) DestroyVehicle(PVeh[playerid]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)