Stylez Posted October 6, 2012 Share Posted October 6, 2012 hi, i made a gui script from intro. to gui scripting but i did it with absolute position and window doesnt shows up. heres the code CLIENT function createLoginWindow local sWidth, sHeight = guiGetScreenSize() local width, height = 450, 450 local x = (sWidth/2) - (width/2) local y = (sHeight/2) - (height/2) loginWindow = guiCreateWindow(x,y, width, height, "Please Log-In", false) guiWindowSetMovable (loginWindow, false) guiWindowSetSizable (loginWindow, false) guiCreateLabel(190,50,35, 25, "Username", false, loginWindow) guiCreateLabel(190,100, 35,25, "Password", false, loginWindow ) editUser = guiCreateEdit(190,75,100,40, "", false, loginWindow) editPass = guiCreateEdit(190, 125, 100, 40, "", false, loginWindow) guiEditSetMaxLength(editUser, 50) guiEditSetMaxLenght(editPass, 50) button = guiCreateButton (190, 250, 50, 50, "Submit", false, loginWindow) guiSetVisible(loginWindow, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createLoginWindow() outputChatBox("Wlcome to MTA:SA Cops & Robbers Server. Please Log-In") if loginWindow ~= nil then guiSetVisible(loginWindow, true) else outputChatBox("An error has occured") end end ) function submit (button, state) if button == "left" and state =="up" then local username = guiGetText(editUser) local password = guiGetText(editPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), username, password) guiSetInputEnabled(false) guiSetVisible(loginWindow, false) showCursor(false) else outputChatBox("Please Enter Username And Password") end end end addEventHandler("onClientGUIClick", button, submit, false) SERVER function loginHandler(username, password) if username == "user" and password =="apple" then if client then spawnPlayer(client, 2505.52, -1741.73, 2072.98) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Welocme To Cops & Robbers Server", client) end else outputChatBox("Invalid username or Password. Please try again", client) return end end addEvent("submitLogin", true) addEventHandler("submitLogin", root, loginHandler) Link to comment
scratcher911 Posted October 6, 2012 Share Posted October 6, 2012 function createLoginWindow should be: function createLoginWindow() Link to comment
Castillo Posted October 6, 2012 Share Posted October 6, 2012 Here: function createLoginWindow You have missing parentheses. Should be: function createLoginWindow ( ) Link to comment
Stylez Posted October 6, 2012 Author Share Posted October 6, 2012 oh, didint saw it. thankyou Link to comment
Stylez Posted October 6, 2012 Author Share Posted October 6, 2012 but it doesnt creates button. why? i deleted 2 spaces between arguments. Link to comment
Castillo Posted October 6, 2012 Share Posted October 6, 2012 function createLoginWindow ( ) local sWidth, sHeight = guiGetScreenSize() local width, height = 450, 450 local x = (sWidth/2) - (width/2) local y = (sHeight/2) - (height/2) loginWindow = guiCreateWindow(x,y, width, height, "Please Log-In", false) guiWindowSetMovable (loginWindow, false) guiWindowSetSizable (loginWindow, false) guiCreateLabel(190,50,35, 25, "Username", false, loginWindow) guiCreateLabel(190,100, 35,25, "Password", false, loginWindow ) editUser = guiCreateEdit(190,75,100,40, "", false, loginWindow) editPass = guiCreateEdit(190, 125, 100, 40, "", false, loginWindow) guiEditSetMaxLength(editUser, 50) guiEditSetMaxLength(editPass, 50) button = guiCreateButton (190, 250, 50, 50, "Submit", false, loginWindow) guiSetVisible(loginWindow, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createLoginWindow() outputChatBox("Wlcome to MTA:SA Cops & Robbers Server. Please Log-In") if loginWindow ~= nil then guiSetVisible(loginWindow, true) else outputChatBox("An error has occured") end end ) function submit (button, state) if button == "left" and state =="up" then local username = guiGetText(editUser) local password = guiGetText(editPass) if username and password then triggerServerEvent("submitLogin", getRootElement(), username, password) guiSetInputEnabled(false) guiSetVisible(loginWindow, false) showCursor(false) else outputChatBox("Please Enter Username And Password") end end end addEventHandler("onClientGUIClick", button, submit, false) It was because you put: guiEditSetMaxLenght ( editPass, 50 ) Instead of: guiEditSetMaxLength ( editPass, 50 ) The function name was wrong. 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