Hello, im actualy modifying a esx_vehicleshop to a Motocycle script and as soon as i enter and press E the marker the Error: client/main.lua:194: bad argument #1 to ‘insert’ (table expected, got nil) appears. All i did is changing the vehicles and the categories, (btw i downloaded a already modified vehicleshop to motorbikes). the script is working with normal sql, as soon as i change something in the categories i get freezed bevore the menu opens. I already tried doing it on several normal vehicleshop scripts and always the same error. Hope some one can help me, thank.
Lines in main.lua
for i=1, #Vehicles, 1 do
if IsModelInCdimage(GetHashKey(Vehicles[i].model)) then
194/ table.insert(vehiclesByCategory[Vehicles[i].category], Vehicles[i])
else
print((‘esx_motorshop: vehicle “%s” does not exist’):format(Vehicles[i].model))
end
end
MYSQL Left: categories Right: vehicles
I already tried to find the problem here but somehow i found no solution.
This error is happening because you are missing the bmw category.
So on line 194, you are trying to insert into a table that doesn’t exist (vehiclesByCategory[“bmw”]), because that category was never created when all the others were added to vehiclesByCategory.
Simply add the bmw category to the database table and you should be good.
omg… i checked it 5 times, tried 4 hours to fix it… i should do less on the server, my brain istn working … im sorry and thank you verry much, now it works.
can i close this topic? or how does it work for the nexttime
Hahaha you’re all good and we’ve ALL been there, many times xD
You marked it as solved, so that’s good.
Now it will close and lock itself after 1 month with no replies.
All the best!
This thread was solved, but if you are having the same issue, I suggest opening a new thread, providing screenshots or code blocks like this OP did and feel free to tag me. I will help you over there, instead of hijacking this thread.