Jump to content

I need help


Dimos7

Recommended Posts

Client Side:

blackLoginScreen = true 
enableKick = true 
disallowLogout = false 
removeBlackScrenTime = 4 
maxLoginAttempts = 5 
  
local localPlayer = getLocalPlayer() 
local playerName = getPlayerName(localPlayer) 
  
function createPasswordWindow() 
GUIEditor_Button = {} 
windowpw = guiCreateWindow(254, 137, 303, 307, "Change Password", false) 
guiSetAlpha(windowpw, 1) 
guiWindowSetSizable(windowpw, false) 
guiWindowSetMovable(windowpw, false) 
username_lpw = guiCreateLabel (7, 75, 289, 24, "                          Old Password:", false, windowpw) 
guiSetAlpha(username_lpw, 1) 
guiLabelSetVerticalAlign(username_lpw, "top") 
guiLabelSetHorizontalAlign(username_lpw, "left") 
usernamepw = guiCreateEdit(9, 100, 285, 25, "", false, windowpw) 
guiSetAlpha(usernamepw, 1) 
guiEditSetMasked(usernamepw, true) 
guiEditSetMaxLength(usernamepw, 30) 
password_lpw = guiCreateLabel(7, 140, 289, 24, "                          New Password:", false, windowpw) 
guiSetAlpha(password_lpw, 1) 
guiLabelSetVerticalAlign(password_lpw, "top") 
guiLabelSetHorizontalAlign(password_lpw, "left") 
passwordpw = guiCreateEdit(9, 168, 285, 25, "", false, windowpw) 
guiSetAlpha(passwordpw, 1) 
guiEditSetMasked(passwordpw, true) 
guiEditSetMaxLength(passwordpw, 30) 
GUIEditor_Button[1] = guiCreateButton(153, 245, 135, 53, "Okey", false, windowpw) 
guiSetAlpha(GUIEditor_Button[1], 1) 
guiSetVisible(windowpw, false) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1], onClientSubmitChangepw, false) 
end 
  
function createLoginWindow() 
GUIEditor_Button = {} 
window = guiCreateWindow(254, 137, 303, 307, "Login Panel", false) 
guiSetAlpha(window, 1) 
guiWindowSetMovable(window, false) 
guiWindowSetSizable(window, false) 
username_l = guiCreateLabel(7, 75, 289, 24, "                            Username:", false, window) 
guiSetAlpha(username_l, 1) 
guiLabelSetVerticalAlign(username_l, "top") 
guiLabelSetHorizontalAlign(username_l, "left") 
username = guiCreateEdit(9, 100, 285, 25, "", false, window) 
guiSetAlpha(username, 1) 
password_l = guiCreateLabel(7, 140, 289, 24, "                            Password:", false, window) 
guiSetAlpha(password_l, 1) 
guiLabelSetVerticalAlign(password_l, "top") 
guiLabelSetHorizontalAlign(password_l, "left") 
password = guiCreateEdit(9, 168, 285, 25, "", false, window) 
guiSetAlpha(password, 1) 
guiEditSetMasked(password, true) 
guiEditSetMaxLength(password, 30) 
GUIEditor_Button[1] = guiCreateButton(9, 245, 143, 53, "Login", false, window) 
guiSetAlpha(GUIEditor_Button[1], 1) 
GUIEditor_Button[2] = guiCreateButton(153, 245, 143, 53, "Register", false, window) 
guiSetAlpha(GUIEditor_Button[2], 1) 
addEventHandler("onClientGUIClick", GUIEditor_Button[1], onClientSubmitLogin) 
addEventHandler("onClientGUIClick", GUIEditor_Button[2], onClientSubmitRegister) 
end 
  
function resourceStart() 
    createLoginWindow() 
    if (window ~= nil) then 
        guiSetVisible(window, true) 
    else 
       outputChatBox("An error has occurred.") 
    end 
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
  
  
function changePw() 
    createPasswordWindow() 
    guiSetVisible(windowpw, true) 
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
  
  
function onClientSubmitLogin(button, state) 
    if button == "left" and state == "up" then 
       local username = guiGetText(username) 
       local password = guiGetText(password) 
       if username and password then 
          triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) 
       else 
          guiSetText(labelInfo, "Enter username and password.") 
       end 
    end 
end 
  
  
function onClientSubmitRegister(button, state) 
    if button == "left" and state == "up" then 
       local username = guiGetText(username) 
       local password = guiGetText(password) 
       if username and password then 
          triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) 
       else 
          guiSetText(labelInfo, "Enter username and password.") 
       end 
    end 
end 
  
  
function onClientSubmitChangepw(button, state) 
    if button == "left" and state == "up" then 
       local username = guiGetText(usernamepw) 
       local password = guiGetText(passwordpw) 
       if username and password then 
          triggerServerEvent("submitChangepw", getRootElement(), localPlayer, username, password) 
       else 
          outputChatBox("Enter old and new password.") 
       end 
    end 
end 
  
  
function  hideLoginWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible(window, false) 
    showCursor(false) 
end 
  
  
function hidePasswordWindow() 
    guiSetInputEnabled(false) 
    guiSetVisible(windowpw, false) 
    showCursor(false) 
end 
  
addEvent("hidePasswordWindow", true) 
addEvent("hideLoginWindow", true) 
addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow) 
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart) 
addCommandHandler("changepass", changePw) 

Server Side:

function passwordHandler(player, oldpassword, newpassword) 
    local account = getPlayerAccount(player) 
    if (account) then 
        if (isGuestAccount(account)) then 
            outputChatBox("You must be logged in to change password.", player, 255, 0, 0) 
            return 
        end 
        local playerName = getPlayerName(player) 
        local password_check = getAccount(playerName, olpassword) 
        if (password_check ~= false) then 
            if (string.len(newpassword) >= 5) then 
                setAccountPassword(account, newpassword) 
                triggerClientEvent(player, "hidePasswordWindow", getRootElement()) 
            else 
                outputChatBox("Your new password must be at least 5 characters.", player, 255, 0, 0) 
            end 
        else 
            outputChatBox("Old password invalid.", player, 255, 0, 0) 
        end 
    end 
end 
  
function loginHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        if (logIn(player, account, password) == true) then 
            outputChatBox("You successfully logged in.", player, 0, 255, 0) 
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
            cancelEvent() 
        else 
           outputChatBox("Please report it on forum", player) 
        end 
    else 
       outputChatBox("Username or password is invalid.", player, 255, 0, 0) 
    end 
end 
  
function registerHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
       outputChatBox("Username is already in used.", player, 255, 0, 0) 
    else 
       account = addAccount(username, password) 
       cancelEvent() 
       outputChatBox("You successfully register"..getPlayerAccount(player)..password..".",player, 0, 255, 0) 
       if (logIn(player, account, password) == true) then 
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
            cancelEvent() 
       else 
           outputChatBox("Please report it on forum", player) 
       end 
    end 
end 
addEvent("submitChangepw", true) 
addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
addEventHandler("submitChangepw", getRootElement(), passwordHandler) 
addEventHandler("submitLogin", getRootElement(), loginHandler) 
addEventHandler("submitRegister", getRootElement(), registerHandler)  

no work why?

Edited by Guest
Link to comment
function passwordHandler(player, oldpassword, newpassword) 
    local account = getPlayerAccount(player) 
    if (account) then 
        if (isGuestAccount(account)) then 
            outputChatBox("You must be logged in to change password.", player, 255, 0, 0) 
            return 
        end 
        local playerName = getPlayerName(player) 
        local password_check = getAccount(playerName, olpassword) 
        if (password_check ~= false) then 
            if (string.len(newpassword) >= 5) then 
                setAccountPassword(account, newpassword) 
                triggerClientEvent(player, "hidePasswordWindow", getRootElement()) 
            else 
                outputChatBox("Your new password must be at least 5 characters.", player, 255, 0, 0) 
            end 
        else 
            outputChatBox("Old password invalid.", player, 255, 0, 0) 
        end 
    end 
end 
  
function loginHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        if (logIn(player, account, password) == true) then 
            outputChatBox("Login:you successfully logged in.", player, 0, 255, 0) 
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
            cancelEvent() 
        else 
           outputChatBox("Please report it on forum", player) 
        end 
    else 
       outputChatBox("Username or password is invalid.", player, 255, 0, 0) 
    end 
end 
  
function registerHandler(player, username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
       outputChatBox("Username is already in used.", player, 255, 0, 0) 
    else 
       account = addAccount(username, password) 
       cancelEvent() 
       outputChatBox("Register:you successfully register"..getPlayerAccount(player)..password..".",player, 0, 255, 0) 
       if (logIn(player, account, password) == true) then 
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
            cancelEvent() 
       else 
           outputChatBox("Please report it on forum", player) 
       end 
    end 
end 
addEvent("submitChangepw", true) 
addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
addEventHandler("submitChangepw", getRootElement(), passwordHandler) 
addEventHandler("submitLogin", getRootElement(), loginHandler) 
addEventHandler("submitRegister", getRootElement(), registerHandler)  

no work why?

guy i have put cancelEvent() for remove the message i take from login and register and still take it why?

Link to comment
  • 4 weeks later...
blackLoginScreen = false     
enableKickPlayer = true 
disallowLogout = false
removeBlackScreenTime = 4
maxLoginAttempts = 5
local localPlayer = getLocalPlayer()
local playerName = getPlayerName(localPlayer)
 
function createRegisterWindow()
GUIEditor_Button = {}
windowr = guiCreateWindow(423, 219, 307, 272, " Register Panel", false)
guiSetAlpha(windowr, 1)
guiWindowSetMovable(windowr, false)
guiWindowSetSizable(windowr, false)
usernamer = guiCreateEdit(45, 23, 251, 32, "", false, windowr)
guiSetAlpha(usernamer, 1)
guiEditSetMaxLength(usernamer,20)
usericon = guiCreateStaticImage(13, 23, 32, 32, "images/user77.png", false, windowr)
guiSetAlpha(usericon, 1)
passwordr = guiCreateEdit(45, 72, 251, 32, "", false, windowr)
guiEditSetMasked(passwordr, true)
guiEditSetMaxLength(passwordr, 30)
guiSetAlpha(passwordr, 1)
passicon = guiCreateStaticImage(13, 72, 32, 32, "images/closed.png", false, windowr)
guiSetAlpha(passicon, 1)
cpassword = guiCreateEdit(45, 120, 251, 32, "", false, windowr)
guiEditSetMasked(cpassword, true)
guiEditSetMaxLength(cpassword, 30)
guiSetAlpha(cpassword, 1)
guiSetAlpha(cpasswordicon, 1)
cpassicon = guiCreateStaticImage(13, 120, 32, 32, "images/closed.png", false, windowr)
guiSetAlpha(cpassicon, 1)
GUIEditor_Button[1] = guiCreateButton(66, 169, 172, 40, "Register", false, windowr)
guiSetAlpha(GUIEditor_Button[1], 1)
addEventHandler("onClientGUIClick", GUIEditor_Button[1], onClientSubmitRegister)
Web = guiCreateLabel(87, 247, 151, 20, "www.xtreme-player.net", false, windowr)
guiSetAlpha(Web, 1)
guiLabelSetVerticalAlign(Web, "top")
guiLabelSetHorizontalAlign(Web, "left")
guiLabelSetColor(Web, 0, 0, 0)
guiSetVisible(windowr, false)
end
 
function createLoginWindow()
GUIEditor_Button = {}
window = guiCreateWindow(423, 219, 307, 272, "Login Panel", false)
guiSetAlpha(window, 1)
guiWindowSetMovable(window, false)
guiWindowSetSizable(window, false)
username = guiCreateEdit(45, 23, 251, 32, "", false, window)
guiSetAlpha(username, 1)
guiEditSetMaxLength(username, 20)
usericon = guiCreateStaticImage(13, 23, 32, 32, "images/user77.png", false, window)
guiSetAlpha(usericon, 1)
password = guiCreateEdit(45, 72, 251, 32, "", false, window)
guiSetAlpha(password, 1)
guiEditSetMasked(password, true)
guiEditSetMaxLength(password, 30)
passicon = guiCreateStaticImage(13, 72, 32, 32, "images/closed.png", false, window)
guiSetAlpha(passicon, 1)
GUIEditor_Button[1] = guiCreateButton(66, 130, 172, 40, "Login", false, window)
guiSetAlpha(GUIEditor_Button[1], 1)
GUIEditor_Button[2] = guiCreateButton(66, 185, 84, 33, "Guest", false, window)
guiSetAlpha(GUIEditor_Button[2], 1)
GUIEditor_Button[3] = guiCreateButton(159, 185, 84, 33, "Register", false, window)
guiSetAlpha(GUIEditor_Button[3], 1)
Web = guiCreateLabel(87, 247, 151, 20, "www.xtreme-player.net", false, window)
guiSetAlpha(Web, 1)
guiLabelSetVerticalAlign(Web, "top")
guiLabelSetHorizontalAlign(Web, "left")
guiLabelSetColor(Web, 0, 0, 0)
Settings = guiCreateStaticImage(265, 232, 32, 32, "images/settings.png", false, window)
guiSetAlpha(Settings, 1)
windows = guiCreateWindow(418, 503, 316, 158, "", false)
guiSetAlpha(windows, 0)
guiWindowSetMovable(windows, false)
guiWindowSetSizable(windows, false)
guiSetVisible(windows, false)
RU = guiCreateStaticImage(9, 26, 80, 30, "images/switch-off.png", false, windows)
guiSetAlpha(RU, 0)
RP = guiCreateStaticImage(9, 67, 80, 30, "images/switch-off.png", false, windows)
guiSetAlpha(RP, 0)
SP = guiCreateStaticImage(9, 107, 80, 30, "images/switch-off.png", false, windows)
guiSetAlpha(SP, 0)
RU_l= guiCreateLabel(98, 31, 161, 22, "Remember my username", false, windows)
guiSetAlpha(RU_l, 0)
guiLabelSetVerticalAlign(RU_l, "top")
guiLabelSetHorizontalAlign(RU_l, "left")
guiLabelSetColor(RU_l, 0, 0, 0)
RP_l = guiCreateLabel(98, 73, 161, 22, "Remember my password", false, windows)
guiSetAlpha(RP_l, 0)
guiLabelSetVerticalAlign(RP_l, "top")
guiLabelSetHorizontalAlign(RP_l, "left")
guiLabelSetColor(RP_l, 0, 0, 0)
SP_l = guiCreateLabel(98, 111, 161, 22, "Show password", false, windows)
guiSetAlpha(SP_l, 0)
guiLabelSetVerticalAlign(SP_l, "top")
guiLabelSetHorizontalAlign(SP_l, "left")
guiLabelSetColor(SP_l, 0, 0, 0)
addEventHandler("onClientGUIClick", GUIEditor_Button[1], onClientSubmitLogin)
addEventHandler("onClientGUIClick", GUIEditor_Button[2], onClickGuest)
addEventHandler("onClientGUIClick", GUIEditor_Button[3], showRegister)
addEventHandler("onClientClick", Settings, onSetting)
addEventHandler("onClientClick", RU, onSetting)
addEventHandler("onClientClick", RP, onSetting)
addEventHandler("onClientClick", SP, onSetting)
end
 
 
function onClickGuest(button, state)
    if(button == "left" and state =="up") then
       if (source == GUIEditor_Button[2]) then
          guiSetVisible(window, false)
          guiSetInputEnabled(false)
          showCursor(false)
        end
    end
end 
 
function resourceStart()
    createLoginWindow()
    if (window ~= nil) then
        guiSetVisible(window, true)
    else
       outputChatBox("An error has occurred")
    end
   guiSetInputEnabled(true)
   showCursor(true)
 end
 
function showRegister()
    createRegisterWindow()
    guiSetVisible(windowr, true)
    guiSetInputEnabled(true)
    showCursor(true)
end
 
function onClientSubmitLogin(button, state)
    if button == "left" and state == "up" then
       local username = guiGetText(username)
       local password = guiGetText(password)
       if username and password then
          triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password)
          Success = guiCreateStaticImage(302, 10, 664, 55 , "images/success.png", false)
          guiSetAlpha(Success, 1)
          Errorl = guiCreateLabel(102, 22, 244, 27, "", false, Success)
          guiSetAlpha(Errorl,  1)
          guiLabelSetVerticalAlign(Errorl, "top")
          guiLabelSetHorizontalAlign(Errorl, "left")
          guiSetText(Errorl, "You successfully logged in.")
          guiSetAlpha(Warning, 0)
          guiSetAlpha(Error, 0)
          guiSetAlpha(Information, 0)
        else
          guiSetAlpha(Success, 0)
          guiSetAlpha(Error, 0)
          guiSetAlpha(Information, 0)
          Warning = guiCreateStaticImage(302, 10, 664, 55 , "images/warning.png", false)
          Errorl = guiCreateLabel(102, 22, 244, 27, "", false, Warning)
          guiSetAlpha(Errorl,  1)
          guiLabelSetVerticalAlign(Errorl, "top")
          guiLabelSetHorizontalAlign(Errorl, "left")
          guiSetAlpha(Warning, 1)
          guiSetText(Errorl, "Enter username and password.")
        end
    end
end
 
function onClientSubmitRegister(button, state)
    if button == "left" and state == "up" then
       local username = guiGetText(usernamer)
       local password = guiGetText(passwordr)
       local cpassword = guiGetText(cpassword)
       if username and password and cpassword then
          triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password, cpassword)
          Success = guiCreateStaticImage(302, 10, 664, 55 , "images/success.png", false)
          guiSetAlpha(Success, 1)
          Errorl = guiCreateLabel(102, 22, 244, 27, "", false, Success)
          guiSetAlpha(Errorl,  1)
          guiLabelSetVerticalAlign(Errorl, "top")
          guiLabelSetHorizontalAlign(Errorl, "left")
          guiSetText(Errorl, "You successfully registered.")
          guiSetAlpha(Warning, 0)
          guiSetAlpha(Information, 0)
          guiSetAlpha(Error, 0)
       else
          guiSetAlpha(Success, 0)
          guiSetAlpha(Error, 0)
          guiSetAlpha(Information, 0)
          Warning = guiCreateStaticImage(302, 10, 664, 55 , "images/warning.png", false)
          Errorl = guiCreateLabel(102, 22, 244, 27, "", false, Warning)
          guiSetAlpha(Errorl,  1)
          guiLabelSetVerticalAlign(Errorl, "top")
          guiLabelSetHorizontalAlign(Errorl, "left")
          guiSetAlpha(Warning, 1)
          guiSetText(Errorl, "Enter username and password.")
        end
          resourceStart()
    end
end
 
function onSetting(state)
    if (source == Settings) and state == "up" then
       guiSetVisible(windows, true)
       guiSetAlpha(RP, 1)
       guiSetAlpha(RP_l, 1)
       guiSetAlpha(windows, 1)
       guiSetAlpha(SP, 1)
       guiSetAlpha(SP_l, 1)
       guiSetAlpha(RU, 1)
       guiSetAlpha(RU_l, 1)
       local username = guiGetText(username)
       local password = guiGetText(password)
       if (source == RU) and state == "up" then
           RU = guiCreateStaticImage(9, 26, 80, 30, "images/switch-on", false, windows)
           Information = guiCreateStaticImage(302, 10, 664, 55, "images/information.png", false)
           Errorl = guiCreateLabel(102, 22, 244, 27, "", false, Information)
           guiSetAlpha(Errorl,  1)
           guiLabelSetVerticalAlign(Errorl, "top")
           guiLabelSetHorizontalAlign(Errorl, "left")
           guiSetAlpha(Success, 0)
           guiSetAlpha(Error, 0)
           guiSetAlpha(Warning, 0)
           guiSetAlpha(Information, 1)
           guiSetText(Errorl, "Your username is now saved.")
           guiSetText(username, username)
        elseif (source == RP) and state == "up" then
           RU = guiCreateStaticImage(9, 26, 80, 30, "images/switch-off", false, windows)
           Information = guiCreateStaticImage(302, 10, 664, 55, "images/information.png", false)
           Errorl = guiCreateLabel(102, 22, 244, 27, "", false, Information)
           guiSetAlpha(Errorl,  1)
           guiLabelSetVerticalAlign(Errorl, "top")
           guiLabelSetHorizontalAlign(Errorl, "left")
           guiSetAlpha(Success, 0)
           guiSetAlpha(Error, 0)
           guiSetAlpha(Warning, 0)
           guiSetAlpha(Information, 1)
           guiSetText(Errorl, "Your username is now unsaved.")
        elseif (source == RP) and state == "up" then
           RP = guiCreateStaticImage(9, 67, 80, 30, "images/switch-on", false, windows)
           Information = guiCreateStaticImage(302, 10, 664, 55, "images/information.png", false)
           Errorl = guiCreateLabel(102, 22, 244, 27, "", false, Information)
           guiSetAlpha(Errorl,  1)
           guiLabelSetVerticalAlign(Errorl, "top")
           guiLabelSetHorizontalAlign(Errorl, "left")
           guiSetAlpha(Success, 0)
           guiSetAlpha(Error, 0)
           guiSetAlpha(Warning, 0)
           guiSetAlpha(Information, 1)
           guiSetText(Errorl, "Your password is now saved.")
           
Edited by Guest
Link to comment
  • 2 weeks later...

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...