0 Üye ve 1 Ziyaretçi konuyu incelemekte.
-- ADD EVENT --addEvent ("registerPlayer",true)addEvent ("loginPlayer",true)-- REGISTER --function onRegister(player,username,password) account = addAccount(username,password) if (account) then outputChatBox ("#FFA800[FFS] #C1C1C1You have successfully registered! Username: #FFA800"..username.." #C1C1C1Password: #FFA800"..password.."#C1C1C1.",player,255,255,255,true) local account = getAccount(username,password) if (account) then logIn (player,account,password) triggerClientEvent(player,"successfullyLogin",player) else triggerClientEvent(player,"notRegister",player) end triggerClientEvent(player,"hideRegisterPanel",player) endend addEventHandler ("registerPlayer",root,onRegister)-- LOGIN --function onLogin(player,username,password,checkboxState) local account = getAccount(username,password) if (account) then logIn (player,account,password) triggerClientEvent(player,"successfullyLogin",player) triggerClientEvent(player,"hideLoginPanel",player) triggerClientEvent(player,"saveXML",getRootElement(),username,password,tostring(checkboxState)) else triggerClientEvent(player,"wrongAccount",player) endend addEventHandler ("loginPlayer",root,onLogin)
kodlar clientte
-- GET SCREEN SIZE --local sX,sY = guiGetScreenSize()-- ABBREVIATIONS --lW, lH = 300,300-- LOGIN PANEL --function loginPanel() showChat (false) showPlayerHudComponent ("all", false) showCursor (true) -- BACKGROUND -- background = guiCreateStaticImage (0,0,sX,sY,"img/background.png",false) -- LOGIN PANEL -- loginWindow = guiCreateStaticImage (sX/2-lW/2,sY/2-lH/2,lW,lH,"img/window.png",false,background) guiSetVisible (loginWindow,true) loginHeaderText = guiCreateLabel (0.1,0.1,300,30,"Log In",false,loginWindow) guiLabelSetVerticalAlign (loginHeaderText,"center") guiLabelSetHorizontalAlign (loginHeaderText,"center") guiSetFont (loginHeaderText,"default-bold-small") usernameEdit = guiCreateEdit (20,52,260,35,"Username",false,loginWindow) guiEditSetMaxLength (usernameEdit,21) passwordEdit = guiCreateEdit (20,102,260,35,"Password",false,loginWindow) guiEditSetMaxLength (passwordEdit,21) guiEditSetMasked (passwordEdit,true) rememberCheckbox = guiCreateCheckBox (lW-130,152,110,20,"Remember me!",false,false,loginWindow) guiSetFont (rememberCheckbox,"default-bold-small") loginButton = guiCreateStaticImage (20,187,260,40,"img/button.png",false,loginWindow) guiSetAlpha (loginButton,1) loginLabel = guiCreateLabel (0,0,260,40,"Log in",false,loginButton) guiLabelSetVerticalAlign (loginLabel,"center") guiLabelSetHorizontalAlign (loginLabel,"center") guiSetFont (loginLabel,"default-bold-small") registerButton = guiCreateStaticImage (20,242,260,40,"img/button.png",false,loginWindow) registerLabel = guiCreateLabel (0,0,260,40,"Register",false,registerButton) guiLabelSetVerticalAlign (registerLabel,"center") guiLabelSetHorizontalAlign (registerLabel,"center") guiSetFont (registerLabel,"default-bold-small") -- REGISTER PANEL -- registerWindow = guiCreateStaticImage (sX/2-lW/2,sY/2-lH/2,lW,lH,"img/window.png",false,background) guiSetVisible (registerWindow,false) registerHeaderText = guiCreateLabel (0.1,0.1,300,30,"Register",false,registerWindow) guiLabelSetVerticalAlign (registerHeaderText,"center") guiLabelSetHorizontalAlign (registerHeaderText,"center") guiSetFont (registerHeaderText,"default-bold-small") usernameText = guiCreateLabel (20,42,80,35,"Username",false,registerWindow) guiEditSetReadOnly (usernameText,true) guiSetFont (usernameText,"default-bold-small") usernameREdit = guiCreateEdit (105,42,175,35,"",false,registerWindow) guiEditSetMaxLength (usernameREdit,21) passwordText = guiCreateLabel (20,92,80,35,"Password",false,registerWindow) guiEditSetReadOnly (passwordText,true) guiSetFont (passwordText,"default-bold-small") passwordREdit = guiCreateEdit (105,92,175,35,"",false,registerWindow) guiEditSetMaxLength (passwordREdit,21) guiEditSetMasked (passwordREdit,true) passwordCText = guiCreateLabel (20,142,80,35,"Password",false,registerWindow) guiEditSetReadOnly (passwordCText,true) guiSetFont (passwordCText,"default-bold-small") passwordCREdit = guiCreateEdit (105,142,175,35,"",false,registerWindow) guiEditSetMaxLength (passwordCREdit,21) guiEditSetMasked (passwordCREdit,true) registerRButton = guiCreateStaticImage (20,192,260,40,"img/button.png",false,registerWindow) registerRLabel = guiCreateLabel (0,0,260,40,"Register",false,registerRButton) guiLabelSetVerticalAlign (registerRLabel,"center") guiLabelSetHorizontalAlign (registerRLabel,"center") guiSetFont (registerRLabel,"default-bold-small") loginRButton = guiCreateStaticImage (20,247,260,40,"img/button.png",false,registerWindow) loginRLabel = guiCreateLabel (0,0,260,40,"Log in",false,loginRButton) guiLabelSetVerticalAlign (loginRLabel,"center") guiLabelSetHorizontalAlign (loginRLabel,"center") guiSetFont (loginRLabel,"default-bold-small") -- REMEMBER PLAYER ACCOUNT -- xml = xmlLoadFile("userdata.xml") loadXML()end addEventHandler ("onClientResourceStart",resourceRoot,loginPanel)-- HOVER BUTTON --addEventHandler ("onClientMouseEnter",root,function() if source == loginLabel then guiStaticImageLoadImage ( loginButton, "img/hoverButton.png" ) elseif source == registerLabel then guiStaticImageLoadImage ( registerButton, "img/hoverButton.png" ) elseif source == loginRLabel then guiStaticImageLoadImage ( loginRButton, "img/hoverButton.png" ) elseif source == registerRLabel then guiStaticImageLoadImage ( registerRButton, "img/hoverButton.png" ) endend)-- BUTTON --addEventHandler ("onClientMouseLeave",root,function() if source == loginLabel then guiStaticImageLoadImage ( loginButton, "img/button.png" ) elseif source == registerLabel then guiStaticImageLoadImage ( registerButton, "img/button.png" ) elseif source == loginRLabel then guiStaticImageLoadImage ( loginRButton, "img/button.png" ) elseif source == registerRLabel then guiStaticImageLoadImage ( registerRButton, "img/button.png" ) endend)-- REMEMBER PLAYER ACCOUNT --function loadXML() if not xml then xml = xmlCreateFile("userdata.xml","userdata") usernameChild = xmlCreateChild(xml,"username") passwordChild = xmlCreateChild(xml,"password") checkboxChild = xmlCreateChild(xml,"state") xmlSaveFile(xml) else usernameChild = xmlFindChild(xml,"username",0) passwordChild = xmlFindChild(xml,"password",0) checkboxChild = xmlFindChild(xml,"state",0) end usernameLoad = xmlNodeGetValue(usernameChild) passwordLoad = xmlNodeGetValue(passwordChild) guiSetText (usernameEdit,usernameLoad) guiSetText (passwordEdit,passwordLoad) if xmlNodeGetValue(checkboxChild) then guiCheckBoxSetSelected (rememberCheckbox,true) endendfunction saveXML(username,password,checkboxState) if guiCheckBoxGetSelected (rememberCheckbox) == true then xmlNodeSetValue(usernameChild,username) xmlNodeSetValue(passwordChild,password) xmlNodeSetValue(checkboxChild,tostring(checkboxState)) xmlSaveFile(xml) else xmlNodeSetValue(usernameChild,"") xmlNodeSetValue(passwordChild,"") xmlNodeSetValue(checkboxChild,"") xmlSaveFile(xml) endendaddEvent("saveXML",true)addEventHandler("saveXML",getRootElement(),saveXML)-- LOGIN PANEL/REGISTER PANEL --function redirectPanel() if (source == registerLabel) then if (guiGetVisible (loginWindow) == true ) then guiSetVisible (loginWindow,false) guiSetVisible (registerWindow,true) end end if (source == loginRLabel) then if (guiGetVisible (registerWindow) == true ) then guiSetVisible (registerWindow,false) guiSetVisible (loginWindow,true) end endend addEventHandler ("onClientGUIClick",getRootElement(),redirectPanel)-- REGISTER --function register() if (source == registerRLabel) then local username = guiGetText(usernameREdit) local password = guiGetText (passwordREdit) if (guiGetText(usernameREdit) ~= "") and (guiGetText(passwordREdit) ~= "") and (guiGetText(passwordREdit) == guiGetText(passwordCREdit)) then triggerServerEvent("registerPlayer",getLocalPlayer(),getLocalPlayer(),username,password) elseif (guiGetText(usernameREdit) == "") then outputNotification ("Invalid username.",3) elseif (guiGetText(passwordREdit) == "") or (guiGetText(passwordCREdit) == "") or (guiGetText(passwordREdit) ~= guiGetText(passwordCREdit)) then outputNotification ("Invalid password.",3) end endend addEventHandler ("onClientGUIClick",getRootElement(),register)-- WRONG USERNAME OR PASSWORD --function wrongAccount() outputNotification ("Wrong username and/or password.",3)end addEvent ("wrongAccount",true) addEventHandler ("wrongAccount",getRootElement(),wrongAccount)-- SUCCESFULLY LOGGED IN --function succesAccount() outputNotification ("You successfully logged in.",1)end addEvent ("successfullyLogin",true) addEventHandler ("successfullyLogin",getRootElement(),succesAccount)-- NOT REGISTER --function notRegister() outputNotification ("Please try again with new username or password!",3)end addEvent ("notRegister",true) addEventHandler ("notRegister",getRootElement(),notRegister)-- LOGIN --function login() if (source == loginLabel) then local username = guiGetText(usernameEdit) local password = guiGetText(passwordEdit) if guiGetText(usernameEdit) ~= "" and guiGetText(passwordEdit) ~= "" then triggerServerEvent("loginPlayer",getLocalPlayer(),getLocalPlayer(),username,password) elseif guiGetText(usernameEdit) == "" and guiGetText(passwordEdit) == "" then outputNotification ("Invalid username and password.",3) elseif guiGetText(usernameEdit) == "" then outputNotification ("Invalid username.",3) elseif guiGetText(passwordEdit) == "" then outputNotification ("Invalid password.",3) end endend addEventHandler ("onClientGUIClick",getRootElement(),login)-- CLOSE LOGIN PANEL --function cLoginPanel() guiSetVisible (background,false) showChat (true) showPlayerHudComponent ("all", true) showCursor (false)end addEvent ("hideLoginPanel",true) addEventHandler ("hideLoginPanel",getRootElement(),cLoginPanel) -- CLOSE REGISTER PANEL --function cRegisterPanel() guiSetVisible (background,false) showChat (true) showPlayerHudComponent ("all", true) showCursor (false)end addEvent ("hideRegisterPanel",true) addEventHandler ("hideRegisterPanel",getRootElement(),cRegisterPanel)
-- GET SCREEN SIZE --local sX,sY = guiGetScreenSize()-- ABBREVIATIONS --lW, lH = 300,300-- LOGIN PANEL --function loginPanel() showChat (false) showPlayerHudComponent ("all", false) showCursor (true) -- BACKGROUND -- background = guiCreateStaticImage (0,0,sX,sY,"img/background.png",false) -- LOGIN PANEL -- loginWindow = guiCreateStaticImage (sX/2-lW/2,sY/2-lH/2,lW,lH,"img/window.png",false,background) guiSetVisible (loginWindow,true) loginHeaderText = guiCreateLabel (0.1,0.1,300,30,"Log In",false,loginWindow) guiLabelSetVerticalAlign (loginHeaderText,"center") guiLabelSetHorizontalAlign (loginHeaderText,"center") guiSetFont (loginHeaderText,"default-bold-small") usernameEdit = guiCreateEdit (20,52,260,35,"Username",false,loginWindow) guiEditSetMaxLength (usernameEdit,21) passwordEdit = guiCreateEdit (20,102,260,35,"Password",false,loginWindow) guiEditSetMaxLength (passwordEdit,21) guiEditSetMasked (passwordEdit,true) rememberCheckbox = guiCreateCheckBox (lW-130,152,110,20,"Remember me!",false,false,loginWindow) guiSetFont (rememberCheckbox,"default-bold-small") loginButton = guiCreateStaticImage (20,187,260,40,"img/button.png",false,loginWindow) guiSetAlpha (loginButton,1) loginLabel = guiCreateLabel (0,0,260,40,"Log in",false,loginButton) guiLabelSetVerticalAlign (loginLabel,"center") guiLabelSetHorizontalAlign (loginLabel,"center") guiSetFont (loginLabel,"default-bold-small") registerButton = guiCreateStaticImage (20,242,260,40,"img/button.png",false,loginWindow) registerLabel = guiCreateLabel (0,0,260,40,"Register",false,registerButton) guiLabelSetVerticalAlign (registerLabel,"center") guiLabelSetHorizontalAlign (registerLabel,"center") guiSetFont (registerLabel,"default-bold-small") -- REGISTER PANEL -- registerWindow = guiCreateStaticImage (sX/2-lW/2,sY/2-lH/2,lW,lH,"img/window.png",false,background) guiSetVisible (registerWindow,false) registerHeaderText = guiCreateLabel (0.1,0.1,300,30,"Register",false,registerWindow) guiLabelSetVerticalAlign (registerHeaderText,"center") guiLabelSetHorizontalAlign (registerHeaderText,"center") guiSetFont (registerHeaderText,"default-bold-small") usernameText = guiCreateLabel (20,42,80,35,"Username",false,registerWindow) guiEditSetReadOnly (usernameText,true) guiSetFont (usernameText,"default-bold-small") usernameREdit = guiCreateEdit (105,42,175,35,"",false,registerWindow) guiEditSetMaxLength (usernameREdit,21) passwordText = guiCreateLabel (20,92,80,35,"Password",false,registerWindow) guiEditSetReadOnly (passwordText,true) guiSetFont (passwordText,"default-bold-small") passwordREdit = guiCreateEdit (105,92,175,35,"",false,registerWindow) guiEditSetMaxLength (passwordREdit,21) guiEditSetMasked (passwordREdit,true) passwordCText = guiCreateLabel (20,142,80,35,"Password",false,registerWindow) guiEditSetReadOnly (passwordCText,true) guiSetFont (passwordCText,"default-bold-small") passwordCREdit = guiCreateEdit (105,142,175,35,"",false,registerWindow) guiEditSetMaxLength (passwordCREdit,21) guiEditSetMasked (passwordCREdit,true) registerRButton = guiCreateStaticImage (20,192,260,40,"img/button.png",false,registerWindow) registerRLabel = guiCreateLabel (0,0,260,40,"Register",false,registerRButton) guiLabelSetVerticalAlign (registerRLabel,"center") guiLabelSetHorizontalAlign (registerRLabel,"center") guiSetFont (registerRLabel,"default-bold-small") loginRButton = guiCreateStaticImage (20,247,260,40,"img/button.png",false,registerWindow) loginRLabel = guiCreateLabel (0,0,260,40,"Log in",false,loginRButton) guiLabelSetVerticalAlign (loginRLabel,"center") guiLabelSetHorizontalAlign (loginRLabel,"center") guiSetFont (loginRLabel,"default-bold-small") -- REMEMBER PLAYER ACCOUNT -- xml = xmlLoadFile("userdata.xml") loadXML()end addEventHandler ("onClientResourceStart",resourceRoot,loginPanel)-- HOVER BUTTON --addEventHandler ("onClientMouseEnter",root,function() if source == loginLabel then guiStaticImageLoadImage ( loginButton, "img/hoverButton.png" ) elseif source == registerLabel then guiStaticImageLoadImage ( registerButton, "img/hoverButton.png" ) elseif source == loginRLabel then guiStaticImageLoadImage ( loginRButton, "img/hoverButton.png" ) elseif source == registerRLabel then guiStaticImageLoadImage ( registerRButton, "img/hoverButton.png" ) endend)-- BUTTON --addEventHandler ("onClientMouseLeave",root,function() if source == loginLabel then guiStaticImageLoadImage ( loginButton, "img/button.png" ) elseif source == registerLabel then guiStaticImageLoadImage ( registerButton, "img/button.png" ) elseif source == loginRLabel then guiStaticImageLoadImage ( loginRButton, "img/button.png" ) elseif source == registerRLabel then guiStaticImageLoadImage ( registerRButton, "img/button.png" ) endend)-- REMEMBER PLAYER ACCOUNT --function loadXML() if not xml then xml = xmlCreateFile("userdata.xml","userdata") usernameChild = xmlCreateChild(xml,"username") passwordChild = xmlCreateChild(xml,"password") checkboxChild = xmlCreateChild(xml,"state") xmlSaveFile(xml) else usernameChild = xmlFindChild(xml,"username",0) passwordChild = xmlFindChild(xml,"password",0) checkboxChild = xmlFindChild(xml,"state",0) end usernameLoad = xmlNodeGetValue(usernameChild) passwordLoad = xmlNodeGetValue(passwordChild) guiSetText (usernameEdit,usernameLoad) guiSetText (passwordEdit,passwordLoad) if xmlNodeGetValue(checkboxChild) then guiCheckBoxSetSelected (rememberCheckbox,true) endendfunction saveXML(username,password,checkboxState) if guiCheckBoxGetSelected (rememberCheckbox) == true then xmlNodeSetValue(usernameChild,username) xmlNodeSetValue(passwordChild,password) xmlNodeSetValue(checkboxChild,tostring(checkboxState)) xmlSaveFile(xml) else xmlNodeSetValue(usernameChild,"") xmlNodeSetValue(passwordChild,"") xmlNodeSetValue(checkboxChild,"") xmlSaveFile(xml) endendaddEvent("saveXML",true)addEventHandler("saveXML",getRootElement(),saveXML)-- LOGIN PANEL/REGISTER PANEL --function redirectPanel() if (source == registerLabel) then if (guiGetVisible (loginWindow) == true ) then guiSetVisible (loginWindow,false) guiSetVisible (registerWindow,true) end end if (source == loginRLabel) then if (guiGetVisible (registerWindow) == true ) then guiSetVisible (registerWindow,false) guiSetVisible (loginWindow,true) end endend addEventHandler ("onClientGUIClick",getRootElement(),redirectPanel)-- REGISTER --function register() if (source == registerRLabel) then local username = guiGetText(usernameREdit) local password = guiGetText (passwordREdit) if (guiGetText(usernameREdit) ~= "") and (guiGetText(passwordREdit) ~= "") and (guiGetText(passwordREdit) == guiGetText(passwordCREdit)) then triggerServerEvent("registerPlayer",getLocalPlayer(),getLocalPlayer(),username,password) elseif (guiGetText(usernameREdit) == "") then outputNotification ("Invalid username.",3) elseif (guiGetText(passwordREdit) == "") or (guiGetText(passwordCREdit) == "") or (guiGetText(passwordREdit) ~= guiGetText(passwordCREdit)) then outputNotification ("Invalid password.",3) end endend addEventHandler ("onClientGUIClick",getRootElement(),register)-- WRONG USERNAME OR PASSWORD --function wrongAccount() outputNotification ("Wrong username and/or password.",3)end addEvent ("wrongAccount",true) addEventHandler ("wrongAccount",getRootElement(),wrongAccount)-- SUCCESFULLY LOGGED IN --function succesAccount() outputNotification ("You successfully logged in.",1)end addEvent ("successfullyLogin",true) addEventHandler ("successfullyLogin",getRootElement(),succesAccount)-- NOT REGISTER --function notRegister() outputNotification ("Please try again with new username or password!",3)end addEvent ("notRegister",true) addEventHandler ("notRegister",getRootElement(),notRegister)-- LOGIN --function login() if (source == loginLabel) then local username = guiGetText(usernameEdit) local password = guiGetText(passwordEdit) if guiGetText(usernameEdit) ~= "" and guiGetText(passwordEdit) ~= "" then triggerServerEvent("loginPlayer",getLocalPlayer(),getLocalPlayer(),username,password) elseif guiGetText(usernameEdit) == "" and guiGetText(passwordEdit) == "" then outputNotification ("Invalid username and password.",3) elseif guiGetText(usernameEdit) == "" then outputNotification ("Invalid username.",3) elseif guiGetText(passwordEdit) == "" then outputNotification ("Invalid password.",3) end endend addEventHandler ("onClientGUIClick",getRootElement(),login)-- CLOSE LOGIN PANEL --function cLoginPanel() guiSetVisible (background,false) showChat (true) showPlayerHudComponent ("all", false) showCursor (false)end addEvent ("hideLoginPanel",true) addEventHandler ("hideLoginPanel",getRootElement(),cLoginPanel) -- CLOSE REGISTER PANEL --function cRegisterPanel() guiSetVisible (background,false) showChat (true) showPlayerHudComponent ("all", false) showCursor (false)end addEvent ("hideRegisterPanel",true) addEventHandler ("hideRegisterPanel",getRootElement(),cRegisterPanel)
bu panele yetki verdinmi ?