Jump to content

Help SQL


WASSIm.

Recommended Posts

HI GUYS. i have problem wit this code its not working and return nil

function getBan(banlSerial) 
    local result = exports["ZA"]:dbQueryZA( "SELECT * FROM bans WHERE banlSerial = ?", tostring(banlSerial)) 
    if (result) then return tostring(result[1]) end 
end 
  
addCommandHandler("ban", 
function (thePlayer) 
    outputChatBox(tostring(getBan(getPlayerSerial(thePlayer)).banlSerial)) 
end) 

Link to comment

i fixed that problem but i have other like it . function not working if no row

ERROR: 108: attempt to index a nil value

function isPlayerBanned(thePlayer) 
    if (thePlayer) then 
        local IP = getPlayerIP(thePlayer) 
        local serial = getPlayerSerial(thePlayer) 
        if (getBan(serial)["banlSerial"]) or (getBanFromIP(IP)["banlIP"]) then 
            return true else return false 
        end 
    else 
        return false 
    end 
end 

Link to comment
function isPlayerBanned ( thePlayer ) 
    if ( thePlayer ) then 
        local IP = getPlayerIP ( thePlayer ) 
        local serial = getPlayerSerial ( thePlayer ) 
        if ( getBan ( serial ) and getBan ( serial ) [ "banlSerial" ] ) or ( getBanFromIP ( IP ) and getBanFromIP ( IP ) [ "banlIP" ] ) then 
            return true 
        else 
            return false 
        end 
    else 
        return false 
    end 
end 

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