Next available ID
#1

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

Код:
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.
Reply
#3

I fixed it anyhow, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)