Easiest way to add huge amount vehicle -
princejeet1510 - 08.02.2017
Sup all,Hope you all are alright so....
Here what i wanted to know today.....like for an example:
I want to create a vehicle renting system....so for it i have vehicles by vehicles i mean (
AddStaticVehicleEx()bla bla) so the problem is if i create a
enum to hold the variable for each vehicle i will have to declare over
59 variables then will again i will have to assign those variables the vehicle info....that is pain in the ass tbh....what would be the easiest way to do it?
Re: Easiest way to add huge amount vehicle -
X337 - 08.02.2017
You can simply hook AddStaticVehicleEx function.
Example:
Код:
enum e_Vehicle {
vehiclecolor,
// ...
}
new Vehicles[MAX_VEHICLES][e_Vehicle];
stock hook_AddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2, respawn_delay, addsiren=0)
{
id = AddStaticVehicleEx(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2, respawn_delay, addsiren);
Vehicles[id][vehiclecolor] = color1;
return id;
}
#if defined _ALS_AddStaticVehicleEx
#undef AddStaticVehicleEx
#else
#define _ALS_AddStaticVehicleEx
#endif
#define AddStaticVehicleEx hook_AddStaticVehicleEx
Re: Easiest way to add huge amount vehicle -
princejeet1510 - 08.02.2017
So now I would add vehicles only and where btw?....
Re: Easiest way to add huge amount vehicle -
BroZeus - 08.02.2017
every heard of arrays and loop?
You don't have to create separate variable for each vehicle, you just have to create one array with enough space to hold all vehicle info.
While creating vehicle, load vehicle detail from db and store it in variable, you don't need to write code to store info for each vehicle separately you just have to write it once and in a loop.
Re: Easiest way to add huge amount vehicle -
princejeet1510 - 08.02.2017
Good but giving a example won't harm you I think....
Re: Easiest way to add huge amount vehicle -
princejeet1510 - 08.02.2017
Is that for real



117 views and Noone have confidence enough to reply lol...
Re: Easiest way to add huge amount vehicle -
ranme15 - 08.02.2017
You already got X337 example.. here is another one.
Код:
enum vehInfoEnum {
vehID,
price,
model
}
new vehInfo[59][vehInfoEnum];
for(new i = 0; i < 59; i ++) {
vehInfo[i][vehID] = CreateVehicle..
vehInfo[i][price] = 10000;
vehInfo[i][model] = 411;
}