Best way to create a vehicle enum? - 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: Best way to create a vehicle enum? (
/showthread.php?tid=629445)
Best way to create a vehicle enum? -
danielpalade - 26.02.2017
-- DELETED --
Re: Best way to create a vehicle enum? - iLearner - 26.02.2017
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.
Re: Best way to create a vehicle enum? -
danielpalade - 26.02.2017
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
Re: Best way to create a vehicle enum? -
Vince - 26.02.2017
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.
Re: Best way to create a vehicle enum? -
danielpalade - 26.02.2017
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..
Re: Best way to create a vehicle enum? -
renatog - 26.02.2017
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=0; i>MAX_VEHICLES; i++)
{
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;
}