[Help] Get Vehicle Model

Hello, i’m trying to edit the esx_jb_advanced_truck_inventory resource,
It basicly creates an trunk inventroy in every vehicle, but there is one problem, i can only change the max weight in a trunk for a vehicle class, such ass “Sedans” can only carry 20KG and “Helicopters” can carry 50kg,
so what i want to do is to change instead of using “GetVehicleClass” to somehow get the VehicleModel name so i can change every specific max car weight in the game

Link to resource https://github.com/TanguyOrtegat/esx_jb_advanced_truck_inventory

Instead of this i would like to change the [numbers] to model name in config.
Config.VehicleLimit = {
[0] = 30000, --Compact
[1] = 40000, --Sedan
[2] = 70000, --SUV
[3] = 25000, --Coupes
[4] = 30000, --Muscle
[5] = 10000, --Sports Classics
[6] = 5000, --Sports
[7] = 5000, --Super
[8] = 5000, --Motorcycles
[9] = 180000, --Off-road
[10] = 300000, --Industrial
[11] = 70000, --Utility
[12] = 100000, --Vans
[13] = 0, --Cycles
[14] = 5000, --Boats
[15] = 20000, --Helicopters
[16] = 0, --Planes
[17] = 40000, --Service
[18] = 40000, --Emergency
[19] = 0, --Military
[20] = 300000, --Commercial
[21] = 0, --Trains
}

1 Like

This should assign the variable vehicleModel to the vehicle model that the player is in.

local vehicleModel = GetEntityModel(GetVehiclePedIsIn(PlayerPedId()))
3 Likes

Yes, but the thing is, the player is accesing the trunk from outside of the car, Also the value of the trunk needs to be constant, not “When player is near/in”

You have to add this around line 99 of the script you’re using:

local vehicleModel = GetEntityModel(closecar)

That will assign vehicleModel to the model of the vehicle that you’re accessing, whether you’re in it or near it.

1 Like

What do i have to do after that? to change all the weights? I do not quite get it

I’ve prepared the config file, vehiclemodel list to change the values
https://pastebin.com/GeRCCegF

Do i need to make any changes there?

Can anyone please help me? im stuck at this…

do a new array like

config.VehicleLimit = {
adder = 10000,
ambulance = 2000,
sanchez = 30000
}

and the furst chech if car you use is in that array then apply that weight otherwise take the weight of the class. as easy as that

Whatever i’m doing it doesent work ingame. i’m new to lua, A new array?

I’ve fixed the entire config file with all models listed

config.VehicleLimit = {
adder = 10000,
ambulance = 2000,
sanchez = 30000
etc…
}

But i cant get the script to “Read” that this is the total weight. It ends up that i can open the esx_menu_dialog until “Amount” appears, Then it’s stuck

now look in the script where it applies the weight limit of classes. do a firt check if the vehile model is in the list, if it is, then take that value otherwise take value in class list

Smart, So you mean like this?:
local vehicleModel = GetVehicleClass(frontVeh)
local vehicleModel = GetEntityModel(frontVeh)

if totalweight > Config.VehicleLimitModel[vehicleModel] or Config.VehicleLimitClass[typeVeh] then
max = true
else
max = false
end

I’ve Changed the config names and addes Model to the modellist and class to the class list

So i did enter that code, But i still cant Deposit stuff into the car.

Please take a look what im doing wrong. Here is the files
https://ufile.io/enuak

local vehicleModelClassWeight = GetVehicleClass(frontVeh)
local vehicleModelModelWeight = GetEntityModel(frontVeh)

if Config.vehicleModelModelWeight [vehicleModel]  ~= nil then
if totalweight > Config.vehicleModelModelWeight [vehicleModel] then
max = true
else
max = false
end
else
if totalweight > Config.vehicleModelClassWeight [typeVeh] then
max = true
else
max = false
end
end

somerhing like that should work i think

Is that the only thing i should edit in the client script? Because i changed alot that touches the “typeVeh” variable, Did you look the code?

well you should check everywhere where he checks vehicle class first check vehiclemodel if there is non then vehicle class

At line 330:

local MaxVh =(tonumber(Config.VehicleModelModelWeight[vehicleModel] or Config.VehicleModelClassWeight[typeVeh])/1000)

Should i use that?

Or should i leave it as it was before:

local MaxVh =(tonumber(Config.VehicleModelClassWeight[typeVeh])/1000)

always use different variables

local MaxVhModel =tonumber(Config.VehicleModelModelWeight[vehicleModel])/1000)
local MaxVhClass = tonumber(Config.VehicleModelClassWeight[typeVeh])/1000)

This is confusing me alot lol So basicly i need to edit everything then? I mean, the scirpt is probably using something called “MaxVh” some where in the code, and if i change it to MaxVhModel, Doesent i have to change it on every line it uses it?

you do have to change everyline.

Can’t i jsut keep it at MaxVh and adapt it that way? isn’t it easier?