el_motoblock Posted November 29, 2012 Share Posted November 29, 2012 local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function createLoginWindow() windowLogin = guiCreateWindow(498, 296, 353, 194, ".\"{SMILIES_PATH}/icon_razz.gif\" alt=\"\" title=\"Razz\" />lease Log In or Register:.", false) guiWindowSetSizable(windowLogin, false) guiSetAlpha(windowLogin, 1.00) guiSetProperty(windowLogin, "CaptionColour", "FF23CC0C") labelLogin = guiCreateLabel(12, 29, 121, 29, "Login: (22 max)", false, windowLogin) guiLabelSetVerticalAlign(labelLogin, "center") editUsername = guiCreateEdit(143, 29, 198, 32, "", false, windowLogin) guiEditSetMaxLength(editUsername, 22) labelPassword = guiCreateLabel(10, 70, 122, 29, "Password: (15 max)", false, windowLogin) guiLabelSetVerticalAlign(labelPassword, "center") editPassword = guiCreateEdit(142, 70, 198, 32, "", false, windowLogin) guiEditSetMasked(editPassword, true) guiEditSetMaxLength(editPassword, 22) buttonGetNick = guiCreateButton(226, 143, 114, 41, "Get Nickname", false, windowLogin) guiSetProperty(buttonGetNick, "NormalTextColour", "FFAAAAAA") buttonLogin = guiCreateButton(10, 143, 84, 41, "Log In", false, windowLogin) guiSetFont(buttonLogin, "default-bold-small") guiSetProperty(buttonLogin, "NormalTextColour", "FF23CC0C") buttonRegister = guiCreateButton(104, 143, 114, 41, "Register", false, windowLogin) guiSetProperty(buttonRegister, "NormalTextColour", "FFAAAAAA") addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false) addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false) end function addLabelOnClick (state) if state == "up" then setTimer ( guiSetText, 1000, 1, editUsername, tostring(playerName) ) end end addEventHandler("onClientGUIClick", buttonGetNick, clientSubmitRegister, false) function resourceStart() createLoginWindow() if (windowLogin ~= nil) then guiSetVisible(windowLogin, true) else outputChatBox("An error has occurred.") end showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Enter username and password.") end end end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Please enter username and password.") end end end function clientSubmitNN() guiSetText(editUsername, tostring(getPlayerName(localPlayer))) end function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(windowLogin, false) showCursor(false) end function hidePasswordWindow() guiSetInputEnabled(false) guiSetVisible(windowChangepw, false) showCursor(false) end function unknownError() guiSetText(labelInfo, "Error: Unknown error has occured.") end function loginWrong() guiSetText(labelInfo, "Error: Wrong username and/or password.") end function registerTaken() guiSetText(labelInfo, "Error: This username is allready taken.") end addEvent("hidePasswordWindow", true) addEvent("hideLoginWindow", true) addEvent("unknownError", true) addEvent("loginWrong", true) addEvent("registerTaken", true) addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) addEventHandler("unknownError", getRootElement(), unknownError) addEventHandler("loginWrong", getRootElement(), loginWrong) addEventHandler("registerTaken", getRootElement(), registerTaken) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart) --Русский язык Link to comment
Kenix Posted November 29, 2012 Share Posted November 29, 2012 Ты не добавил к функции addLabelOnClick обработчик события ( 'onClientGUIClick' ). Link to comment
Other Languages Moderators Disinterpreter Posted November 29, 2012 Other Languages Moderators Share Posted November 29, 2012 local localPlayer = getLocalPlayer() имеет смысл? Link to comment
Kenix Posted November 29, 2012 Share Posted November 29, 2012 Нет, она уже определена, это предопределенная переменная. Вот список предопределенных переменных на данный момент: https://forum.multitheftauto.com/viewtop ... dc1b106b6a Link to comment
el_motoblock Posted November 30, 2012 Author Share Posted November 30, 2012 Ты не добавил к функции addLabelOnClick обработчик события ( 'onClientGUIClick' ). а не понял вот: local localPlayer = getLocalPlayer() local playerName = getPlayerName(localPlayer) function createLoginWindow() windowLogin = guiCreateWindow(498, 296, 353, 194, ".\"{SMILIES_PATH}/icon_razz.gif\" alt=\"\" title=\"Razz\" />lease Log In or Register:.", false) guiWindowSetSizable(windowLogin, false) guiSetAlpha(windowLogin, 1.00) guiSetProperty(windowLogin, "CaptionColour", "FF23CC0C") labelLogin = guiCreateLabel(12, 29, 121, 29, "Login: (22 max)", false, windowLogin) guiLabelSetVerticalAlign(labelLogin, "center") editUsername = guiCreateEdit(143, 29, 198, 32, "", false, windowLogin) guiEditSetMaxLength(editUsername, 22) labelPassword = guiCreateLabel(10, 70, 122, 29, "Password: (15 max)", false, windowLogin) guiLabelSetVerticalAlign(labelPassword, "center") editPassword = guiCreateEdit(142, 70, 198, 32, "", false, windowLogin) guiEditSetMasked(editPassword, true) guiEditSetMaxLength(editPassword, 22) buttonGetNick = guiCreateButton(226, 143, 114, 41, "Get Nickname", false, windowLogin) guiSetProperty(buttonGetNick, "NormalTextColour", "FFAAAAAA") buttonLogin = guiCreateButton(10, 143, 84, 41, "Log In", false, windowLogin) guiSetFont(buttonLogin, "default-bold-small") guiSetProperty(buttonLogin, "NormalTextColour", "FF23CC0C") buttonRegister = guiCreateButton(104, 143, 114, 41, "Register", false, windowLogin) guiSetProperty(buttonRegister, "NormalTextColour", "FFAAAAAA") --Полоска ошибок labelInfo = guiCreateLabel(13, 113, 338, 20, "", false, windowLogin) guiSetFont(labelInfo, "default-small") guiLabelSetColor(labelInfo, 204, 17, 12) guiLabelSetVerticalAlign(labelInfo, "center") addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false) addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false) addEventHandler("onClientGUIClick", buttonGetNick, addLabelOnClick, false) end function addLabelOnClick (button, state) if button == "left" and state == "up" then setTimer ( guiSetText, 1000, 1, editUsername, tostring(playerName) ) end end function resourceStart() createLoginWindow() if (windowLogin ~= nil) then guiSetVisible(windowLogin, true) else outputChatBox("An error has occurred.") end showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Enter username and password.") end end end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Please enter username and password.") end end end function clientSubmitNN() guiSetText(editUsername, tostring(getPlayerName(localPlayer))) end function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(windowLogin, false) showCursor(false) end function hidePasswordWindow() guiSetInputEnabled(false) guiSetVisible(windowChangepw, false) showCursor(false) end function unknownError() guiSetText(labelInfo, "Error: Unknown error has occured.") end function loginWrong() guiSetText(labelInfo, "Error: Wrong username and/or password.") end function registerTaken() guiSetText(labelInfo, "Error: This username is allready taken.") end addEvent("hidePasswordWindow", true) addEvent("hideLoginWindow", true) addEvent("unknownError", true) addEvent("loginWrong", true) addEvent("registerTaken", true) addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) addEventHandler("unknownError", getRootElement(), unknownError) addEventHandler("loginWrong", getRootElement(), loginWrong) addEventHandler("registerTaken", getRootElement(), registerTaken) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart) --Русский язык Link to comment
el_motoblock Posted November 30, 2012 Author Share Posted November 30, 2012 20:attempt to call global 'register' (a nil value). Дебагскрипт ругается когда регистрируюсь с гуи Вот серверный скрипт: function loginHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then if (logIn(player, account, password) == true) then triggerClientEvent (player, "hideLoginWindow", getRootElement()) else triggerClientEvent (player, "unknownError", getRootElement()) end else triggerClientEvent (player, "loginWrong", getRootElement()) end end function registerHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then triggerClientEvent(player, "registerTaken", getRootElement()) else account = addAccount(username, password) if (register(player, account, password) == true) then triggerClientEvent(player, "hideLoginWindow", getRootElement()) else triggerClientEvent(player, "unknownError", getRootElement()) end end end addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) ---русский язык И как сделать что пока окно логина не действовали кнопки чата Link to comment
Kenix Posted November 30, 2012 Share Posted November 30, 2012 20:attempt to call global 'register' (a nil value).Дебагскрипт ругается когда регистрируюсь с гуи Вот серверный скрипт: function loginHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then if (logIn(player, account, password) == true) then triggerClientEvent (player, "hideLoginWindow", getRootElement()) else triggerClientEvent (player, "unknownError", getRootElement()) end else triggerClientEvent (player, "loginWrong", getRootElement()) end end function registerHandler(player, username, password) local account = getAccount(username, password) if (account ~= false) then triggerClientEvent(player, "registerTaken", getRootElement()) else account = addAccount(username, password) if (register(player, account, password) == true) then triggerClientEvent(player, "hideLoginWindow", getRootElement()) else triggerClientEvent(player, "unknownError", getRootElement()) end end end addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, registerHandler) ---русский язык Функция register не определена. И как сделать что пока окно логина не действовали кнопки чата https://wiki.multitheftauto.com/wiki/GuiSetInputMode 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