JR10 Posted July 12, 2011 Share Posted July 12, 2011 try this: local windowLogin local editLoginUser local editLoginPass local loginToRegist local buttonLoginSubmit local windowRegist local editRegistUser local editRegistPass local registToLogin local buttonRegistSubmit local windowPassChange local editPassChangeNew local editPassChangeRe local buttonPassChangeSubmit local buttonExit addEventHandler("onClientResourceStart", resourceRoot, function () createLoginWindow() createRegistWindow() createPassChangeWindow() showLoginWindow() end ) addEvent("onLoginStart", true) addEventHandler("onLoginStart", getRootElement(), showLoginWindow) addEvent("onRegistStart", true) addEventHandler("onRegistStart", getRootElement(), showRegistWindow) addEvent("onPassChangeStart", true) addEventHandler("onPassChangeStart", getRootElement(), showPassChangeWindow) function showLoginWindow() if not windowLogin then outputChatBox("A bejelentkezo rendszer nem mukodik rendesen, kerlek jelentsd a weboldalon") outputChatBox("www."..webSite..".hu") end guiSetVisible(windowLogin, true) showCursor(true) guiSetInputEnabled(true) end function showRegistWindow() if not windowRegist then outputChatBox("A bejelentkezo rendszer nem mukodik rendesen, kerlek jelentsd a weboldalon") outputChatBox("www."..webSite..".hu") end guiSetVisible(windowRegist, true) showCursor(true) guiSetInputEnabled(true) end function showPassChangeWindow() if not windowPassChange then outputChatBox("Ez a funkcio jelenleg inaktiv, hamarosan vissza lesz allitva") end guiSetVisible(windowRegist, true) showCursor(true) guiSetInputEnabled(true) end function createLoginWindow() local GUIEditor_Label = {} windowLogin = guiCreateWindow(0.3484,0.3242,0.3,0.2,"Bejelentkezes",true) guiWindowSetSizable(windowLogin,false) GUIEditor_Label[1] = guiCreateLabel(0.1,0.2,0.4453,0.1268,"Felhasznalonev:",true,windowLogin) guiLabelSetColor(GUIEditor_Label[1],255, 255, 255) GUIEditor_Label[2] = guiCreateLabel(0.1,0.4,0.3281,0.0927,"Jelszo:",true,windowLogin) guiLabelSetColor(GUIEditor_Label[2],255, 255, 255) editLoginUser = guiCreateEdit(0.401,0.2,0.5,0.1024,"",true,windowLogin) guiEditSetMaxLength(editLoginUser,64) editLoginPass = guiCreateEdit(0.401,0.4,0.5,0.1024,"",true,windowLogin) guiEditSetMaxLength(editLoginPass,64) buttonLoginSubmit = guiCreateButton(0.099,0.6488,0.2005,0.2,"Elfogad",true,windowLogin) buttonLoginToRegist = guiCreateButton(0.349,0.6488,0.2995,0.2,"Regisztracio",true,windowLogin) buttonExit = guiCreateButton(0.7005,0.6488,0.2005,0.2,"Kilepes",true,windowLogin) addEventHandler("onClientGUIClick", buttonLoginToRegist, changeLoginToRegist, false) addEventHandler("onClientGUIClick", buttonPassChangeSubmit, submitPassChange, false) addEventHandler("onClientGUIClick", buttonExit, exitAuth, false) guiSetVisible(windowLogin, false) end function createRegistWindow() local GUIEditor_Label = {} windowRegist = guiCreateWindow(0.3484,0.3242,0.3,0.2,"Regisztracio",true) guiWindowSetSizable(windowRegist,false) GUIEditor_Label[1] = guiCreateLabel(0.1,0.2,0.4453,0.1268,"Felhasznalonev:",true,windowRegist) guiLabelSetColor(GUIEditor_Label[1],255, 255, 255) GUIEditor_Label[2] = guiCreateLabel(0.1,0.4,0.3281,0.0927,"Jelszo:",true,windowRegist) guiLabelSetColor(GUIEditor_Label[2],255, 255, 255) editRegistUser = guiCreateEdit(0.401,0.2,0.5,0.1024,"",true,windowRegist) guiEditSetMaxLength(editRegistUser,64) editRegistPass = guiCreateEdit(0.401,0.4,0.5,0.1024,"",true,windowRegist) guiEditSetMaxLength(editRegistPass,64) buttonRegistSubmit = guiCreateButton(0.099,0.6488,0.2005,0.2,"Elfogad",true,windowRegist) buttonRegistToLogin = guiCreateButton(0.349,0.6488,0.2995,0.2,"Bejelentkezes",true,windowRegist) buttonExit = guiCreateButton(0.7005,0.6488,0.2005,0.2,"Kilepes",true,windowRegist) addEventHandler("onClientGUIClick", buttonRegistToLogin, changeRegistToLogin, false) addEventHandler("onClientGUIClick", buttonLoginSubmit, submitLogin, false) addEventHandler("onClientGUIClick", buttonRegistSubmit, submitRegist, false) guiSetVisible(windowRegist, false) end function createPassChangeWindow() local GUIEditor_Label = {} windowPassChange = guiCreateWindow(0.3484,0.3242,0.3,0.2,"Jelszocsere",true) guiWindowSetSizable(windowPassChange,false) GUIEditor_Label[1] = guiCreateLabel(0.1,0.2,0.4453,0.1268,"Uj jelszo:",true,windowPassChange) guiLabelSetColor(GUIEditor_Label[1],255, 255, 255) GUIEditor_Label[2] = guiCreateLabel(0.1,0.4,0.3281,0.0927,"Megerosites:",true,windowPassChange) guiLabelSetColor(GUIEditor_Label[2],255, 255, 255) editPassChangeNew = guiCreateEdit(0.401,0.2,0.5,0.1024,"",true,windowPassChange) guiEditSetMaxLength(editPassChangeNew,64) editPassChangeRe = guiCreateEdit(0.401,0.4,0.5,0.1024,"",true,windowPassChange) guiEditSetMaxLength(editPassChangeRe,64) buttonPassChangeSubmit = guiCreateButton(0.099,0.6488,0.2005,0.2,"Csere",true,windowPassChange) buttonExit = guiCreateButton(0.7005,0.6488,0.2005,0.2,"Kilepes",true,windowPassChange) guiSetVisible(windowPassChange, false) end function changeLoginToRegist(button, state) if button == "left" and state == "up" then guiSetVisible(windowLogin, false) showRegistWindow() end end function changeRegistToLogin(button, state) if button == "left" and state == "up" then guiSetVisible(windowRegist, false) showLoginWindow() end end function exitAuth(button, state) if button == "left" and state == "up" then if windowLogin then guiSetVisible(windowLogin, false) end if windowRegist then guiSetVisible(windowRegist, false) end if windowPassChange then guiSetVisible(windowPassChange, false) end showCursor(false) guiSetInputEnabled(false) triggerServerEvent("onAuthExit", getLocalPlayer()) end end function submitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(editLoginUser) local password = guiGetText(editLoginPass) if string.len(username) == 0 or string.len(password) == 0 then outputChatBox("Mindket mezo kitoltese kotelezo") else guiSetVisible(windowLogin, false) showCursor(false) guiSetInputEnabled(false) triggerServerEvent("onAuthLogin", getLocalPlayer(), username, password) end end end function submitRegist(button, state) if button == "left" and state == "up" then local username = guiGetText(editRegistUser) local password = guiGetText(editRegistPass) if string.len(username) == 0 or string.len(password) == 0 then outputChatBox("Mindket mezo kitoltese kotelezo") elseif string.len(fiusernameeld1) < 4 then outputChatBox("A felhasznalonevnek minimum 4 karakter hosszunak kell lennie") else guiSetVisible(windowRegist, false) destroyElement(windowRegist) showCursor(false) guiSetInputEnabled(false) triggerServerEvent("onAuthRegist", getLocalPlayer(), username, password) end end end function submitPassChange(button, state) if button == "left" and state == "up" then local newpass = guiGetText(editPassChangeNew) local repass = guiGetText(editPassChangeRe) if string.len(newpass) == 0 or string.len(repass) == 0 then outputChatBox("Mindket mezo kitoltese kotelezo") elseif string.len(newpass) < 4 then outputChatBox("Az új jelszónak minimum 4 karakter hosszunak kell lennie") elseif newpass ~= repass then outputChatBox("Az új jelszó és a megerősítés nem egyeznek") else guiSetVisible(windowPassChange, false) showCursor(false) guiSetInputEnabled(false) triggerServerEvent("onAuthPassChange", getLocalPlayer(), newpass) end end end And btw, you have 3 buttons with the same variable, buttonExit. Link to comment
Nonameman Posted July 12, 2011 Author Share Posted July 12, 2011 You can see only one window of the three in the same time, so they can use the same variable, which I can close the shown one with. First, exit function destroyed the window, but I recreated it, and now only hides it, but now I see that it is still not the best, I have to create other checks. Thanks, I'll check the new code! EDIT: It's better to addEventHandler("onClientGUIClick") when I create the GUI? Link to comment
JR10 Posted July 12, 2011 Share Posted July 12, 2011 You are wrong, it's not what's visible and what's not, buttonExit will be this buttonExit = guiCreateButton(0.7005,0.6488,0.2005,0.2,"Kilepes",true,windowPassChange) Yes, right inside the block after the creation. Link to comment
Nonameman Posted July 13, 2011 Author Share Posted July 13, 2011 You are wrong, it's not what's visible and what's not, buttonExit will be this buttonExit = guiCreateButton(0.7005,0.6488,0.2005,0.2,"Kilepes",true,windowPassChange) Yes, right inside the block after the creation. Everything seems to be ok, except the command that would make the password changer window show to the player. Debugscript warning: Bad argument @ 'triggerClientEvent' (line 36) I post the client & server files again, cuz they changed: local authLogin = {} local authRegist = {} local authChange = {} addEventHandler("onClientResourceStart", resourceRoot, function () createAuthWindows() showLoginWindow() end ) function showLoginWindow() if not authLogin.window then outputChatBox("A bejelentkezo rendszer nem mukodik rendesen, kerlek jelentsd a weboldalon") outputChatBox("www."..webSite..".hu") end guiSetVisible(authLogin.window, true) showCursor(true) guiSetInputEnabled(true) end addEvent("onLoginStart", true) addEventHandler("onLoginStart", getRootElement(), showLoginWindow) function showRegistWindow() if not authRegist.window then outputChatBox("A bejelentkezo rendszer nem mukodik rendesen, kerlek jelentsd a weboldalon") outputChatBox("www."..webSite..".hu") end guiSetVisible(authRegist.window, true) showCursor(true) guiSetInputEnabled(true) end addEvent("onRegistStart", true) addEventHandler("onRegistStart", getRootElement(), showRegistWindow) function showPassChangeWindow() if not authChange.window then outputChatBox("Ez a funkcio jelenleg inaktiv, hamarosan vissza lesz allitva") end guiSetVisible(authChange.window, true) showCursor(true) guiSetInputEnabled(true) end addEvent("onPassChangeStart", true) addEventHandler("onPassChangeStart", getRootElement(), showPassChangeWindow) function createAuthWindows() local GUIEditor_Label = {} authLogin.window = guiCreateWindow(0.3484,0.3242,0.3,0.2,"Bejelentkezes",true) guiWindowSetSizable(authLogin.window,false) GUIEditor_Label[1] = guiCreateLabel(0.1,0.2,0.4453,0.1268,"Felhasznalonev:",true,authLogin.window) guiLabelSetColor(GUIEditor_Label[1],255, 255, 255) GUIEditor_Label[2] = guiCreateLabel(0.1,0.4,0.3281,0.0927,"Jelszo:",true,authLogin.window) guiLabelSetColor(GUIEditor_Label[2],255, 255, 255) authLogin.user = guiCreateEdit(0.401,0.2,0.5,0.1024,"",true,authLogin.window) guiEditSetMaxLength(authLogin.user,64) authLogin.pass = guiCreateEdit(0.401,0.4,0.5,0.1024,"",true,authLogin.window) guiEditSetMaxLength(authLogin.pass,64) authLogin.submit = guiCreateButton(0.099,0.6488,0.2005,0.2,"Elfogad",true,authLogin.window) authLogin.toRegist = guiCreateButton(0.349,0.6488,0.2995,0.2,"Regisztracio",true,authLogin.window) authLogin.exit = guiCreateButton(0.7005,0.6488,0.2005,0.2,"Kilepes",true,authLogin.window) guiSetVisible(authLogin.window, false) --- authRegist.window = guiCreateWindow(0.3484,0.3242,0.3,0.2,"Regisztracio",true) guiWindowSetSizable(authRegist.window,false) GUIEditor_Label[1] = guiCreateLabel(0.1,0.2,0.4453,0.1268,"Felhasznalonev:",true,authRegist.window) guiLabelSetColor(GUIEditor_Label[1],255, 255, 255) GUIEditor_Label[2] = guiCreateLabel(0.1,0.4,0.3281,0.0927,"Jelszo:",true,authRegist.window) guiLabelSetColor(GUIEditor_Label[2],255, 255, 255) authRegist.user = guiCreateEdit(0.401,0.2,0.5,0.1024,"",true,authRegist.window) guiEditSetMaxLength(authRegist.user,64) authRegist.pass = guiCreateEdit(0.401,0.4,0.5,0.1024,"",true,authRegist.window) guiEditSetMaxLength(authRegist.pass,64) authRegist.submit = guiCreateButton(0.099,0.6488,0.2005,0.2,"Elfogad",true,authRegist.window) authRegist.toLogin = guiCreateButton(0.349,0.6488,0.2995,0.2,"Bejelentkezes",true,authRegist.window) authRegist.exit = guiCreateButton(0.7005,0.6488,0.2005,0.2,"Kilepes",true,authRegist.window) guiSetVisible(authRegist.window, false) --- authChange.window = guiCreateWindow(0.3484,0.3242,0.3,0.2,"Jelszocsere",true) guiWindowSetSizable(authChange.window,false) GUIEditor_Label[1] = guiCreateLabel(0.1,0.2,0.4453,0.1268,"Uj jelszo:",true,authChange.window) guiLabelSetColor(GUIEditor_Label[1],255, 255, 255) GUIEditor_Label[2] = guiCreateLabel(0.1,0.4,0.3281,0.0927,"Megerosites:",true,authChange.window) guiLabelSetColor(GUIEditor_Label[2],255, 255, 255) authChange.new = guiCreateEdit(0.401,0.2,0.5,0.1024,"",true,authChange.window) guiEditSetMaxLength(authChange.new,64) authChange.re = guiCreateEdit(0.401,0.4,0.5,0.1024,"",true,authChange.window) guiEditSetMaxLength(authChange.re,64) authChange.submit = guiCreateButton(0.099,0.6488,0.2005,0.2,"Csere",true,authChange.window) authChange.exit = guiCreateButton(0.7005,0.6488,0.2005,0.2,"Kilepes",true,authChange.window) guiSetVisible(authChange.window, false) --- addEventHandler("onClientGUIClick", authLogin.submit, submitLogin, false) addEventHandler("onClientGUIClick", authRegist.submit, submitRegist, false) addEventHandler("onClientGUIClick", authChange.submit, submitChange, false) addEventHandler("onClientGUIClick", authLogin.toRegist, changeToRegist, false) addEventHandler("onClientGUIClick", authRegist.toLogin, changeToLogin, false) addEventHandler("onClientGUIClick", authLogin.exit, exitWindows, false) addEventHandler("onClientGUIClick", authRegist.exit, exitWindows, false) addEventHandler("onClientGUIClick", authChange.exit, exitWindows, false) end function submitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(authLogin.user) local password = guiGetText(authLogin.pass) if string.len(username) == 0 or string.len(password) == 0 then outputChatBox("Mindket mezo kitoltese kotelezo") else guiSetVisible(authLogin.window, false) showCursor(false) guiSetInputEnabled(false) triggerServerEvent("onAuthLogin", getLocalPlayer(), username, password) end end end function submitRegist(button, state) if button == "left" and state == "up" then local username = guiGetText(authRegist.user) local password = guiGetText(authRegist.pass) if string.len(username) == 0 or string.len(password) == 0 then outputChatBox("Mindket mezo kitoltese kotelezo") elseif string.len(username) < 4 then outputChatBox("A felhasznalonevnek minimum 4 karakter hosszunak kell lennie") else guiSetVisible(authRegist.window, false) showCursor(false) guiSetInputEnabled(false) triggerServerEvent("onAuthRegist", getLocalPlayer(), username, password) end end end function submitChange(button, state) if button == "left" and state == "up" then local newpass = guiGetText(authChange.new) local repass = guiGetText(authChange.re) if string.len(newpass) == 0 or string.len(repass) == 0 then outputChatBox("Mindket mezo kitoltese kotelezo") elseif string.len(newpass) < 4 then outputChatBox("Az új jelszónak minimum 4 karakter hosszunak kell lennie") elseif newpass ~= repass then outputChatBox("Az új jelszó és a megerősítés nem egyeznek") else guiSetVisible(authChange.window, false) showCursor(false) guiSetInputEnabled(false) triggerServerEvent("onAuthPassChange", getLocalPlayer(), newpass) end end end function changeToRegist(button, state) if button == "left" and state == "up" then guiSetVisible(authLogin.window, false) showRegistWindow() end end function changeToLogin(button, state) if button == "left" and state == "up" then guiSetVisible(authRegist.window, false) showLoginWindow() end end function exitWindows(button, state) if button == "left" and state == "up" then if guiGetVisible(authLogin.window) then guiSetVisible(authLogin.window, false) end if guiGetVisible(authRegist.window) then guiSetVisible(authRegist.window, false) end if guiGetVisible(authChange.window) then guiSetVisible(authChange.window, false) end showCursor(false) guiSetInputEnabled(false) outputChatBox("Bejelentkezes nelkul nem lehet jatszani a szerveren") end end addEvent("onAuthLogin", true) addEventHandler("onAuthLogin", getRootElement(), function (username, password) if getAccount(username, password) then logIn(source, getAccount(username, password), password) outputChatBox("Sikeresen bejelentkeztel", source) spawnPlayer(source, 1959.55, -1714.46, 15) fadeCamera(source, true) setCameraTarget(source, source) else outputChatBox("Nem letezik ilyen felhasznalo, probald ujra vagy regisztralj", source) triggerClientEvent(source, "onLoginStart", getRootElement()) end end ) addEvent("onAuthRegist", true) addEventHandler("onAuthRegist", getRootElement(), function (username, password) if getAccount(username) then outputChatBox("Mar letezik ilyen nevu felhasznalo, jelentkezz be, vagy valassz masik felhasznalonevet", source) triggerClientEvent("onRegistStart", source) else addAccount(username, password) triggerClientEvent(source, "onLoginStart", getRootElement()) outputChatBox("Sikeres regisztracio, most mar bejelentkezhetsz", source) end end ) function passwordChange(playerSource) if isGuestAccount(getPlayerAccount(playerSource)) then outputChatBox("Be kell jelentkezned hogy hasznalhasd ezt a parancsot", source) else triggerClientEvent(source, "onPassChangeStart", getRootElement()) end end addCommandHandler("jelszocsere", passwordChange) addEvent("onAuthPassChange", getRootElement(), function (newpass) setAccountPassword(getPlayerAccount(source), newpass) outputChatBox("Sikeres jelszocsere", source) end ) Link to comment
JR10 Posted July 13, 2011 Share Posted July 13, 2011 function passwordChange(playerSource) if isGuestAccount(getPlayerAccount(playerSource)) then outputChatBox("Be kell jelentkezned hogy hasznalhasd ezt a parancsot", source) else triggerClientEvent(source, "onPassChangeStart", getRootElement()) end end addCommandHandler("jelszocsere", passwordChange) Source is not defined. Try this: function passwordChange(playerSource) if isGuestAccount(getPlayerAccount(playerSource)) then outputChatBox("Be kell jelentkezned hogy hasznalhasd ezt a parancsot", playerSource) else triggerClientEvent(playerSource, "onPassChangeStart", getRootElement()) end end Link to comment
Nonameman Posted July 13, 2011 Author Share Posted July 13, 2011 Thanks, so outputChatBox sent message for all players on the server because its second argument was nil? Link to comment
JR10 Posted July 13, 2011 Share Posted July 13, 2011 It should shows a bad argument @ outputChatBox and yes, it sends it to all players. 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