Jump to content

problem with login panel


taxi

Recommended Posts

hey guys I am a newbie and this script is my first i hope none take my script and list it for him :oops:

i tried to make it work all day long but something is wronge i seem to never figure this out at all :shock: !!!!

BTW i am arabic so pls help me...

this is the client_side

blackLoginScreen = true 
 
enableKickPlayer = false
 
disallowLogout = false
 
removeBlackScreenTime = 6
 
maxLoginAttempts = 5
 
--------------XML-------
 
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
----------------------WINDOW
GUIEditor = {
 
    label = {},
 
    button = {},
 
    edit = {},
 
    window = {},
 
}
mainWindow = guiCreateWindow(186, 196, 378, 154, "login panel by: TAXI v1.0", false)
guiWindowSetSizable(mainWindow, false)
 
guiSetAlpha(mainWindow, 1.00)
 
guiSetProperty(mainWindow, "CaptionColour", "FFFF8A00")
 
 
 
btnTaxi = guiCreateButton(153, 41, 74, 49, "TAXI", false, mainWindow)
 
guiSetFont(btnTaxi, "sa-header")
 
guiSetProperty(btnTaxi, "NormalTextColour", "FFFF8A00")
 
 
editUsername = guiCreateEdit(10, 61, 139, 23, "", false, mainWindow)
 
guiEditSetMaxLength(editUsername, 32)
 
 
editPassword = guiCreateEdit(229, 61, 139, 23, "", false, mainWindow)
 
guiEditSetMasked(editPassword, true)
 
guiEditSetMaxLength(editPassword, 32)
 
 
lblUsername = guiCreateLabel(15, 40, 134, 15, "username: :اسم الحساب", false, mainWindow)
 
guiLabelSetColor(lblUsername, 255, 222, 0)
 
 
lblPassword = guiCreateLabel(234, 41, 129, 15, "password:  :كلمت السر", false, mainWindow)
 
guiLabelSetColor(lblPassword, 0, 221, 255)
 
 
btnPlayAsGuest = guiCreateButton(151, 96, 70, 48, "| زائر |", false, mainWindow)
 
guiSetProperty(btnPlayAsGuest, "NormalTextColour", "FFFF0000")
 
 
 
btnLogin = guiCreateButton(10, 96, 137, 48, "login |تسجيل الدخول", false, mainWindow)
 
guiSetProperty(btnLogin, "NormalTextColour", "FF00FF0B")
 
 
btnToggleRegister = guiCreateButton(225, 96, 144, 49, "register |التسجيل", false, mainWindow)
 
guiSetProperty(btnToggleRegister, "NormalTextColour", "FF0011FF")
 
 
 
registerWindow = guiCreateWindow(252, 118, 271, 317, "Register Panel By:Taxi v1.0", false)
guiWindowSetSizable(registerWindow, false)
 
guiSetAlpha(registerWindow, 1.00)
 
guiSetProperty(registerWindow, "CaptionColour", "FFFF6600")
 
 
 
editRegistrationUsername = guiCreateEdit(57, 108, 170, 27, "", false, registerWindow)
 
guiEditSetMasked(editRegistrationUsername, true)
 
guiEditSetMaxLength(editRegistrationUsername, 30)
 
 
editRegistrationPassword = guiCreateEdit(57, 166, 170, 27, "", false, registerWindow)
 
guiEditSetMasked(editRegistrationPassword, true)
guiEditSetMaxLength(editRegistrationPassword, 30)
 
 
editRegistrationRepeatPassword = guiCreateEdit(57, 222, 170, 27, "", false, registerWindow)
 
guiEditSetMasked(editRegistrationRepeatPassword, true)
 
guiEditSetMaxLength(editRegistrationRepeatPassword, 30)
 
 
lblRegister = guiCreateLabel(5, 22, 273, 52, "REGISTER!", false, registerWindow)
 
guiSetFont(lblRegister, "sa-gothic")
 
guiLabelSetColor(lblRegister, 255, 102, 0)
 
 
lblRUsername = guiCreateLabel(73, 93, 137, 15, "Username: :اسم الحساب", false, registerWindow)
 
guiLabelSetColor(lblRUsername, 17, 255, 0)
 
 
lblRPassword = guiCreateLabel(71, 151, 136, 15, "Password: :كلمت السر", false, registerWindow)
 
guiLabelSetColor(lblRPassword, 255, 0, 0)
 
 
lblRepeatPassword = guiCreateLabel(47, 203, 189, 15, "Repeat Password: :إعادة كلمة السر", false, registerWindow)
guiLabelSetColor(lblRepeatPassword, 165, 0, 227)
 
 
btnConfirmRegistration = guiCreateButton(10, 257, 110, 50, "Register | التسجيل", false, registerWindow)
guiSetProperty(btnConfirmRegistration, "NormalTextColour", "FF00C5E3")
 
 
btnCancel = guiCreateButton(151, 257, 110, 50, "Cancel | إلغاء", false, registerWindow)
 
guiSetProperty(btnCancel, "NormalTextColour", "FF0025E3")
 
 
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()
        end
    end
end
 
 
 
------Register_player
function onClickRegisterConfirm(button,state)
    if(button == "left" and state == "up") then
       
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...