Blackmau5 Posted March 22, 2013 Share Posted March 22, 2013 wrote a script to log on the server and added script registration, but the script registration error! here's the script: login_panel_client.lua ------------------------------------- -----------| Авторизация |----------- ------------------------------------- blackLoginScreen = true -- Установите значение 'true' для того что-бы активировать чёрный экран во время активного окна авторизации . removeBlackScreenTime = 4 -- Установите максимальное время чёрного экрана после закрытия диалогового окна авторизации (экран плавно стаёт прозрачный , по истечению времени игрок будет активным и сможет выполнять сценарий игры) enableKickPlayer = true -- Установите значение 'true' для того что-бы выкинуть игрока из сервера если он превысил максимальное количество попыток при неправильном вводе логина и/или пароле . maxLoginAttempts = 5 -- Установите максимальное количество попыток неправильного ввода логина и/или пароля после чего он будет выкинутый из сервера . disallowLogout = false -- Set whether to show the userpanel to the players if they log out of their accounts. ---------------------------------- -- Текст который отображаеться слева в информационном окне при авторизации - Для переноса текста на следующую строчку используйте комбинацию '\n' (Первая строка \nВторая строка) если отступить текст от '\n' он будет так-же отступлён и в информационном окне . infoText = "|--- Обновления \n| |--- Автомобили \n| |--- Audi R8 \n| |--- BMW 740i \n| |--- Ferrari R1 \n| \n|---" infoText = "|--- Статус сервера \n| |--- MTA:SA Server 1.3.1 rev.5174 \n| |---- Альфа версия (Тестирование) \n| \n| \n|--- Информационное окно \n| |--- О Сервере \n| |--- CPU : AMD Athlon™ II x2 255 Processor 3.10 GHz \n| |--- RAM : SDRAM x2 DDR3 1.333 MHz 4.096 M/Bute \n| |--- AMD Athlon™ II x2 255 Processor 3.10 GHz \n| |--- OS Windows 7 x64 rev.7600 [Максимальная] \n| \n| \n|--- Обновления \n| |--- Автомобили \n| | |--- Audi R8 \n| | |--- BMW 740i \n| | |--- Ferrari F1 \n| | \n| |--- Оружие \n| | |--- Стандартное \n| | |--- Стандартное \n| | |--- Стандартное \n| | \n| |--- Скины \n| |--- Стандартное \n| |--- Стандартное \n| |--- Стандартное " -- Screen and GUI window sizes screenWidth,screenHeight = guiGetScreenSize() mainWidth,mainHeight = 800,600 regWidth,regHeight = 290,182 -- Generate the XML file name function getServerName() triggerServerEvent("onClientLoginLoaded",getLocalPlayer()) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getServerName) function setXmlFileName(sName) xmlFileName = tostring("login_"..sName..".xml") loginPanel() end addEvent("onGetServerData",true) addEventHandler("onGetServerData",getRootElement(),setXmlFileName) ---------------------------------- addEvent("onRequestIncreaseAttempts",true) addEvent("onRequestDisplayPanel",true) function loginPanel() -- Check if autologin is enabled - If yes, then log the player in, else create and show the userpanel local xmlFile = xmlLoadFile(xmlFileName) if xmlFile then status = xmlNodeGetAttribute(xmlFile,"autologin") if (status == "true") then local username = tostring(xmlNodeGetAttribute(xmlFile,"username")) local password = tostring(xmlNodeGetAttribute(xmlFile,"password")) if not (username == "") and not (password == "") then triggerServerEvent("onRequestAutologin",getLocalPlayer(),username,password) end else if blackLoginScreen == true then fadeCamera(false,0,0,0,0) end ------------------------------------------------------ -----| Авторизация |----- ------------------------------------------------------ mainWindow = guiCreateWindow(screenWidth/2-mainWidth/2,screenHeight/2-mainHeight/2,mainWidth,mainHeight,"Авторизация",false) guiWindowSetSizable(mainWindow,false) --guiCreateStaticImage(11,29,560,558,"login_panel_logo.png",false,mainWindow) mInfo = guiCreateMemo(11,29,560,558,infoText,false,mainWindow) guiMemoSetReadOnly(mInfo,true) lblUsername = guiCreateLabel(606,35,158,14,"Логин:",false,mainWindow) guiLabelSetColor(lblUsername,0,85,255) guiLabelSetVerticalAlign(lblUsername,"center") guiLabelSetHorizontalAlign(lblUsername,"center",false) guiSetFont(lblUsername,"default-bold-small") editUsername = guiCreateEdit(581,57,208,25,"",false,mainWindow) guiEditSetMaxLength(editUsername,30) lblPassword = guiCreateLabel(606,88,158,14,"Пароль:",false,mainWindow) guiLabelSetColor(lblPassword,0,85,255) guiLabelSetVerticalAlign(lblPassword,"center") guiLabelSetHorizontalAlign(lblPassword,"center",false) guiSetFont(lblPassword,"default-bold-small") editPassword = guiCreateEdit(581,110,208,25,"",false,mainWindow) guiEditSetMaxLength(editPassword,30) guiEditSetMasked(editPassword,true) btnToggleRegister = guiCreateButton(581,153,123,25,"Регистрация",false,mainWindow) guiSetFont(btnToggleRegister,"default-bold-small") btnLogin = guiCreateButton(709,153,80,25,"Войти",false,mainWindow) guiSetFont(btnLogin,"default-bold-small") btnPlayAsGuest = guiCreateButton(581,549,208,38,"Авторизоваться как гость",false,mainWindow) guiSetFont(btnPlayAsGuest,"default-bold-small") ------------------------------------------------------ -----| Регистрация |----- ------------------------------------------------------ registerWindow = guiCreateWindow(screenWidth/2-regWidth/2,screenHeight/2-regHeight/2,regWidth,regHeight,"Регистрация",false) guiWindowSetSizable(registerWindow,false) --lblRegister = guiCreateStaticImage(11,29,128,128,"login_panel_logo.png",false,registerWindow) guiLabelSetColor(lblRegister,0,85,255) guiLabelSetVerticalAlign(lblRegister,"center") guiLabelSetHorizontalAlign(lblRegister,"center",false) guiSetFont(lblRegister,"default-bold-small") lblRUsername = guiCreateLabel(11,33,50,14,"Логин:",false,registerWindow) guiLabelSetColor(lblRUsername,0,85,255) guiLabelSetVerticalAlign(lblRUsername,"center") guiLabelSetHorizontalAlign(lblRUsername,"center",false) guiSetFont(lblRUsername,"default-bold-small") editRegistrationUsername = guiCreateEdit(71,29,208,25,"",false,registerWindow) lblRPassword = guiCreateLabel(11,78,50,14,"Пароль:",false,registerWindow) guiLabelSetColor(lblRPassword,0,85,255) guiLabelSetVerticalAlign(lblRPassword,"center") guiLabelSetHorizontalAlign(lblRPassword,"center",false) guiSetFont(lblRPassword,"default-bold-small") editRegistrationPassword = guiCreateEdit(71,74,208,25,"",false,registerWindow) guiEditSetMasked(editRegistrationPassword,true) lblRepeatPassword = guiCreateLabel(11,113,50,14,"Ещё раз:",false,registerWindow) guiLabelSetColor(lblRepeatPassword,0,85,255) guiLabelSetVerticalAlign(lblRepeatPassword,"center") guiLabelSetHorizontalAlign(lblRepeatPassword,"center",false) guiSetFont(lblRepeatPassword,"default-bold-small") editRegistrationRepeatPassword = guiCreateEdit(71,109,208,25,"",false,registerWindow) guiEditSetMasked(editRegistrationRepeatPassword,true) btnConfirmRegistration = guiCreateButton(11,144,163,25,"Зарегистрироваться",false,registerWindow) guiSetFont(btnConfirmRegistration,"default-bold-small") btnCancel = guiCreateButton(179,144,100,25,"Отмена",false,registerWindow) guiSetFont(btnCancel,"default-bold-small") guiSetVisible(mainWindow, true) guiSetVisible(registerWindow, false) guiSetInputEnabled(true) showCursor(true) addEventHandler("onClientGUIClick",btnLogin,onClickLogin) addEventHandler("onClientGUIClick",btnToggleRegister,onClickRegisterToggle) addEventHandler("onClientGUIClick",btnPlayAsGuest,onClickGuest) addEventHandler("onClientGUIClick",btnConfirmRegistration,onClickRegisterConfirm) addEventHandler("onClientGUIClick",btnCancel,onClickCancel) addEventHandler("onRequestIncreaseAttempts",getRootElement(),increaseAttempts) attemptedLogins = 0 end xmlUnloadFile(xmlFile) else xmlFileHandler(true) end addEventHandler("onRequestDisplayPanel",getRootElement(),logoutHandler) end --addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),loginPanel) -- Disable autologin function removeAutoLogin() local xmlFile = xmlLoadFile(xmlFileName) if xmlFile then local status = xmlNodeGetAttribute(xmlFile,"autologin") if status == "true" then xmlNodeSetAttribute(xmlFile,"autologin","false") outputChatBox("#0000FF* #FFFFFFAuto-login is now #FF0000DISABLED#FFFFFF!",255,255,255,true) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) else outputChatBox("#0000FF* #FFFFFFAuto-login is already #FF0000DISABLED#FFFFFF!",255,255,255,true) xmlUnloadFile(xmlFile) end end end addCommandHandler("disableauto", removeAutoLogin) -- Enable autologin function addAutoLogin() local xmlFile = xmlLoadFile(xmlFileName) if xmlFile then local status = xmlNodeGetAttribute(xmlFile,"autologin") if status == "false" then xmlNodeSetAttribute(xmlFile,"autologin","true") outputChatBox("#0000FF* #FFFFFFAuto-login is now #00FF00ENABLED#FFFFFF! You will be automatically logged in every time you join the server.",255,255,255,true) setTimer(outputChatBox,1000,1,"#0000FF* #FFFFFFTo #FF0000DISABLE#FFFFFF auto-login, use #ABCDEF/disableauto#FFFFFF!",255,255,255,true) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) else outputChatBox("#0000FF* #FFFFFFAuto-login is already #00FF00ENABLED#FFFFFF!",255,255,255,true) xmlUnloadFile(xmlFile) end end end addCommandHandler("enableauto", addAutoLogin) -- LOGIN PLAYER function onClickLogin(button,state) if(button == "left" and state == "up") then if (source == btnLogin) then username = guiGetText(editUsername) password = guiGetText(editPassword) triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password,enableKickPlayer,attemptedLogins,maxLoginAttempts) xmlFileHandler() Link to comment
K4stic Posted March 22, 2013 Share Posted March 22, 2013 add it to Admin group in acl.xml Link to comment
Blackmau5 Posted March 22, 2013 Author Share Posted March 22, 2013 (edited) Help ! no disconnect player ! code login_panel_server.lua -- Login handling function loginPlayer(username,password,enableKickPlayer,attemptedLogins,maxLoginAttempts) if not (username == "") then if not (password == "") then local account = getAccount ( username, password ) if ( account ~= false ) then logIn (source, account, password) outputChatBox ("#0000FF* #FFFFFFYou have sucessfully logged in!",source,255,255,255,true) setTimer(outputChatBox,700,1,"#0000FF* #FFFFFFTo enable auto-login, use #ABCDEF/enableauto#FFFFFF!",source,255,255,255,true) triggerClientEvent (source,"hideLoginWindow",getRootElement()) else if enableKickPlayer == true then if (attemptedLogins >= maxLoginAttempts-1) then outputChatBox ("#0000FF* #FFFFFFError! Wrong username and/or password!",source,255,255,255,true) setTimer(outputChatBox,500,1,"#0000FF* #FFFFFFWarning! Maximum login attempts reached! [#008AFF"..attemptedLogins+1 .."/"..maxLoginAttempts.."#FFFFFF]",source,255,255,255,true) setTimer(outputChatBox,1000,1,"#0000FF* #FFFFFFYou will be kicked in #008AFF5 seconds#FFFFFF!",source,255,255,255,true) setTimer(kickPlayer,5000,1,source,"Failed to login") else outputChatBox ("#0000FF* #FFFFFFError! Wrong username and/or password!",source,255,255,255,true) setTimer(outputChatBox,500,1,"#0000FF* #FFFFFFLogin attempts: [#008AFF"..attemptedLogins+1 .."/"..maxLoginAttempts.."#FFFFFF]",source,255,255,255,true) triggerClientEvent(source,"onRequestIncreaseAttempts",source) end else outputChatBox ("#0000FF* #FFFFFFError! Wrong username and/or password!",source,255,255,255,true) end end else outputChatBox ("#0000FF* #FFFFFFError! Please enter your password!",source,255,255,255,true) end else outputChatBox ("#0000FF* #FFFFFFError! Please enter your username!",source,255,255,255,true) end end Screen server "Error Code Disconnect Player" : help please ! Edited March 23, 2013 by Guest Link to comment
Castillo Posted March 22, 2013 Share Posted March 22, 2013 That error is old, the line 18 is fine. Link to comment
Blackmau5 Posted March 23, 2013 Author Share Posted March 23, 2013 error code line 18 ! I do not know the correct script ! line 18 : setTimer(kickPlayer,5000,1,source,"Failed to login") Please tell me the code "Disconnect" and "Close Client" ))) Help ! Link to comment
PaiN^ Posted March 23, 2013 Share Posted March 23, 2013 ?!! The line you posted is totally correct ! It have to be something else 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