Best way to create a vehicle enum?
#1

-- DELETED --
Reply
#2

Do a select query, as count(*), and use that value for MAX_VEHICLES

Or if you want to load only 2k vehs, make a check in for loop when loading data.
Reply
#3

Quote:
Originally Posted by iLearner
Посмотреть сообщение
Do a select query, as count(*), and use that value for MAX_VEHICLES

Or if you want to load only 2k vehs, make a check in for loop when loading data.
I want to load every vehicle from the database, and then create them when the player logges in. So it's not like it will create 2k cars at once
Reply
#4

You can't physically create more than 2000 vehicles anyway. The server just won't let you. An AddStaticVehicle/CreateVehicle call that would go over the limit will return INVALID_VEHICLE_ID.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
You can't physically create more than 2000 vehicles anyway. The server just won't let you. An AddStaticVehicle/CreateVehicle call that would go over the limit will return INVALID_VEHICLE_ID.
Yea I know. But the current "setup" I have is that a vehicle that is spawned is assigned to this enum. But first before it spawnes, it needs to have some data in it's own part of the enum.. And if I can't load more than 2k vehicles into the enum, I wouldn't be able to spawn that vehicle..
Reply
#6

I don't know if I understood you, but you want to create player vehicles (player login in server and create his vehicle)?
If yes, you'll request to DB the data of his vehicle (model, color, paintjob, ...), assign the data to its id in vehicleVariables array and create the vehicle
Every time a player join, you create the vehicle, every time the player leaves the server, you destroy it and erase the data in vehicleVariables array.

Example:
PHP код:
public OnPlayerConnect(playerid)
{
    new 
vID INVALID_VEHICLE_ID;
    
//Loop all vehicles to get the free slot (Maybe it isn't the best method to do that)
    
for(new i=0i>MAX_VEHICLESi++)
    {
        if(!
IsValidVehicle(i))
        {
            
//This slot is free
            
vID i;
            break;
        }
    }
    
//This means that we have a free slot and we can create a vehicle.
    
if(vID != INVALID_VEHICLE_ID)
    {
        
//Request data from DB, assign to vID slot in vehicleVariables array and create the vehicle.
    
}
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)