Next available ID - 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: Next available ID (
/showthread.php?tid=606176)
Next available ID -
CloudLEL - 30.04.2016
Hi,
I need some insight on how I can do the following.
Say I have a command in-game which creates a vehicle. And each time it creates a vehicle it assigns an incremental ID to the vehicle (1, 2, 3, 4 etc..)
But if I delete the vehicle with the ID 3. The next vehicle I create needs to replace the ID that was deleted instead of continuing on the list.
Anyone know how I can do this?
Re: Next available ID -
CalvinC - 30.04.2016
Код:
stock GetFreeVehicleSlot()
{
for(new i = 1; i < MAX_VEHICLES; i ++)
{
if(!IsValidVehicle(i)) return i;
}
return 0;
}
This will get the next vehicleid that is unused.
Re: Next available ID -
CloudLEL - 30.04.2016
I fixed it anyhow, thanks.