WASSIm. Posted January 1, 2014 Share Posted January 1, 2014 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
Jaysds1 Posted January 1, 2014 Share Posted January 1, 2014 Did you try seeing if the result is a table before trying to return the value? Link to comment
Baseplate Posted January 1, 2014 Share Posted January 1, 2014 Can you copy the table creation syntax? Link to comment
WASSIm. Posted January 1, 2014 Author Share Posted January 1, 2014 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
Castillo Posted January 1, 2014 Share Posted January 1, 2014 Either getBan or getBanFromIP must be returning a boolean instead of a table. Link to comment
WASSIm. Posted January 1, 2014 Author Share Posted January 1, 2014 Either getBan or getBanFromIP must be returning a boolean instead of a table. its working if have row. btw how fix ? Link to comment
Castillo Posted January 1, 2014 Share Posted January 1, 2014 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
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