DLmass Posted August 8, 2014 Share Posted August 8, 2014 I have no clue how to solve this. All help is much appreciated.. Thanks.. function sendVehicleInfo(player) local username = getElementData (player, "username") local veh = mysql_query(database, "SELECT * FROM vehicles WHERE username = '"..username.."'") if #veh > 0 then local ele = {} for i=1,#veh do if veh[i].spawned == 1 then ele[i] = spawnPlayerVehicle(player,vehicles[i],false) end veh[i].sellPrice = getVehicleSellPrice(veh[i].boughtprice,player) veh[i].boughtprice = false end triggerClientEvent(player,"receiveVehicles", player, veh, ele) end end Attempt to get lenght of local 'vehicles' (a userdata value) at line 4 Link to comment
vx89 Posted August 8, 2014 Share Posted August 8, 2014 Are you sure you are the author of this? Link to comment
DLmass Posted August 8, 2014 Author Share Posted August 8, 2014 No. I found this online actually Link to comment
Mr_Moose Posted August 8, 2014 Share Posted August 8, 2014 You may have forgot to define 'vehicles', vehicles = { } Can't remember exactly what the meaning of that error was but it's obviously something related to the variable named vehicles. Since object orientated programming was implemented recently as well you may be careful defining objects with the same name as the class such as 'player' or 'vehicle' as in this case. Link to comment
DLmass Posted August 8, 2014 Author Share Posted August 8, 2014 hey MrBrutus, that does not work! Link to comment
Mr_Moose Posted August 8, 2014 Share Posted August 8, 2014 Ops, my mistake. You are trying to get the length of an object named 'vehicles' (on line 4 according to the error log but it doesn't seem to be that in your code). That error can't be related to mysql, check your entire code for a syntax like this: #vehicles Because that's pretty much the only place you can attempt to get the length of an array. Link to comment
DLmass Posted August 8, 2014 Author Share Posted August 8, 2014 Well. I'm kinda trying to convert it over from built in mysql to mta_mysql. Everything else succeeds except this.. Link to comment
Mr_Moose Posted August 8, 2014 Share Posted August 8, 2014 Well the syntax seems to be correct, but why not use dbConnect instead, those functions has built in features to prevent some SQL injections as well which is a common way to 'hack' a mysql database. Link to comment
DLmass Posted August 8, 2014 Author Share Posted August 8, 2014 I can't use dbConnect. My server does not like it.. It always fails when I try to connect lol Link to comment
Mr_Moose Posted August 8, 2014 Share Posted August 8, 2014 You have to use it the correct way, and follow the correct syntax Link to comment
DLmass Posted August 8, 2014 Author Share Posted August 8, 2014 I did I just won't connect to my database! Link to comment
xXMADEXx Posted August 8, 2014 Share Posted August 8, 2014 I did I just won't connect to my database! What is the exact code you're using to try to connect to the database? Link to comment
DLmass Posted August 8, 2014 Author Share Posted August 8, 2014 Looks like I had to install libmysqlclient.so.16. I've decided that I will no longer convert the script to mta_mysql. Thanks for your help MrBrutus Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now