#DaMiAnO Posted April 14, 2012 Share Posted April 14, 2012 Hi! My resource, not working. When I click "Zaloguj", the GUI will close. 0 error messages (outputChatBox). Errors in Console: [2012-04-14 10:15:35] WARNING: GameMode\LoginRegister_s.lua:7: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got nil] [2012-04-14 10:15:35] ERROR: GameMode\LoginRegister_s.lua:8: attempt to call global 'dbPool' (a nil value) Client-side: function createLoginBox() LoginGUI = guiCreateWindow(527,159,380,407,"Truck - Logowanie",false) guiSetAlpha(LoginGUI,0.69999998807907) guiWindowSetSizable(LoginGUI,false) IntroLabel = guiCreateLabel(47,62,290,32," Witamy na Truck!\nWpisz poniżej Login oraz Hasło, aby się zalogować!",false,LoginGUI) guiSetFont(IntroLabel,"default-bold-small") LoginLabel = guiCreateLabel(76,181,38,16,"Login:",false,LoginGUI) guiSetFont(LoginLabel,"default-bold-small") PassLabel = guiCreateLabel(72,218,40,16,"Hasło:",false,LoginGUI) guiSetFont(PassLabel,"default-bold-small") LoginBox = guiCreateEdit(128,179,137,19,"",false,LoginGUI) PassBox = guiCreateEdit(129,216,137,19,"",false,LoginGUI) guiEditSetMasked(PassBox,true) LoginButton = guiCreateButton(35,259,306,52,"Zaloguj!",false,LoginGUI) RegisterButton = guiCreateButton(35,330,306,52,"Zarejesrtuj!",false,LoginGUI) guiSetVisible(LoginGUI, false) addEventHandler("onClientGUIClick", LoginButton, submitLogin, false) addEventHandler("onClientGUIClick", RegisterButton, registerPlayer, false) end function startLoginRegisterModule() createLoginBox() if (LoginGUI ~= nil) then guiSetVisible(LoginGUI, true) else outputDebugString("Nie moge utworzyc GUI odpowiedzialnego od Logowania/Rejestracji!", 3, 255, 0, 0) end showCursor(true) guiSetInputEnabled(true) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginRegisterModule) function submitLogin(button, state) if button == "left" and state == "up" then local login = guiGetText(LoginBox) local pass = guiGetText(PassBox) if login and pass then triggerServerEvent("submitLoginServer", getRootElement(), login, pass) guiSetInputEnabled(false) guiSetVisible(LoginGUI, false) showCursor(false) else outputChatBox("#EE5555* #C0C0C0Proszę wpisać #EE5555Login #C0C0C0i #EE5555Hasło#C0C0C0!") end end end Server-side: function loginHandler(login, pass) local getAccount = dbQuery(connection, "SELECT * FROM `accounts` WHERE `account` = `%s` AND `password` = `%s`", login, pass) local result = dbPool(getAccount, 0) if result then if client then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) end else outputChatBox("#EE5555* #C0C0C0Podano zły #EE5555Login #C0C0C0lub #EE5555Hasło#C0C0C0!") end end addEvent("submitLoginServer", true) addEventHandler("submitLoginServer", root, loginHandler) Link to comment
Kenix Posted April 14, 2012 Share Posted April 14, 2012 (edited) All your code wrong .. Edited April 14, 2012 by Guest Link to comment
Kenix Posted April 14, 2012 Share Posted April 14, 2012 Variable connection nil. dbPool not exists! Should be dbPoll Can you show where you connect to db? Link to comment
drk Posted April 14, 2012 Share Posted April 14, 2012 Also, you can't use variables with same name of MTA:SA functions like getAccount. Link to comment
#DaMiAnO Posted April 14, 2012 Author Share Posted April 14, 2012 mysql = dbConnect("mysql", "dbname=mta;host=192.166.219.226", "damiano", "Censored", "share=1") if(mysql) then outputServerLog("\n[MySQL] Pomyslnie polaczono z MySQL!") outputDebugString("Pomyslnie polaczono z MySQL!", 3, 0, 224, 0) else outputServerLog("\n[MySQL] Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...") outputDebugString("Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...", 3, 255, 0, 0) destroyElement(mysql) end Link to comment
drk Posted April 14, 2012 Share Posted April 14, 2012 Client-side: function createLoginBox() LoginGUI = guiCreateWindow(527,159,380,407,"Truck - Logowanie",false) guiSetAlpha(LoginGUI,0.69999998807907) guiWindowSetSizable(LoginGUI,false) IntroLabel = guiCreateLabel(47,62,290,32," Witamy na Truck!\nWpisz poniżej Login oraz Hasło, aby się zalogować!",false,LoginGUI) guiSetFont(IntroLabel,"default-bold-small") LoginLabel = guiCreateLabel(76,181,38,16,"Login:",false,LoginGUI) guiSetFont(LoginLabel,"default-bold-small") PassLabel = guiCreateLabel(72,218,40,16,"Hasło:",false,LoginGUI) guiSetFont(PassLabel,"default-bold-small") LoginBox = guiCreateEdit(128,179,137,19,"",false,LoginGUI) PassBox = guiCreateEdit(129,216,137,19,"",false,LoginGUI) guiEditSetMasked(PassBox,true) LoginButton = guiCreateButton(35,259,306,52,"Zaloguj!",false,LoginGUI) RegisterButton = guiCreateButton(35,330,306,52,"Zarejesrtuj!",false,LoginGUI) guiSetVisible(LoginGUI, false) addEventHandler("onClientGUIClick", LoginButton, submitLogin, false) addEventHandler("onClientGUIClick", RegisterButton, registerPlayer, false) end function startLoginRegisterModule() createLoginBox() if (LoginGUI ~= nil) then guiSetVisible(LoginGUI, true) else outputDebugString("Nie moge utworzyc GUI odpowiedzialnego od Logowania/Rejestracji!", 3, 255, 0, 0) end showCursor(true) guiSetInputEnabled(true) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginRegisterModule) function submitLogin(button, state) if button == "left" and state == "up" then local login = guiGetText(LoginBox) local pass = guiGetText(PassBox) if login and pass then triggerServerEvent("submitLoginServer", getRootElement(), login, pass) guiSetInputEnabled(false) guiSetVisible(LoginGUI, false) showCursor(false) else outputChatBox("#EE5555* #C0C0C0Proszę wpisać #EE5555Login #C0C0C0i #EE5555Hasło#C0C0C0!") end end end Server-side: function loginHandler(login, pass) mysql = dbConnect("mysql", "dbname=mta;host=192.166.219.226", "damiano", "Censored", "share=1") if(mysql) then outputServerLog("\n[MySQL] Pomyslnie polaczono z MySQL!") outputDebugString("Pomyslnie polaczono z MySQL!", 3, 0, 224, 0) else outputServerLog("\n[MySQL] Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...") outputDebugString("Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...", 3, 255, 0, 0) destroyElement(mysql) end local acc = dbQuery(mysql, "SELECT * FROM `accounts` WHERE `account` = `%s` AND `password` = `%s`", login, pass) local result = dbPoll(acc, 0) if result then if client then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) end else outputChatBox("#EE5555* #C0C0C0Podano zły #EE5555Login #C0C0C0lub #EE5555Hasło#C0C0C0!") end end addEvent("submitLoginServer", true) addEventHandler("submitLoginServer", root, loginHandler) Link to comment
#DaMiAnO Posted April 14, 2012 Author Share Posted April 14, 2012 Client-side: function createLoginBox() LoginGUI = guiCreateWindow(527,159,380,407,"Truck - Logowanie",false) guiSetAlpha(LoginGUI,0.69999998807907) guiWindowSetSizable(LoginGUI,false) IntroLabel = guiCreateLabel(47,62,290,32," Witamy na Truck!\nWpisz poniżej Login oraz Hasło, aby się zalogować!",false,LoginGUI) guiSetFont(IntroLabel,"default-bold-small") LoginLabel = guiCreateLabel(76,181,38,16,"Login:",false,LoginGUI) guiSetFont(LoginLabel,"default-bold-small") PassLabel = guiCreateLabel(72,218,40,16,"Hasło:",false,LoginGUI) guiSetFont(PassLabel,"default-bold-small") LoginBox = guiCreateEdit(128,179,137,19,"",false,LoginGUI) PassBox = guiCreateEdit(129,216,137,19,"",false,LoginGUI) guiEditSetMasked(PassBox,true) LoginButton = guiCreateButton(35,259,306,52,"Zaloguj!",false,LoginGUI) RegisterButton = guiCreateButton(35,330,306,52,"Zarejesrtuj!",false,LoginGUI) guiSetVisible(LoginGUI, false) addEventHandler("onClientGUIClick", LoginButton, submitLogin, false) addEventHandler("onClientGUIClick", RegisterButton, registerPlayer, false) end function startLoginRegisterModule() createLoginBox() if (LoginGUI ~= nil) then guiSetVisible(LoginGUI, true) else outputDebugString("Nie moge utworzyc GUI odpowiedzialnego od Logowania/Rejestracji!", 3, 255, 0, 0) end showCursor(true) guiSetInputEnabled(true) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginRegisterModule) function submitLogin(button, state) if button == "left" and state == "up" then local login = guiGetText(LoginBox) local pass = guiGetText(PassBox) if login and pass then triggerServerEvent("submitLoginServer", getRootElement(), login, pass) guiSetInputEnabled(false) guiSetVisible(LoginGUI, false) showCursor(false) else outputChatBox("#EE5555* #C0C0C0Proszę wpisać #EE5555Login #C0C0C0i #EE5555Hasło#C0C0C0!") end end end Server-side: function loginHandler(login, pass) mysql = dbConnect("mysql", "dbname=mta;host=192.166.219.226", "damiano", "Censored", "share=1") if(mysql) then outputServerLog("\n[MySQL] Pomyslnie polaczono z MySQL!") outputDebugString("Pomyslnie polaczono z MySQL!", 3, 0, 224, 0) else outputServerLog("\n[MySQL] Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...") outputDebugString("Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...", 3, 255, 0, 0) destroyElement(mysql) end local acc = dbQuery(mysql, "SELECT * FROM `accounts` WHERE `account` = `%s` AND `password` = `%s`", login, pass) local result = dbPoll(acc, 0) if result then if client then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) end else outputChatBox("#EE5555* #C0C0C0Podano zły #EE5555Login #C0C0C0lub #EE5555Hasło#C0C0C0!") end end addEvent("submitLoginServer", true) addEventHandler("submitLoginServer", root, loginHandler) Can you make for me, when player write bad login or pass, GUI will not hide? BUG: My account is in DB, but when i loging, i see message "Bad login or pass". How to fix? Link to comment
drk Posted April 14, 2012 Share Posted April 14, 2012 I don't know where is that "Bad login or pass" errors, so I can't help you. Link to comment
#DaMiAnO Posted April 14, 2012 Author Share Posted April 14, 2012 Database result uncollected after 5 minutes. [Query: SELECT * FROM `accounts` WHERE `accounts` = `%s` AND `password` = `%s`] Link to comment
drk Posted April 14, 2012 Share Posted April 14, 2012 Database result uncollected after 5 minutes. [Query: SELECT * FROM `accounts` WHERE `accounts` = `%s` AND `password` = `%s`] Seems like you don't get data from table for 5 minutes. Link to comment
drk Posted April 15, 2012 Share Posted April 15, 2012 I know that. Seems like you don't get data from table for 5 minutes. Link to comment
#DaMiAnO Posted April 20, 2012 Author Share Posted April 20, 2012 I'm using now mysql module, my code: function createLoginBox() LoginGUI = guiCreateWindow(527,159,380,407,"Truck - Logowanie",false) guiSetAlpha(LoginGUI,0.69999998807907) guiWindowSetSizable(LoginGUI,false) IntroLabel = guiCreateLabel(47,62,290,32," Witamy na Truck!\nWpisz poniżej Login oraz Hasło, aby się zalogować!",false,LoginGUI) guiSetFont(IntroLabel,"default-bold-small") LoginLabel = guiCreateLabel(76,181,38,16,"Login:",false,LoginGUI) guiSetFont(LoginLabel,"default-bold-small") PassLabel = guiCreateLabel(72,218,40,16,"Hasło:",false,LoginGUI) guiSetFont(PassLabel,"default-bold-small") LoginBox = guiCreateEdit(128,179,137,19,"",false,LoginGUI) PassBox = guiCreateEdit(129,216,137,19,"",false,LoginGUI) guiEditSetMasked(PassBox,true) LoginButton = guiCreateButton(35,259,306,52,"Zaloguj!",false,LoginGUI) RegisterButton = guiCreateButton(35,330,306,52,"Zarejesrtuj!",false,LoginGUI) guiSetVisible(LoginGUI, false) addEventHandler("onClientGUIClick", LoginButton, submitLogin, false) addEventHandler("onClientGUIClick", RegisterButton, registerPlayer, false) end function startLoginRegisterModule() createLoginBox() if (LoginGUI ~= nil) then guiSetVisible(LoginGUI, true) else outputDebugString("Nie moge utworzyc GUI odpowiedzialnego od Logowania/Rejestracji!", 3, 255, 0, 0) end showCursor(true) guiSetInputEnabled(true) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginRegisterModule) function submitLogin(button, state) if button == "left" and state == "up" then local login = guiGetText(LoginBox) local pass = guiGetText(PassBox) if login and pass then triggerServerEvent("submitLoginServer", getRootElement(), login, pass) guiSetInputEnabled(false) guiSetVisible(LoginGUI, false) showCursor(false) else outputChatBox("#EE5555* #C0C0C0Proszę wpisać #EE5555Login #C0C0C0i #EE5555Hasło#C0C0C0!") end end end function loginHandler(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `accounts` = '%s' AND `password` = '%s'", login, pass) if result then if client then spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) end else outputChatBox("#EE5555* #C0C0C0Podano zły #EE5555Login #C0C0C0lub #EE5555Hasło#C0C0C0!", client) end end addEvent("submitLoginServer", true) addEventHandler("submitLoginServer", root, loginHandler) Link to comment
Michael# Posted April 20, 2012 Share Posted April 20, 2012 What is "result" ? Also, show connection and you should free result of query. Link to comment
#DaMiAnO Posted April 20, 2012 Author Share Posted April 20, 2012 Connect: mysql = mysql_connect("localhost", "root", "", "truck") if(mysql) then outputServerLog("\n[MySQL] Pomyslnie polaczono z MySQL!") outputDebugString("Pomyslnie polaczono z MySQL!", 3, 0, 224, 0) else outputServerLog("\n[MySQL] Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...") outputDebugString("Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...", 3, 255, 0, 0) mysql_close(mysql) end Link to comment
Michael# Posted April 20, 2012 Share Posted April 20, 2012 What is "result" in the other code? Link to comment
#DaMiAnO Posted April 21, 2012 Author Share Posted April 21, 2012 In MySQL Query been bad. Topic can be closed. 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