WASSIm. Posted January 1, 2014 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)
Jaysds1 Posted January 1, 2014 Posted January 1, 2014 Did you try seeing if the result is a table before trying to return the value? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
WASSIm. Posted January 1, 2014 Author 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
Castillo Posted January 1, 2014 Posted January 1, 2014 Either getBan or getBanFromIP must be returning a boolean instead of a table. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
WASSIm. Posted January 1, 2014 Author 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 ?
Castillo Posted January 1, 2014 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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