01.12.2014, 15:31
Quote:
I would just add a field in the vehicledata enum that holds a bool to indicate if it's a worldvehicle or not.
Then you can check it easily as well, and this way all your data about a vehicle is combined into a single enum. Otherwise you have multiple arrays, each one holding different data: - vehicleinfo - worldinfo - copcar - admincars - whatever else When you enter a vehicle and you want to know if this entered vehicle is a worldcar, you need to loop through all worldcar indices and see if you find a match. If you found a match, it's a worldcar. If you can't find a match, it's not a worldcar. Putting all that data in one enum (vehicleinfo), removed that loop, speeding up your script as it doesn't need to search for a vehicleid. The OnPlayerEnterVehicle callback already gives you the vehicleid. You could easily check if this vehicle is a worldcar: pawn Code:
Or if you use another callback that doesn't give you a vehicleid, just use GetPlayerVehicleID to get the vehicleid you need to access ALL data about that vehicle, as it's all stored into one single enum. And to make a worldcar, you only need a short function: pawn Code:
Your solution works fine too, except you need loops to find data inside arrays, and you use less memory. But memory is less of an issue these days because computers have more and more memory (mine has 12GB of RAM), a few extra kilobytes won't hurt a true server. |