Klesh Posted June 24, 2011 Posted June 24, 2011 Hello, im making a simple gui,is Window login GUI but i have problems with the ( " end, ) ") and that nears, maybe have other error from somewhere because the login window is not showing: Client-Side: function createLoginWindow() wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",true) lblUser = guiCreateLabel(22,40,142,17,"Username ",true,wdwLogin) lblPass = guiCreateLabel(25,167,127,20,"Password",true,wdwLogin) edtUser = guiCreateEdit(21,71,141,32,"",true,wdwLogin) edtPass = guiCreateEdit(23,202,141,32,"",true,wdwLogin) guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) btnLogin = guiCreateButton(31,263,133,41,"Login",true,wdwLogin) guiSetFont(btnLogin,"sa-header") guiSetVisible(wdwLogin, true) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResouce()), function () createLoginWindow() outPutChatBox("Welcome to MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible (wdwLogin ,true) else outPutChatBox("An unexpected error was ocurred and the log in Window was not created") end showCursor(true) guiSetInputEnbled(true) end ) function createLoginWindow () addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end function clientSubmitLogin (button,state) if button == "left" and state =="up" then guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end end function clientSubmitLogin (button,state) if button =="left" and state == "up" then local username = getGuiText(edtUser) local password =getGuiText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement (), username, password) guiSetInputEnable(false) guiSetVisible(wdwLogin, false) else outputChatBox("Please enter a username and password") end end end Thanks for any help.
Castillo Posted June 24, 2011 Posted June 24, 2011 function createLoginWindow() wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",true) lblUser = guiCreateLabel(22,40,142,17,"Username ",true,wdwLogin) lblPass = guiCreateLabel(25,167,127,20,"Password",true,wdwLogin) edtUser = guiCreateEdit(21,71,141,32,"",true,wdwLogin) edtPass = guiCreateEdit(23,202,141,32,"",true,wdwLogin) guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) btnLogin = guiCreateButton(31,263,133,41,"Login",true,wdwLogin) guiSetFont(btnLogin,"sa-header") guiSetVisible(wdwLogin, true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResouce()), function () createLoginWindow() outPutChatBox("Welcome to MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible (wdwLogin ,true) else outPutChatBox("An unexpected error was ocurred and the log in Window was not created") end showCursor(true) guiSetInputEnbled(true) end ) function clientSubmitLogin (button,state) if button == "left" and state =="up" then guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end end function clientSubmitLogin (button,state) if button =="left" and state == "up" then local username = getGuiText(edtUser) local password =getGuiText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement (), username, password) guiSetInputEnable(false) guiSetVisible(wdwLogin, false) else outputChatBox("Please enter a username and password") end end end
JR10 Posted June 24, 2011 Posted June 24, 2011 Klesh, Alot of the functions are spelled wrong. function createLoginWindow() wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",true) lblUser = guiCreateLabel(22,40,142,17,"Username ",true,wdwLogin) lblPass = guiCreateLabel(25,167,127,20,"Password",true,wdwLogin) edtUser = guiCreateEdit(21,71,141,32,"",true,wdwLogin) edtPass = guiCreateEdit(23,202,141,32,"",true,wdwLogin) guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) btnLogin = guiCreateButton(31,263,133,41,"Login",true,wdwLogin) guiSetFont(btnLogin,"sa-header") guiSetVisible(wdwLogin, true) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResouce()), function () createLoginWindow() outputChatBox("Welcome to MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible (wdwLogin ,true) else outputChatBox("An unexpected error was ocurred and the log in Window was not created") end showCursor(true) guiSetInputEnabled(true) end ) function clientSubmitLogin (button,state) if button == "left" and state =="up" then guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) end end function clientSubmitLogin (button,state) if button =="left" and state == "up" then local username = getGuiText(edtUser) local password =getGuiText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement (), username, password) guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) else outputChatBox("Please enter a username and password") end end end
Klesh Posted June 24, 2011 Author Posted June 24, 2011 (edited) Being no showing, maybe the error is in the server-side? Edited June 25, 2011 by Guest
JR10 Posted June 24, 2011 Posted June 24, 2011 First did you see my code?? because i fixed all the wrong spelled functions and and its not showing ofc because addEventHandler("onClientResourceStart", getResourceRootElement(getThisResouce()), function () getThisResouce?? should be: addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () guiSetVisible(wdwLogin, true) Hmm?? its already shown up you should hide it change tru to false.
Klesh Posted June 25, 2011 Author Posted June 25, 2011 No showing yet, its maybe because i have to add a function with playerJoin or some code is wrong.
JR10 Posted June 25, 2011 Posted June 25, 2011 Try this: function createLoginWindow() wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",true) lblUser = guiCreateLabel(22,40,142,17,"Username ",true,wdwLogin) lblPass = guiCreateLabel(25,167,127,20,"Password",true,wdwLogin) edtUser = guiCreateEdit(21,71,141,32,"",true,wdwLogin) edtPass = guiCreateEdit(23,202,141,32,"",true,wdwLogin) guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) btnLogin = guiCreateButton(31,263,133,41,"Login",true,wdwLogin) guiSetFont(btnLogin,"sa-header") guiSetVisible(wdwLogin, false) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createLoginWindow() outputChatBox("Welcome to MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible (wdwLogin ,true) showCursor(true) guiSetInputEnabled(true) else outputChatBox("An unexpected error was ocurred and the log in Window was not created") end end ) function clientSubmitLogin (button,state) if button =="left" and state == "up" then local username = getGuiText(edtUser) local password =getGuiText(edtPass) if username and password then triggerServerEvent("submitLogin", getRootElement (), username, password) guiSetInputEnabled(false) guiSetVisible(wdwLogin, false) showCursor(false) else outputChatBox("Please enter a username and password") end end end
Klesh Posted June 25, 2011 Author Posted June 25, 2011 (edited) Showing the cursor and the welcome message works, but the window still not showing. Edited June 25, 2011 by Guest
gokalpfirat Posted June 25, 2011 Posted June 25, 2011 I think your windows x,y is too high then i could be you cant see in screen.
Klesh Posted June 25, 2011 Author Posted June 25, 2011 I think is not that, i create the window with GUIeditor so the size and coord are good, maybe some value is wrong. Here is the line 3: Server-side: function loginHandler(username,password) end addEvent(submitLogin, true) addEventHandler("submitLogin",root,loginHandler) function loginHandler(username,password) if username == user and password == apple then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) setCameraTarget(client, client) outputChatBox("You succesfully logged, your stats will be saved.") end else outPutChatBox("Invalid username and password, please re-connect and try again.",client) end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler)
JR10 Posted June 25, 2011 Posted June 25, 2011 it's damn obvious function loginHandler(username,password) if username == user and password == apple then if (client) then spawnPlayer(client, 1959.55, -1714.46, 10) setCameraTarget(client, client) outputChatBox("You succesfully logged, your stats will be saved.") end else outPutChatBox("Invalid username and password, please re-connect and try again.",client) end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler)
Klesh Posted June 25, 2011 Author Posted June 25, 2011 Yes i didn't see, but is the same, look this: Try to test, this resource is for MTA: community.
JR10 Posted June 25, 2011 Posted June 25, 2011 The problem is the relative you specified it true while its not : function createLoginWindow() wdwLogin = guiCreateWindow(787,419,187,323,"Login System by Sparrow",false) lblUser = guiCreateLabel(22,40,142,17,"Username ",false,wdwLogin) lblPass = guiCreateLabel(25,167,127,20,"Password",false,wdwLogin) edtUser = guiCreateEdit(21,71,141,32,"",false,wdwLogin) edtPass = guiCreateEdit(23,202,141,32,"",false,wdwLogin) guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) btnLogin = guiCreateButton(31,263,133,41,"Login",false,wdwLogin) guiSetFont(btnLogin,"sa-header") guiSetVisible(wdwLogin, false) addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createLoginWindow() outputChatBox("Welcome to MTA:SA Server, please log in.") if (wdwLogin ~= nil) then guiSetVisible (wdwLogin ,true) showCursor(true) guiSetInputEnabled(true) else outputChatBox("An unexpected error was ocurred and the log in Window was not created") end end ) Tested it and it worked.
Klesh Posted June 25, 2011 Author Posted June 25, 2011 Yes works, but the login button no works, login button only hide the window and the player no log in. Something wrong in the code?
JR10 Posted June 25, 2011 Posted June 25, 2011 here: if username == user and password == apple then should be: if username == 'user' and password == 'apple' then
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