Jump to content

attempt to compare number with nil?!?!?


Lukkaz

Recommended Posts

  
addCommandHandler( "jailtime", 
function ( player, commandName ) 
    if exports.players:isLoggedIn( player ) then 
    local characterID = exports.players:getCharacterID( player ) 
    if characterID then 
     local result = exports.sql:query_assoc( "SELECT jailTime FROM characters WHERE characterID = "..characterID ) 
            for key, value in ipairs( result ) do 
            local time= value.time 
            if ( time >= 1 ) then    
            outputChatBox ( "Your jailtime is "..time..".", source, 0, 255, 0 ) 
            else  
            outputDebugString("its not working it cant be compared(NIL)") 
        end 
    end 
end 
end 
end 
) 
  

I been working on this for so long and getting quite frustrated -_-

it's probably a quick fix but I can not see it and come to you guys as a last resort.

Link to comment

Your SQL query selects jailTime, not "time", I think this will do:

     local result = exports.sql:query_assoc( "SELECT jailTime FROM characters WHERE characterID = "..characterID ) 
            for key, value in ipairs( result ) do 
                local time= value.jailTime 

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