Personal vehicle - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Personal vehicle (
/showthread.php?tid=358169)
Personal vehicle -
RedFusion - 09.07.2012
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
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.
Re: Personal vehicle -
coole210 - 09.07.2012
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.
Re: Personal vehicle -
RedFusion - 09.07.2012
Please tell me how that line works
Re: Personal vehicle -
coole210 - 09.07.2012
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.
Re: Personal vehicle -
RedFusion - 09.07.2012
I did add this one on disconnect and connect
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.
Re: Personal vehicle -
coole210 - 09.07.2012
If it's -1, then change that line to:
pawn Код:
if(PVeh[playerid] != -1) DestroyVehicle(PVeh[playerid]);