Vehicle id messup
#1

Hello, i have the same problem as mentioned here but i dont understand what to do, can someone give me a code explanation please its a matter of life and death(not really but its very important)
https://sampforum.blast.hk/showthread.php?tid=348235 This is the problem
Reply
#2

I guess you are either missing to destroy a vehicle though resetting the variable or other way round.
Try to check all vehicle variables & DestroyVehicle calls, if there are variables messed up or not being reset after destroying the corresponding vehicle..

Hard to say if there's no code - even with code it can be hard to find out.
Does it happen to all/random vehicles or a special type of vehicle (like playervehicle, factionvehicles or st..)?
Reply
#3

Job vehicles
Could you please give me an example of what i need to do after i destroy/respawn a vehicle please
Reply
#4

So, you have vehicle variable, like:

Код:
new vehicle = -1; // Initialize with -1 since not assigned yet
Set it to -1 to know that this is not filled yet.

Now somewhere you want to create that vehicle, you do:

Код:
if(vehicle == -1) vehicle = CreateVehicle(...);
Now elsewhere, where you want to remove it again:

Код:
if(vehicle != -1) DestroyVehicle(vehicle);
vehicle = -1; // Set it back to -1 so you know it is not created
That should be done with every vehicle.

This way you make sure no IDs will be switched/lost.
Reply
#5

So i dont need to reset it when i /respawnallcars on /respawnthiscar ?
Reply
#6

oh you mean on simple respawning (SetVehicleToRespawn())?
No, since the vehicle doesnt get destroyed in that case, so it still exists and keeps its ID.
Reply
#7

Thanks very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)