#DaMiAnO Posted May 5, 2012 Posted May 5, 2012 Hello! I have big trouble, because my code have 0 errors and 0 warning, but it isn't working. Client-side: local screenWidth, screenHeight = guiGetScreenSize() function createDxOnLogin() dxDrawRectangle(769.0, 379.0, 211.0, 193.0, tocolor(255, 0, 0, 155), false) dxDrawText("Ping: 0\n\n\n FPS: 0",778.0, 387.0, 970.0, 542.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 380.0, 404.0, 194.0, tocolor(255, 192, 0, 155), false) dxDrawText("Rejestracja", 358.0, 380.0, 574.0, 418.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(769.0, 178.0, 211.0, 193.0, tocolor(0, 255, 0, 155), false) dxDrawText("Online:\n\n 1 / 100", 776.0, 180.0, 962.0, 215.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 178.0, 404.0, 194.0, tocolor(0, 96, 255, 155), false) dxDrawText("Logowanie", 361.0, 180.0, 547.0, 215.0,tocolor(255, 255, 255,255), 1.0, "bankgothic", "left", "top", false, false, false) end addEventHandler("onClientRender", root, createDxOnLogin) function createGUIElements() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHasło:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jeśli nie posiadasz konta, udaj się na nasze forum i zarejestruj konto.\nKolejnym krokiem będzie założenie postaci.\n\n\n[url=http://www.LostHeaven.pl]www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) guiSetVisible(loginButton, false) guiSetVisible(loginPassLabel, false) guiSetVisible(registerLabel, false) guiSetVisible(loginBox, false) guiSetVisible(passBox, false) guiSetVisible(keyImage, false) addEventHandler("onClientGUIClick", loginButton, clientSubmitLogin, false) end function onClientJoinToServer() createGUIElements() guiSetVisible(loginButton, true) guiSetVisible(loginPassLabel, true) guiSetVisible(registerLabel, true) guiSetVisible(loginBox, true) guiSetVisible(passBox, true) guiSetVisible(keyImage, true) showCursor(true) guiSetInputEnabled(true) addEventHandler("onClientRender", root, createDxOnLogin) end addEvent("tryAgain", true) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onClientJoinToServer) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", getRootElement(), login, pass) guiSetVisible(loginButton, false) guiSetVisible(loginPassLabel, false) guiSetVisible(registerLabel, false) guiSetVisible(loginBox, false) guiSetVisible(passBox, false) guiSetVisible(keyImage, false) guiSetInputEnabled(false) showCursor(false) else outputChatBox("#EE5555* #C0C0C0Proszę wpisać #EE5555Login #C0C0C0oraz #EE5555Hasło#C0C0C0, aby się zalogować!", 255, 255, 255, true) end end end Server-side: function onPlayerLoginToAccount(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '%s' AND `password` = '%s'", login, pass) if acc then outputChatBox("Zalogowano.", source) else outputChatBox("#EE5555* #C0C0C0Podano zły #EE5555Login #C0C0C0lub #EE5555Hasło#C0C0C0!", source, 255, 255, 255, true) triggerServerEvent("tryAgain", getRootElement()) end end addEvent("submitLogin", true) addEventHandler("submitLogin", root, onPlayerLoginToAccount) Sorry for my English.
TwiX! Posted May 5, 2012 Posted May 5, 2012 if you not have errors check all code with debug or output messages - Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]
Jaysds1 Posted May 5, 2012 Posted May 5, 2012 Here: Client: local screenWidth, screenHeight = guiGetScreenSize() function createDxOnLogin() dxDrawRectangle(769.0, 379.0, 211.0, 193.0, tocolor(255, 0, 0, 155), false) dxDrawText("Ping: 0\n\n\n FPS: 0",778.0, 387.0, 970.0, 542.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 380.0, 404.0, 194.0, tocolor(255, 192, 0, 155), false) dxDrawText("Rejestracja", 358.0, 380.0, 574.0, 418.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(769.0, 178.0, 211.0, 193.0, tocolor(0, 255, 0, 155), false) dxDrawText("Online:\n\n 1 / 100", 776.0, 180.0, 962.0, 215.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 178.0, 404.0, 194.0, tocolor(0, 96, 255, 155), false) dxDrawText("Logowanie", 361.0, 180.0, 547.0, 215.0,tocolor(255, 255, 255,255), 1.0, "bankgothic", "left", "top", false, false, false) end function createGUIElements() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) guiSetVisible(loginButton, false) guiSetVisible(loginPassLabel, false) guiSetVisible(registerLabel, false) guiSetVisible(loginBox, false) guiSetVisible(passBox, false) guiSetVisible(keyImage, false) addEventHandler("onClientGUIClick", loginButton, clientSubmitLogin, false) end addEventHandler("onClientResourceStart",resourceRoot,function() createGUIElements() showCursor(true) guiSetInputEnabled(true) addEventHandler("onClientRender", root, createDxOnLogin) end) addEvent("tryAgain", true) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", getRootElement(), login, pass) guiSetVisible(loginButton, false) guiSetVisible(loginPassLabel, false) guiSetVisible(registerLabel, false) guiSetVisible(loginBox, false) guiSetVisible(passBox, false) guiSetVisible(keyImage, false) guiSetInputEnabled(false) showCursor(false) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end Server: addEvent("submitLogin", true) addEventHandler("submitLogin", root,function(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '"..login.."' AND `password` = '"..pass.."'") if acc then outputChatBox("Zalogowano.", source) else outputChatBox("#EE5555* #C0C0C0Podano zly #EE5555Login #C0C0C0lub #EE5555Haslo#C0C0C0!", source, 255, 255, 255, true) triggerServerEvent(client,"tryAgain", getRootElement()) end end) 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/
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 Here:Client: local screenWidth, screenHeight = guiGetScreenSize() function createDxOnLogin() dxDrawRectangle(769.0, 379.0, 211.0, 193.0, tocolor(255, 0, 0, 155), false) dxDrawText("Ping: 0\n\n\n FPS: 0",778.0, 387.0, 970.0, 542.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 380.0, 404.0, 194.0, tocolor(255, 192, 0, 155), false) dxDrawText("Rejestracja", 358.0, 380.0, 574.0, 418.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(769.0, 178.0, 211.0, 193.0, tocolor(0, 255, 0, 155), false) dxDrawText("Online:\n\n 1 / 100", 776.0, 180.0, 962.0, 215.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 178.0, 404.0, 194.0, tocolor(0, 96, 255, 155), false) dxDrawText("Logowanie", 361.0, 180.0, 547.0, 215.0,tocolor(255, 255, 255,255), 1.0, "bankgothic", "left", "top", false, false, false) end function createGUIElements() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]http://www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) guiSetVisible(loginButton, false) guiSetVisible(loginPassLabel, false) guiSetVisible(registerLabel, false) guiSetVisible(loginBox, false) guiSetVisible(passBox, false) guiSetVisible(keyImage, false) addEventHandler("onClientGUIClick", loginButton, clientSubmitLogin, false) end addEventHandler("onClientResourceStart",resourceRoot,function() createGUIElements() showCursor(true) guiSetInputEnabled(true) addEventHandler("onClientRender", root, createDxOnLogin) end) addEvent("tryAgain", true) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", getRootElement(), login, pass) guiSetVisible(loginButton, false) guiSetVisible(loginPassLabel, false) guiSetVisible(registerLabel, false) guiSetVisible(loginBox, false) guiSetVisible(passBox, false) guiSetVisible(keyImage, false) guiSetInputEnabled(false) showCursor(false) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end Server: addEvent("submitLogin", true) addEventHandler("submitLogin", root,function(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '"..login.."' AND `password` = '"..pass.."'") if acc then outputChatBox("Zalogowano.", source) else outputChatBox("#EE5555* #C0C0C0Podano zly #EE5555Login #C0C0C0lub #EE5555Haslo#C0C0C0!", source, 255, 255, 255, true) triggerServerEvent(client,"tryAgain", getRootElement()) end end) Not working. Sorry for my English.
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 What's wrong with it? Is it not showing the GUI and Text? 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/
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 What's wrong with it?Is it not showing the GUI and Text? Yes. GUI and Dx not showing. Sorry for my English.
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 fine, try this: addEventHandler("onClientResourceStart",resourceStart,function() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) addEventHandler("onClientGUIClick", loginButton,function clientSubmitLogin(button,state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", localPlayer, login, pass) local elements = {loginButton,loginPassLabel,registerLabel,loginBox,passBox,keyImage} destroyElement(elements) guiSetInputEnabled(false) showCursor(false) removeEventHandler("onClientRender",root,createDxOnLogin) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end,false) showCursor(true) guiSetInputEnabled(true) addEventHandler("onClientRender", root, createDxOnLogin) end) function createDxOnLogin() dxDrawRectangle(769.0, 379.0, 211.0, 193.0, tocolor(255, 0, 0, 155), false) dxDrawText("Ping: 0\n\n\n FPS: 0",778.0, 387.0, 970.0, 542.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 380.0, 404.0, 194.0, tocolor(255, 192, 0, 155), false) dxDrawText("Rejestracja", 358.0, 380.0, 574.0, 418.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(769.0, 178.0, 211.0, 193.0, tocolor(0, 255, 0, 155), false) dxDrawText("Online:\n\n 1 / 100", 776.0, 180.0, 962.0, 215.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 178.0, 404.0, 194.0, tocolor(0, 96, 255, 155), false) dxDrawText("Logowanie", 361.0, 180.0, 547.0, 215.0,tocolor(255, 255, 255,255), 1.0, "bankgothic", "left", "top", false, false, false) end addEvent("submitLogin", true) addEventHandler("submitLogin", root,function(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '"login"' AND `password` = '"pass"'") if acc then outputChatBox("Zalogowano.", source) else outputChatBox("#EE5555* #C0C0C0Podano zly #EE5555Login #C0C0C0lub #EE5555Haslo#C0C0C0!", source, 255, 255, 255, true) triggerServerEvent(client,"tryAgain", root) end end) 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/
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 fine, try this: addEventHandler("onClientResourceStart",resourceStart,function() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]http://www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) addEventHandler("onClientGUIClick", loginButton,function clientSubmitLogin(button,state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", localPlayer, login, pass) local elements = {loginButton,loginPassLabel,registerLabel,loginBox,passBox,keyImage} destroyElement(elements) guiSetInputEnabled(false) showCursor(false) removeEventHandler("onClientRender",root,createDxOnLogin) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end,false) showCursor(true) guiSetInputEnabled(true) addEventHandler("onClientRender", root, createDxOnLogin) end) function createDxOnLogin() dxDrawRectangle(769.0, 379.0, 211.0, 193.0, tocolor(255, 0, 0, 155), false) dxDrawText("Ping: 0\n\n\n FPS: 0",778.0, 387.0, 970.0, 542.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 380.0, 404.0, 194.0, tocolor(255, 192, 0, 155), false) dxDrawText("Rejestracja", 358.0, 380.0, 574.0, 418.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(769.0, 178.0, 211.0, 193.0, tocolor(0, 255, 0, 155), false) dxDrawText("Online:\n\n 1 / 100", 776.0, 180.0, 962.0, 215.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 178.0, 404.0, 194.0, tocolor(0, 96, 255, 155), false) dxDrawText("Logowanie", 361.0, 180.0, 547.0, 215.0,tocolor(255, 255, 255,255), 1.0, "bankgothic", "left", "top", false, false, false) end addEvent("submitLogin", true) addEventHandler("submitLogin", root,function(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '"login"' AND `password` = '"pass"'") if acc then outputChatBox("Zalogowano.", source) else outputChatBox("#EE5555* #C0C0C0Podano zly #EE5555Login #C0C0C0lub #EE5555Haslo#C0C0C0!", source, 255, 255, 255, true) triggerServerEvent(client,"tryAgain", root) end end) Nope, Dx and GUI isn't showing.. Sorry for my English.
Callum Posted May 6, 2012 Posted May 6, 2012 Add an outputChatBox below everything in the script (on the line after the event handler). This will determine whether the script is being executed. If not, check your meta.xml. Retired
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 Error is here: addEventHandler("onClientResourceStart",resourceStart, function() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]http://www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) outputChatBox("Dupa1") addEventHandler("onClientGUIClick", loginButton, function clientSubmitLogin(button, state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", localPlayer, login, pass) local elements = {loginButton, loginPassLabel, registerLabel, loginBox, passBox, keyImage} destroyElement(elements) guiSetInputEnabled(false) showCursor(false) removeEventHandler("onClientRender",root,createDxOnLogin) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end, false) showCursor(true) guiSetInputEnabled(true) outputChatBox("Dupa2") addEventHandler("onClientRender", root, createDxOnLogin) end) Because Dupa1 and Dupa2 isn't showing. My meta: "Login.lua" type="client"/> Sorry for my English.
Guest Guest4401 Posted May 6, 2012 Posted May 6, 2012 addEventHandler("onClientResourceStart",resourceStart,function() What is resourceStart? It should be resourceRoot : addEventHandler("onClientResourceStart",resourceRoot,function() And change this src="Login.lua" type="client"/> to ="Login.lua" type="client"/>
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 addEventHandler("onClientResourceStart",resourceStart,function() What is resourceStart? It should be resourceRoot : addEventHandler("onClientResourceStart",resourceRoot,function() And change this src="Login.lua" type="client"/> to ="Login.lua" type="client"/> I edited this, and not working. : (( Sorry for my English.
hxv Posted May 6, 2012 Posted May 6, 2012 client, I have changed false) to ,false) addEventHandler("onClientResourceStart",root, function() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]http://www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) outputChatBox("Dupa1") addEventHandler("onClientGUIClick", loginButton, function clientSubmitLogin(button, state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", localPlayer, login, pass) local elements = {loginButton, loginPassLabel, registerLabel, loginBox, passBox, keyImage} destroyElement(elements) guiSetInputEnabled(false) showCursor(false) removeEventHandler("onClientRender",root,createDxOnLogin) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end, ,false) showCursor(true) guiSetInputEnabled(true) outputChatBox("Dupa2") addEventHandler("onClientRender", root, createDxOnLogin) end )
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 Working, but How to show Dx and GUI, when I wrote bad login or pass, and How to hide dx and gui, when i logged to account? Sorry for my English.
ben_wright Posted May 6, 2012 Posted May 6, 2012 addEventHandler("onClientResourceStart", root, function() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) addEventHandler("onClientGUIClick", loginButton, function(button, state) if button == "left" and state == "up" then local login = guiGetText( loginBox ) local pass = guiGetText( passBox ) if login and pass then triggerServerEvent("submitLogin", localPlayer, login, pass) local elements = { loginButton, loginPassLabel, registerLabel, loginBox, passBox, keyImage } destroyElement( elements ) guiSetInputEnabled( false ) showCursor( false ) removeEventHandler("onClientRender",root,createDxOnLogin) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end, false ) loginPassLabel = guiCreateLabel( 481, 244, 48, 56, "Login:\n\n\nHaslo:", false ) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel( 363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]http://www.LostHeaven.pl[/url]", false ) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit( 525, 241, 145, 23, "", false ) guiEditSetMaxLength( loginBox, 25 ) passBox = guiCreateEdit( 525, 281, 145, 23, "", false ) guiEditSetMasked( passBox, true ) guiEditSetMaxLength( passBox, 30 ) keyImage = guiCreateStaticImage( 358, 237, 111, 94, "images/Key.png", false ) --outputChatBox("Dupa1") showCursor( true ) guiSetInputEnabled( true ) --outputChatBox("Dupa2") addEventHandler("onClientRender", root, createDxOnLogin) end) use triggerClientEvent on serverside then trigger an event with guiSetVisible.
hxv Posted May 6, 2012 Posted May 6, 2012 server side: addEventHandler("onPlayerLogin", localPlayer, function() -- here your code to hide dx and gui end ) The dx or GUI will not hide when you will write bad login or pass without any conditions.
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 My code. Client: local screenWidth, screenHeight = guiGetScreenSize() local players = getElementsByType("player") function createDxOnLogin() dxDrawRectangle(769.0, 379.0, 211.0, 193.0, tocolor(255, 0, 0, 155), false) dxDrawText("Ping: "..tostring(getPlayerPing(getLocalPlayer())).."\n\n\n FPS: 0",778.0, 387.0, 970.0, 542.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 379.0, 404.0, 193.0, tocolor(255, 192, 0, 155), false) dxDrawText("Rejestracja", 358.0, 380.0, 574.0, 418.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(769.0, 178.0, 211.0, 193.0, tocolor(0, 255, 0, 155), false) dxDrawText("Online:\n\n "..tostring(#players).." / 100", 776.0, 180.0, 962.0, 215.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 178.0, 404.0, 194.0, tocolor(0, 96, 255, 155), false) dxDrawText("Logowanie", 361.0, 180.0, 547.0, 215.0,tocolor(255, 255, 255,255), 1.0, "bankgothic", "left", "top", false, false, false) end function createGUIElements() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]http://www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "key.png", false) guiSetVisible(loginButton, true) guiSetVisible(loginPassLabel, true) guiSetVisible(registerLabel, true) guiSetVisible(loginBox, true) guiSetVisible(passBox, true) guiSetVisible(keyImage, true) addEventHandler("onClientGUIClick", loginButton, clientSubmitLogin, false) end addEventHandler("onClientResourceStart",resourceRoot,function() createGUIElements() showCursor(true) guiSetInputEnabled(true) addEventHandler("onClientRender", root, createDxOnLogin) end) function tryAgainLogin() createGUIElements() addEventHandler("onClientRender", root, createDxOnLogin) end addEvent("tryAgain") addEventHandler("tryAgain", getRootElement(), tryAgainLogin) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", getRootElement(), login, pass) guiSetVisible(loginButton, false) guiSetVisible(loginPassLabel, false) guiSetVisible(registerLabel, false) guiSetVisible(loginBox, false) guiSetVisible(passBox, false) guiSetVisible(keyImage, false) guiSetInputEnabled(false) showCursor(false) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end Server: addEvent("submitLogin", true) addEventHandler("submitLogin", root, function(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '%s' AND `pass` = '%s'", login, pass) if acc then outputChatBox("Zalogowano.", source) else outputChatBox("#EE5555* #C0C0C0Podano zly #EE5555Login #C0C0C0lub #EE5555Haslo#C0C0C0!", source, 255, 255, 255, true) triggerServerEvent(source, "tryAgain", getRootElement()) end end) If i wrote bad login or pass, then GUI is invisible, but Dx is visible. If I wrote bad login or pass, I want Visible GUI and Visible Dx. If I wrote good login and pass, I want hide Dx and GUI. I'm triggering it, but does not working. Second question, bad argument #1 to 'mysql_query' (mysqlHandler expected, got nil). I'm connected to MySQL. ( Your methods to client-side not working ). Sorry for my English.
ben_wright Posted May 6, 2012 Posted May 6, 2012 addEvent("submitLogin", true) addEventHandler("submitLogin", root, function(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '%s' AND `pass` = '%s'", login, pass) if acc then outputChatBox("Zalogowano.", source) triggerClientEvent ( "yourEvent", source ) else outputChatBox("#EE5555* #C0C0C0Podano zly #EE5555Login #C0C0C0lub #EE5555Haslo#C0C0C0!", source, 255, 255, 255, true) triggerServerEvent(source, "tryAgain", getRootElement()) end end) use this method instead of, well.. yours. and something like, function yourEvent() guiSetVisible ( loginButton, false ) -- insert the rest here end addEvent("yourEvent") addEventHandler("yourEvent", localPlayer, yourEvent)
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 Code is bugged, for example outputChatBox is not showing. Sorry for my English.
ben_wright Posted May 6, 2012 Posted May 6, 2012 what exactly is bugged? using what I've posted earlier and the snippet above should do the trick.
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 Try this: addEventHandler("onClientResourceStart",resourceRoot,function() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]http://www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) addEventHandler("onClientGUIClick", loginButton,function(button,state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", localPlayer, login, pass) guiSetInputEnabled(false) showCursor(false) removeEventHandler("onClientRender",root,createDxOnLogin) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end,false) showCursor(true) guiSetInputEnabled(true) addEventHandler("onClientRender", root, createDxOnLogin) end) function createDxOnLogin() dxDrawRectangle(769.0, 379.0, 211.0, 193.0, tocolor(255, 0, 0, 155), false) dxDrawText("Ping: 0\n\n\n FPS: 0",778.0, 387.0, 970.0, 542.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 380.0, 404.0, 194.0, tocolor(255, 192, 0, 155), false) dxDrawText("Rejestracja", 358.0, 380.0, 574.0, 418.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(769.0, 178.0, 211.0, 193.0, tocolor(0, 255, 0, 155), false) dxDrawText("Online:\n\n 1 / 100", 776.0, 180.0, 962.0, 215.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 178.0, 404.0, 194.0, tocolor(0, 96, 255, 155), false) dxDrawText("Logowanie", 361.0, 180.0, 547.0, 215.0,tocolor(255, 255, 255,255), 1.0, "bankgothic", "left", "top", false, false, false) end addEvent("close",true) addEventHandler("close",root,function() local elements = {loginButton,loginPassLabel,registerLabel,loginBox,passBox,keyImage} destroyElement(elements) removeEventHandler("onClientRender",root,createDxOnLogin) end) addEvent("submitLogin", true) addEventHandler("submitLogin", root,function(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '"login"' AND `password` = '"pass"'") if acc then outputChatBox("Zalogowano.", source) triggerClientEvent(client,"close",root) else outputChatBox("#EE5555* #C0C0C0Podano zly #EE5555Login #C0C0C0lub #EE5555Haslo#C0C0C0!", source, 255, 255, 255, true) end end) 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/
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 Try this:addEventHandler("onClientResourceStart",resourceRoot,function() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]http://www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) addEventHandler("onClientGUIClick", loginButton,function(button,state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", localPlayer, login, pass) guiSetInputEnabled(false) showCursor(false) removeEventHandler("onClientRender",root,createDxOnLogin) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end,false) showCursor(true) guiSetInputEnabled(true) addEventHandler("onClientRender", root, createDxOnLogin) end) function createDxOnLogin() dxDrawRectangle(769.0, 379.0, 211.0, 193.0, tocolor(255, 0, 0, 155), false) dxDrawText("Ping: 0\n\n\n FPS: 0",778.0, 387.0, 970.0, 542.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 380.0, 404.0, 194.0, tocolor(255, 192, 0, 155), false) dxDrawText("Rejestracja", 358.0, 380.0, 574.0, 418.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(769.0, 178.0, 211.0, 193.0, tocolor(0, 255, 0, 155), false) dxDrawText("Online:\n\n 1 / 100", 776.0, 180.0, 962.0, 215.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 178.0, 404.0, 194.0, tocolor(0, 96, 255, 155), false) dxDrawText("Logowanie", 361.0, 180.0, 547.0, 215.0,tocolor(255, 255, 255,255), 1.0, "bankgothic", "left", "top", false, false, false) end addEvent("close",true) addEventHandler("close",root,function() local elements = {loginButton,loginPassLabel,registerLabel,loginBox,passBox,keyImage} destroyElement(elements) removeEventHandler("onClientRender",root,createDxOnLogin) end) addEvent("submitLogin", true) addEventHandler("submitLogin", root,function(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '"login"' AND `password` = '"pass"'") if acc then outputChatBox("Zalogowano.", source) triggerClientEvent(client,"close",root) else outputChatBox("#EE5555* #C0C0C0Podano zly #EE5555Login #C0C0C0lub #EE5555Haslo#C0C0C0!", source, 255, 255, 255, true) end end) When I left empty boxes, dx is hiding, but gui is showing. Sorry for my English.
#DaMiAnO Posted May 6, 2012 Author Posted May 6, 2012 Try this:addEventHandler("onClientResourceStart",resourceRoot,function() loginButton = guiCreateButton(634, 323, 117, 37, "Zaloguj!", false) loginPassLabel = guiCreateLabel(481, 244, 48, 56, "Login:\n\n\nHaslo:", false) guiSetFont(loginPassLabel,"default-bold-small") registerLabel = guiCreateLabel(363, 424, 397, 86, "Jesli nie posiadasz konta, udaj sie na nasze forum i zarejestruj konto.\nKolejnym krokiem bedzie zalozenie postaci.\n\n\n[url=http://www.LostHeaven.pl]http://www.LostHeaven.pl[/url]", false) guiSetFont(registerLabel,"default-bold-small") loginBox = guiCreateEdit(525, 241, 145, 23, "", false) guiEditSetMaxLength(loginBox, 25) passBox = guiCreateEdit(525, 281, 145, 23, "", false) guiEditSetMasked(passBox, true) guiEditSetMaxLength(passBox, 30) keyImage = guiCreateStaticImage(358, 237, 111, 94, "images/Key.png", false) addEventHandler("onClientGUIClick", loginButton,function(button,state) if button == "left" and state == "up" then local login = guiGetText(loginBox) local pass = guiGetText(passBox) if login and pass then triggerServerEvent("submitLogin", localPlayer, login, pass) guiSetInputEnabled(false) showCursor(false) removeEventHandler("onClientRender",root,createDxOnLogin) else outputChatBox("#EE5555* #C0C0C0Prosze wpisac #EE5555Login #C0C0C0oraz #EE5555Haslo#C0C0C0, aby sie zalogowac!", 255, 255, 255, true) end end end,false) showCursor(true) guiSetInputEnabled(true) addEventHandler("onClientRender", root, createDxOnLogin) end) function createDxOnLogin() dxDrawRectangle(769.0, 379.0, 211.0, 193.0, tocolor(255, 0, 0, 155), false) dxDrawText("Ping: 0\n\n\n FPS: 0",778.0, 387.0, 970.0, 542.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 380.0, 404.0, 194.0, tocolor(255, 192, 0, 155), false) dxDrawText("Rejestracja", 358.0, 380.0, 574.0, 418.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(769.0, 178.0, 211.0, 193.0, tocolor(0, 255, 0, 155), false) dxDrawText("Online:\n\n 1 / 100", 776.0, 180.0, 962.0, 215.0, tocolor(255, 255, 255, 255), 1.0, "bankgothic", "left", "top", false, false, false) dxDrawRectangle(358.0, 178.0, 404.0, 194.0, tocolor(0, 96, 255, 155), false) dxDrawText("Logowanie", 361.0, 180.0, 547.0, 215.0,tocolor(255, 255, 255,255), 1.0, "bankgothic", "left", "top", false, false, false) end addEvent("close",true) addEventHandler("close",root,function() local elements = {loginButton,loginPassLabel,registerLabel,loginBox,passBox,keyImage} destroyElement(elements) removeEventHandler("onClientRender",root,createDxOnLogin) end) addEvent("submitLogin", true) addEventHandler("submitLogin", root,function(login, pass) local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `login` = '"login"' AND `password` = '"pass"'") if acc then outputChatBox("Zalogowano.", source) triggerClientEvent(client,"close",root) else outputChatBox("#EE5555* #C0C0C0Podano zly #EE5555Login #C0C0C0lub #EE5555Haslo#C0C0C0!", source, 255, 255, 255, true) end end) When I left empty boxes, dx is hiding, but gui is showing. Error: bad argument #1 to 'mysql_query' (mysqlHandler expected, got nil) Sorry for my English.
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 create your mysql: mysql_connect() https://wiki.multitheftauto.com/wiki/Mod ... ql_connect 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/
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