SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/07/2012, 07:24 PM   #1
RedFusion
Gangsta
 
RedFusion's Avatar
 
Join Date: Nov 2009
Location: Sweden
Posts: 921
Reputation: 330
Default Personal vehicle

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 Code:
new PVeh[ MAX_PLAYERS ];

further down in the public carspawner i made
pawn Code:
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.
__________________
Also known as fusez
RedFusion is offline   Reply With Quote
Old 09/07/2012, 07:39 PM   #2
coole210
Gangsta
 
Join Date: Jul 2008
Location: Canada
Posts: 995
Reputation: 84
Default Re: Personal vehicle

I would add something like..

pawn Code:
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.
coole210 is offline   Reply With Quote
Old 09/07/2012, 07:40 PM   #3
RedFusion
Gangsta
 
RedFusion's Avatar
 
Join Date: Nov 2009
Location: Sweden
Posts: 921
Reputation: 330
Default Re: Personal vehicle

Please tell me how that line works
__________________
Also known as fusez
RedFusion is offline   Reply With Quote
Old 09/07/2012, 07:57 PM   #4
coole210
Gangsta
 
Join Date: Jul 2008
Location: Canada
Posts: 995
Reputation: 84
Default Re: Personal vehicle

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.
coole210 is offline   Reply With Quote
Old 09/07/2012, 08:45 PM   #5
RedFusion
Gangsta
 
RedFusion's Avatar
 
Join Date: Nov 2009
Location: Sweden
Posts: 921
Reputation: 330
Default Re: Personal vehicle

I did add this one on disconnect and connect
pawn Code:
PVeh[playerid] = -1;
and also this one when spawning a vehicle
pawn Code:
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.
__________________
Also known as fusez
RedFusion is offline   Reply With Quote
Old 09/07/2012, 08:52 PM   #6
coole210
Gangsta
 
Join Date: Jul 2008
Location: Canada
Posts: 995
Reputation: 84
Default Re: Personal vehicle

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

pawn Code:
if(PVeh[playerid] != -1) DestroyVehicle(PVeh[playerid]);
coole210 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] RoavOwn - Simple Personal Vehicle Creator aRoach Includes 22 24/02/2012 02:35 PM
[Include] RoapVeh v1.0 - Personal Vehicle Creator aRoach Includes 13 21/09/2011 06:26 PM
Personal Vehicle. [Fixed, Mod delete please] DiddyBop Help Archive 5 16/12/2009 04:44 PM
Personal NRG Spawner: Change Vehicle? Oxside Help Archive 3 27/02/2009 12:26 PM


All times are GMT. The time now is 08:42 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.