Best-Killer Posted January 18, 2017 Share Posted January 18, 2017 usernames = {} function onLogin ( player, user, pass ) local account = getAccount ( user, pass ) local accblock = accountBlocked(user) if ( account ~= false ) then if accblock == "0" then return end outputChatBox(accblock) if isTimer(cooldown) then return end cooldown = setTimer(function() end, 1000, 1) if (logIn ( client, account, pass ) == true) then triggerClientEvent ( client, "SAEGLogin:hideLogin", client ) setElementData(player,"AccountData:Username",tostring(user)) setElementData ( player, "AccountData:Serial", s ) setElementData ( player, "AccountData:IP", ip ) else triggerClientEvent ( client, "setWarning", client, "Something went wrong while logging!", 255, 0, 0 ) end else triggerClientEvent ( client, "setWarning", client, "Invalid login details!", 255, 0, 0 ) end end addEvent( "SAEGLogin:onLogin", true ) addEventHandler( "SAEGLogin:onLogin", root, onLogin ) function accountBlocked(acc) accblocked = false query = exports.NGsql:db_query ( "SELECT * FROM accountdata WHERE Username=? LIMIT 1", tostring(acc)) for i, v in ipairs (query) do accblocked = v["Blocked"] end if not accblocked then return false end return accblocked end what's worng with my code guys ?? pff the player can login if the account is blocked Link to comment
LoPollo Posted January 18, 2017 Share Posted January 18, 2017 if not accblocked then return false end return accblocked --why don't you use return accblocked --or if you don't want nils return accblocked or false setElementData ( player, "AccountData:IP", ip ) else triggerClientEvent ( client, "setWarning", client, "Something went wrong while logging!", 255, 0, 0 ) --aren't player and client the same? it would be better to use only client addEventHandler( "SAEGLogin:onLogin", root, onLogin ) --THERE'S NO PROBLEM HERE --i just want you to remind, since you bound the event to root, that having root in the triggerEvent/triggerServerEvent as sourceElement is bad local accblock = accountBlocked(user) if ( account ~= false ) then --it's better to check if account is (not) false before calling accountBlocked: if ( account ~= false ) then local accblock = accountBlocked(user) About the problem outputChatBox(accblock) --i usually use iprint() or outputDebugString+tostring. I don't remember if booleans are printed. So... what happens in the chat? Does it print true? setElementData ( player, "AccountData:Serial", s ) setElementData ( player, "AccountData:IP", ip ) Ok... after seeing this, since i don't see neither s nor ip defined, i'm sure you didn't even tried to correct the script. Reading errors helps you and more importantly helps US if you want us to solve the script. That's why i usually ignore posts without enough informations about the problems, and that's why i'm annoyed now. I won't further read the script for now. Till you correct the above and, if it's not enough, until you explain more the problem (in this case i mean giving us the error log) i don't see why I (actually everyone) should help you with this. NOTE: i'm annoyed but that doesn't mean i won't help you if it's required. So if you prove that help is actually required, as i said i will be happy to help. But if you don't give us the error log (debugscript 3/serverl.log/clientscript.log) and you don't read it i feel like you think we are like a "fix-machine". We are here to help you in scripting, making you learn and learning ourself something everytime, we are not machines. Link to comment
Best-Killer Posted January 18, 2017 Author Share Posted January 18, 2017 38 minutes ago, LoPollo said: if not accblocked then return false end return accblocked --why don't you use return accblocked --or if you don't want nils return accblocked or false setElementData ( player, "AccountData:IP", ip ) else triggerClientEvent ( client, "setWarning", client, "Something went wrong while logging!", 255, 0, 0 ) --aren't player and client the same? it would be better to use only client addEventHandler( "SAEGLogin:onLogin", root, onLogin ) --THERE'S NO PROBLEM HERE --i just want you to remind, since you bound the event to root, that having root in the triggerEvent/triggerServerEvent as sourceElement is bad local accblock = accountBlocked(user) if ( account ~= false ) then --it's better to check if account is (not) false before calling accountBlocked: if ( account ~= false ) then local accblock = accountBlocked(user) About the problem outputChatBox(accblock) --i usually use iprint() or outputDebugString+tostring. I don't remember if booleans are printed. So... what happens in the chat? Does it print true? setElementData ( player, "AccountData:Serial", s ) setElementData ( player, "AccountData:IP", ip ) Ok... after seeing this, since i don't see neither s nor ip defined, i'm sure you didn't even tried to correct the script. Reading errors helps you and more importantly helps US if you want us to solve the script. That's why i usually ignore posts without enough informations about the problems, and that's why i'm annoyed now. I won't further read the script for now. Till you correct the above and, if it's not enough, until you explain more the problem (in this case i mean giving us the error log) i don't see why I (actually everyone) should help you with this. NOTE: i'm annoyed but that doesn't mean i won't help you if it's required. So if you prove that help is actually required, as i said i will be happy to help. But if you don't give us the error log (debugscript 3/serverl.log/clientscript.log) and you don't read it i feel like you think we are like a "fix-machine". We are here to help you in scripting, making you learn and learning ourself something everytime, we are not machines. Hhhhh i like all your words all right hahahaha there is no errors in debug ^^ and thx (Sloved) Link to comment
LoPollo Posted January 18, 2017 Share Posted January 18, 2017 There was no error? weird I'm happy you fixed it 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