Jump to content

sendVehicleInfo


DLmass

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...