G-Stefan Posted June 29, 2016 Share Posted June 29, 2016 I know that xml is outdate but it is easy to use Nothing happens when the resource starts Should i save this client /server? i am new GUIEditor = { button = {}, window = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0, 0, 312, 206, "Welcome to ...", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(31, 31, 239, 51, "Login", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "sa-header") guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF1BFB03") GUIEditor.button[2] = guiCreateButton(31, 110, 239, 51, "Register", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[2], "sa-header") guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFDE801") addEventHandler("onClientGUIClick", GUIEditor.button[2], registerPanel, false) end ) function registerButton(button,state) if button == "left" and state == "up" then registerWindow = guiCreateWindow(0, 0, 239, 328, "Register if you dont have an account", false) guiWindowSetSizable(registerWindow, false) userLabel = guiCreateLabel(10, 27, 88, 45, "User", false, registerWindow) guiSetFont(userLabel, "sa-header") guiLabelSetColor(userLabel, 253, 232, 1) editUser = guiCreateEdit(105, 37, 124, 26, "", false, registerWindow) passLabel = guiCreateLabel(10, 82, 88, 45, "Pass", false, registerWindow) guiSetFont(passLabel, "sa-header") guiLabelSetColor(passLabel, 253, 232, 1) editPass = guiCreateEdit(105, 91, 124, 26, "", false, registerWindow) registerButton = guiCreateButton(21, 148, 198, 57, "Register", false, registerWindow) guiSetFont(registerButton, "sa-header") guiSetProperty(registerButton, "NormalTextColour", "FF36FC01") backButton = guiCreateButton(20, 235, 198, 57, "Back", false, registerWindow) guiSetFont(backButton, "sa-header") guiSetProperty(backButton, "NormalTextColour", "FFFD0000") addEventHandler("onClientGUIClick",registerButton,accountSave) end end local counter = 1 function accountSave(button,state) accountDataBase = xmlLoadFile("DataBases\accounts.xml") newUsername = tostring(guiGetText(editUser)) newPassword = tostring(guiGetText(editPass)) if accountDataBase then return else accountDataBase = xmlCreateFile("DataBases\accounts.xml","root") accountNode = xmlCreateChild(accountDataBase,"Account"..counter) xmlNodeSetAttribute(accountNode,"username",nil) xmlNodeSetAttribute(accountNode,"password",nil) end if button == "left" and state == "up" then if newPassword and newUsername then accountTable = xmlNodeGetChildren(accountDataBase) for i,node in pairs do otherNamers = xmlNodeGetAttribute(accountDataBase, "username") if newUsername == tostring(otherNamers) then break else accountNode = xmlCreateChild(accountDataBase,"Account"..counter) xmlNodeSetAttribute(accountNode,"username",newUsername) xmlNodeSetAttribute(accountNode,"password",newPassword) counter = counter + 1 break end end end end end Link to comment
Simple0x47 Posted June 29, 2016 Share Posted June 29, 2016 Try this: GUIEditor = { button = {}, window = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0, 0, 312, 206, "Welcome to ...", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(31, 31, 239, 51, "Login", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "sa-header") guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF1BFB03") GUIEditor.button[2] = guiCreateButton(31, 110, 239, 51, "Register", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[2], "sa-header") guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFDE801") addEventHandler("onClientGUIClick", GUIEditor.button[2], registerPanel, false) end ) function registerButton(button,state) if button == "left" and state == "up" then registerWindow = guiCreateWindow(0, 0, 239, 328, "Register if you dont have an account", false) guiWindowSetSizable(registerWindow, false) userLabel = guiCreateLabel(10, 27, 88, 45, "User", false, registerWindow) guiSetFont(userLabel, "sa-header") guiLabelSetColor(userLabel, 253, 232, 1) editUser = guiCreateEdit(105, 37, 124, 26, "", false, registerWindow) passLabel = guiCreateLabel(10, 82, 88, 45, "Pass", false, registerWindow) guiSetFont(passLabel, "sa-header") guiLabelSetColor(passLabel, 253, 232, 1) editPass = guiCreateEdit(105, 91, 124, 26, "", false, registerWindow) registerButton = guiCreateButton(21, 148, 198, 57, "Register", false, registerWindow) guiSetFont(registerButton, "sa-header") guiSetProperty(registerButton, "NormalTextColour", "FF36FC01") backButton = guiCreateButton(20, 235, 198, 57, "Back", false, registerWindow) guiSetFont(backButton, "sa-header") guiSetProperty(backButton, "NormalTextColour", "FFFD0000") addEventHandler("onClientGUIClick",registerButton,accountSave) end end local counter = 1 function accountSave(button,state) accountDataBase = xmlLoadFile("DataBases/accounts.xml") newUsername = tostring(guiGetText(editUser)) newPassword = tostring(guiGetText(editPass)) if accountDataBase then return else accountDataBase = xmlCreateFile("DataBases/accounts.xml","root") accountNode = xmlCreateChild(accountDataBase,"Account"..counter) xmlNodeSetAttribute(accountNode,"username",nil) xmlNodeSetAttribute(accountNode,"password",nil) end if button == "left" and state == "up" then if newPassword and newUsername then accountTable = xmlNodeGetChildren(accountDataBase) for i,node in pairs do otherNamers = xmlNodeGetAttribute(accountDataBase, "username") if newUsername == tostring(otherNamers) then break else accountNode = xmlCreateChild(accountDataBase,"Account"..counter) xmlNodeSetAttribute(accountNode,"username",newUsername) xmlNodeSetAttribute(accountNode,"password",newPassword) counter = counter + 1 break end end end end end 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