SA-MP Forums Archive
Assign specific ID to a 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: Assign specific ID to a vehicle (/showthread.php?tid=448221)



Assign specific ID to a vehicle - Muhamed.pwn - 03.07.2013

Me again..

I made a COS based on the servers vehicleids, so I can't destroy a created car. If I do so the vehicle ids will mess up so I need delete all COS vehicles and start buying them again.

My question is: is there a way to assign a specific vehicleid to a vehicle ex. start COS car IDs from ID 1000 and so on so I can create cars for events, factions and so on. Currently, when a player disconnects I just set it's vehicle position to a random float somewhere in the water. Nowhere in my script I have "DestroyVehicle", I can't risk to mess up vehicleids because the COS file names are based on the vehicleids.

I've read this thread https://sampforum.blast.hk/showthread.php?tid=406551 and ****** said assign a variable to record the vehicle ID and work with it but would such an metod mess the IDs too !?


Re: Assign specific ID to a vehicle - iPoisonxL - 03.07.2013

Try something like
pawn Код:
new yourCarID = CreateVehicle(vehicle parameters);



Re: Assign specific ID to a vehicle - Muhamed.pwn - 03.07.2013

Quote:
Originally Posted by iPoisonxL
Посмотреть сообщение
Try something like
PHP код:
yourCarID CreateVehicle(vehicle parameters); 
You are right.
I tought to do it so, but what to store in the players variable to acces the vehicle then ex. for saving!?


Re: Assign specific ID to a vehicle - introzen - 03.07.2013

PlayerCar[MAX_PLAYERS]


Re: Assign specific ID to a vehicle - TheStreetsRP - 03.07.2013

Don't store anything in the player's variables. What I do.

Код:
enum vehEnum { vehEntity, vehID, vehOwnerID };
new Vehicle[MAX_VEHICLES][vehEnum];
Then load up the array with your vehicle data in OnGameModeInit();

Then whenever you need to find which vehicle you're dealing with, in regards to the array, you loop as such.. This is assuming you have the "vehicleid".

Код:
for(new i;i<MAX_VEHICLES;i++)
    if(Vehicle[i][vehEntity] == vehicleid)
        return i;