03.05.2012, 11:16
Quote:
Well, you cannot just get last ID of car.
What if Vehicle ID 100, 124, 156,175,201 is destroyed? Then it will replace id 100, and return 99. |
The only good way to do it by hooking CreateVehicle is by having a global counter variable that is incremented in Create* and decremented on Destroy*.
But then you obviously have the problem of multiple different scripts having individual vehicle counts, therefore the only good way is looping through them all and checking if the model is valid.
I had another idea but I think it's too much work for the results really:
- Create a variable that holds the highest id.
- Hook CreateV. function so when a vehicle is created it checks if the ID is higher than the last marked ID from CreateV.
- If it is assign the new highest ID to the variable.
- Loop up to that ID on the count function, this way the loop doesn't to unneeded work if you have a server with only 200 vehicles on (MAX_VEHICLES is 2000 right?)
I guess that would work across multiple scripts right?