Vehicle id messup - 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: Vehicle id messup (
/showthread.php?tid=574305)
Vehicle id messup -
Marcuse - 15.05.2015
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
AW: Vehicle id messup -
NaS - 15.05.2015
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..)?
Re: Vehicle id messup -
Marcuse - 16.05.2015
Job vehicles
Could you please give me an example of what i need to do after i destroy/respawn a vehicle please
AW: Vehicle id messup -
NaS - 16.05.2015
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.
Re: Vehicle id messup -
Marcuse - 16.05.2015
So i dont need to reset it when i /respawnallcars on /respawnthiscar ?
AW: Vehicle id messup -
NaS - 16.05.2015
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.
Re: Vehicle id messup -
Marcuse - 16.05.2015
Thanks very much!