Jump to content

Need Urgent Help


MetaGamer

Recommended Posts

I need some help. Whenever I try to register it says unknown error. This is my code

Client Side

  
local localPlayer = getLocalPlayer() 
local playerName = getPlayerName(localPlayer) 
  
function createPasswordWindow() 
    windowChangepw = guiCreateWindow(0.3859,0.349,0.2219,0.1628,"Change password",true) 
    guiSetSize(windowChangepw, 165, 21) 
    guiSetAlpha(windowChangepw,0.80000001192093) 
    editOldpw = guiCreateEdit(110,29,165,21,"",false,windowChangepw) 
    guiSetAlpha(editOldpw,1) 
    guiEditSetMasked(editOldpw,true) 
    labelOldpw = guiCreateLabel(10,29,90,21,"Old password:",false,windowChangepw) 
    guiSetAlpha(labelOldpw,1) 
    guiLabelSetColor(labelOldpw,255,255,255) 
    guiLabelSetVerticalAlign(labelOldpw,"center") 
    guiLabelSetHorizontalAlign(labelOldpw,"left",false) 
    editNewpw = guiCreateEdit(110,60,165,21,"",false,windowChangepw) 
    guiSetAlpha(editNewpw,1) 
    guiEditSetMasked(editNewpw,true) 
    guiEditSetMaxLength(editNewpw,50) 
    labelNewpw = guiCreateLabel(10,60,90,21,"New password:",false,windowChangepw) 
    guiSetAlpha(labelNewpw,1) 
    guiLabelSetColor(labelNewpw,255,255,255) 
    guiLabelSetVerticalAlign(labelNewpw,"center") 
    guiLabelSetHorizontalAlign(labelNewpw,"left",false) 
    buttonChangepw = guiCreateButton(10,91,265,23,"Change password",false,windowChangepw) 
    guiSetAlpha(buttonChangepw,1) 
     
    guiSetVisible(windowChangepw, false) 
     
    addEventHandler("onClientGUIClick", buttonChangepw, clientSubmitChangepw, false) 
end 
  
function createLoginWindow() 
    windowLogin = guiCreateWindow(0.3945,0.3646,0.2109,0.2018,"Gangsta RPG [bETA]",true) 
    guiSetSize(windowLogin, 270, 155, false) 
    guiSetAlpha(windowLogin,1) 
    labelUsername = guiCreateLabel(10,52,59,24,"Username:",false,windowLogin) 
    guiSetAlpha(labelUsername,1) 
    guiLabelSetColor(labelUsername,255,255,255) 
    guiLabelSetVerticalAlign(labelUsername,"center") 
    guiLabelSetHorizontalAlign(labelUsername,"left",false) 
    labelPassword = guiCreateLabel(10,86,59,24,"Password:",false,windowLogin) 
    guiSetAlpha(labelPassword,1) 
    guiLabelSetColor(labelPassword,255,255,255) 
    guiLabelSetVerticalAlign(labelPassword,"center") 
    guiLabelSetHorizontalAlign(labelPassword,"left",false) 
    labelInfo = guiCreateLabel(10,26,250,17,"Please login or register.",false,windowLogin) 
    guiSetAlpha(labelInfo,1) 
    guiLabelSetColor(labelInfo,255,255,255) 
    guiLabelSetVerticalAlign(labelInfo,"top") 
    guiLabelSetHorizontalAlign(labelInfo,"center",false) 
    guiSetFont(labelInfo,"default-bold-small") 
    editUsername = guiCreateEdit(79,52,181,25,playerName,false,windowLogin) 
    guiSetAlpha(editUsername,1) 
    guiEditSetMaxLength(editUsername, 50) 
    editPassword = guiCreateEdit(79,86,181,25,"",false,windowLogin) 
    guiSetAlpha(editPassword,1) 
    guiEditSetMasked(editPassword, true) 
    guiEditSetMaxLength(editPassword, 50) 
    buttonLogin = guiCreateButton(10,121,120,21,"Log in",false,windowLogin) 
    guiSetAlpha(buttonLogin,1) 
    buttonRegister = guiCreateButton(143,121,117,21,"Register",false,windowLogin) 
    guiSetAlpha(buttonRegister,1) 
     
    guiSetVisible(windowLogin, false) 
     
    addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false) 
    addEventHandler("onClientGUIClick", buttonRegister, clientSubmitRegister, false) 
end 
  
function resourceStart() 
    createLoginWindow() 
    if (windowLogin ~= nil) then 
        guiSetVisible(windowLogin, true) 
    else 
        outputChatBox("An error has occurred.") 
    end 
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
  
function changePw() 
    createPasswordWindow() 
    guiSetVisible(windowChangepw, true) 
    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, "Enter username and password.") 
        end 
    end 
end 
  
function clientSubmitChangepw(button, state) 
    if button == "left" and state == "up" then 
        local oldpassword = guiGetText(editOldpw) 
        local newpassword = guiGetText(editNewpw) 
        if oldpassword and newpassword then 
            triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword) 
        else 
            outputChatBox("Enter old and new password.") 
        end 
    end 
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, "An unknown error occured.") 
end 
  
function loginWrong() 
    guiSetText(labelInfo, "Wrong username and/or password.") 
end 
  
function registerTaken() 
    guiSetText(labelInfo, "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) 
  
addCommandHandler("changepw", 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 your password.", player) 
            return 
        end 
        local playerName = getPlayerName(player) 
        local password_check = getAccount(playerName, oldpassword) 
        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 long!", player) 
            end 
        else 
            outputChatBox("Old password invalid.", player) 
        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("If you want to change your password, use /changepw", player) 
            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 (logIn(player, account, password) == true) then 
            outputChatBox("If you want to change your password, use /changepw", player) 
            triggerClientEvent(player, "hideLoginWindow", getRootElement()) 
        else 
            triggerClientEvent(player, "unknownError", getRootElement()) 
        end 
    end 
end 
  
addEvent("submitChangepw", true) 
addEvent("submitLogin", true) 
addEvent("submitRegister", true) 
addEventHandler("submitChangepw", root, passwordHandler) 
addEventHandler("submitLogin", root, loginHandler) 
addEventHandler("submitRegister", root, registerHandler) 

  
[23:02:55] WARNING: windows\login\server.lua:43: Access denied @  'addAccount' 
[23:02:55] WARNING: windows\login\server.lua:43: Bad Arguement @  'login' 

Please help me fast. Thanks in advance

Edited by Guest
Link to comment

no man. It's not the problem of acl. No one can register. If they click register it shows "An Unknown Error has occured". BTW it also shows

  
[23:02:55] WARNING: windows\login\server.lua:43: Access denied @  'addAccount' 
[23:02:55] WARNING: windows\login\server.lua:43: Bad Arguement @  'login' 

in command prompt

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