Assign specific ID to a vehicle
#1

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 !?
Reply
#2

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

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!?
Reply
#4

PlayerCar[MAX_PLAYERS]
Reply
#5

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;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)