Jump to content

Veh description not loading data when restarting


..:D&G:..

Recommended Posts

I recently tried to help my friend with his vehicle description system that he made, he can set the descriptions for the vehicles, but when he restarts the server the descriptions are not showing anymore, and he also gets some erros:

[2013-12-28 01:12:35] WARNING: vehdescription\s_vehicle_descriptions.lua:42: Bad argument @ 'getElementData' [Expected element at argument 1, got nil] 
[2013-12-28 01:12:35] ERROR: s_vehicle_descriptions.lua:45: attempt to index local 'descriptions' (a userdata value) 

This is what we have put to load the data from the database:

function loadToDescription(descriptions, theVehicle) 
    local dbid = getElementData(theVehicle, "dbid") 
    local acceptedQuerys = { } 
    for i = 1, 5 do 
        local load = exports.mysql:query_free("SELECT * FROM vehicles WHERE description" .. i .. " = '" .. mysql:escape_string( descriptions[i] ) .. "' WHERE id = '".. mysql:escape_string(dbid) .."'") 
        --local load = exports.mysql:query_free("SELECT * FROM vehicles WHERE description1= '" .. newvalue .. "' WHERE id = '".. exports.mysql:escape_string(dbid) .."'")        
        if load then 
            exports['anticheat-system']:loadProtectedElementDataEx(theVehicle, "description:"..i, descriptions[i], true) 
            acceptedQuerys[i] = true 
        end 
    end 
     
    local counter = 0 
    for j = 1, #acceptedQuerys do 
        if acceptedQuerys[j] then 
            counter = counter + 1 
        end 
    end 
end 
addEventHandler ( "onResourceStart", getRootElement(), loadToDescription ) 

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...