Jump to content

save password function not working


-stolka-

Recommended Posts

the debugscript reports bad agrument at line 59, it says expected account at argument 1 got nil... how can i fix it?

--//Register the account 
function RegisterPlayer(Login, Password, sex) 
    if (not getAccount(Login)) then 
        addAccount(Login, Password) 
    else 
        outputChatBox("#CC0033[sERVER]: #339933This nickname is already registered, choose a other nickname", source, 0, 0, 0,true) 
        return 0 
    end 
  
    local playerAccount = getAccount(Login, Password) 
    setAccountData(playerAccount, "money", math.random(5000,10000)) 
    setAccountData(playerAccount, "sex", sex) 
    setAccountData(playerAccount, "password", Password) 
    setAccountData(playerAccount, "Kills", 0) 
    setAccountData(playerAccount, "Deads", 0) 
    setAccountData(playerAccount, "canSelectTeam", 1) 
    logIn(source, playerAccount, Password) 
    outputChatBox("#CC0033[sERVER]: #339933You have successfully registered and logged in automatically, do not forget your password ", source, 0, 0, 0,true) 
    outputChatBox("#339933[sERVER] #ffffffYour login #CC0033"..Login.." #ffffffand password #CC0033"..Password.."#ffffff! Good game \"{SMILIES_PATH}/icon_wink.gif\" alt=\"\" title=\"Wink\" />!", source, 0, 0, 0,true) 
    --//Remove the ability to change nickname after joined on the [sERVER]. 
    addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
    triggerClientEvent("login_sucsess", getRootElement(), source) 
    triggerClientEvent("step1gangs", source) 
end 
addEvent("submitRegister", true) 
addEventHandler("submitRegister", getRootElement(), RegisterPlayer) 
  
--//Enter in Account 
function LoginPlayer(Login, Password, CheckBoxStat) 
    local account = getAccount (Login,Password) 
    if ( account ~= false ) then 
        logIn (source, account, Password) 
        local playerAccount = getAccount(Login, Password) 
        setAccountData(playerAccount, "savePassword", CheckBoxStat) 
        --//Remove the ability to change nickname after joined on the [sERVER]. 
        addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
        triggerClientEvent("login_sucsess", getRootElement(), source) 
        if not getAccountData (playerAccount, "canSelectTeam") == 1 then 
            triggerClientEvent("step1gangs", source) 
        else 
            local team = getAccountData (playerAccount, "onSavedTeam") 
            local skin = getAccountData(playerAccount, "onSavedSkin") 
            local weapon1 = getAccountData(playerAccount, "onSavedWeapon1") 
            local weapon2 = getAccountData(playerAccount, "onSavedWeapon2") 
            local weapon3 = getAccountData(playerAccount, "onSavedWeapon3") 
            callClientFunction(source,"checkSpawns",team, skin, weapon1, weapon2, weapon3) 
        end 
    else 
        outputChatBox ("#CC0033[sERVER]: #ffffffWrong #CC0033username #ffffffand/or #CC0033password!",source,255,255,255,true) 
    end 
end 
addEvent("submitLogin", true) 
addEventHandler("submitLogin", getRootElement(), LoginPlayer) 
  
--//Check password saved or no 
function getSavePassword(Login) 
    local playerAccount = getAccount(Login) 
    local getSavePassword = getAccountData(playerAccount, "savePassword") 
    local Password = getAccountData(playerAccount, "password") 
    if (getSavePassword == true) then 
        triggerClientEvent("addPassword", getRootElement(), Password, Login) 
    end 
end 
addEvent("getSavePassword", true) 
addEventHandler("getSavePassword", getRootElement(), getSavePassword) 
  
function cancelChangeNick(oldNick, newNick) 
    cancelEvent() 
end 
  
--//Logged players after stop gamemode 
function logOutPlayer(theResourceStopped) 
    if getResourceName(theResourceStopped) == "GangWar" then 
        for k, players in ipairs(getElementsByType("player")) do 
            kickPlayer(players, "Restart Gamemoge") 
        end 
    end 
end 
addEventHandler("onResourceStop", getRootElement(), logOutPlayer) 
  
------------------------------------------ 
-- Call 
------------------------------------------ 
function callServerFunction(funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do arg[key] = tonumber(value) or value end 
    end 
    loadstring("return "..funcname)()(unpack(arg)) 
end 
addEvent("onClientCallsServerFunction", true) 
addEventHandler("onClientCallsServerFunction", resourceRoot , callServerFunction) 
  
function callClientFunction(client, funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do 
            if (type(value) == "number") then arg[key] = tostring(value) end 
        end 
    end 
    -- If the clientside event handler is not in the same resource, replace 'resourceRoot' with the appropriate element 
    triggerClientEvent(client, "onServerCallsClientFunction", resourceRoot, funcname, unpack(arg or {})) 
end 

Link to comment
function getSavePassword(Login) 
    local playerAccount = getAccount(Login) 
    if ( playerAccount ) then 
        local getSavePassword = getAccountData(playerAccount, "savePassword") 
        local Password = getAccountData(playerAccount, "password") 
        if (getSavePassword == true) then 
            triggerClientEvent("addPassword", getRootElement(), Password, Login) 
        end 
    else 
        ouputChatBox ( "I got no account" ) 
    end 
end 
addEvent("getSavePassword", true) 
addEventHandler("getSavePassword", getRootElement(), getSavePassword) 

Check this. If it ouptus 'I got no account' check if 'Login' is sending from client correctly.

Link to comment

the function was not called, i corrected it but it's still not working... it's say expected element at argument 2 line 49 triggerEvent

--//Register the account 
function RegisterPlayer(Login, Password, sex) 
    if (not getAccount(Login)) then 
        addAccount(Login, Password) 
    else 
        outputChatBox("#CC0033[sERVER]: #339933This nickname is already registered, choose a other nickname", source, 0, 0, 0,true) 
        return 0 
    end 
  
    local playerAccount = getAccount(Login, Password) 
    setAccountData(playerAccount, "money", math.random(5000,10000)) 
    setAccountData(playerAccount, "sex", sex) 
    setAccountData(playerAccount, "password", Password) 
    setAccountData(playerAccount, "Kills", 0) 
    setAccountData(playerAccount, "Deads", 0) 
    setAccountData(playerAccount, "canSelectTeam", 1) 
    logIn(source, playerAccount, Password) 
    outputChatBox("#CC0033[sERVER]: #339933You have successfully registered and logged in automatically, do not forget your password ", source, 0, 0, 0,true) 
    outputChatBox("#339933[sERVER] #ffffffYour login #CC0033"..Login.." #ffffffand password #CC0033"..Password.."#ffffff! Good game \"{SMILIES_PATH}/icon_wink.gif\" alt=\"\" title=\"Wink\" />!", source, 0, 0, 0,true) 
    --//Remove the ability to change nickname after joined on the [sERVER]. 
    addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
    triggerClientEvent("login_sucsess", getRootElement(), source) 
    triggerClientEvent("step1gangs", source) 
end 
addEvent("submitRegister", true) 
addEventHandler("submitRegister", getRootElement(), RegisterPlayer) 
  
--//Enter in Account 
function LoginPlayer(Login, Password, CheckBoxStat) 
    local account = getAccount (Login,Password) 
    if ( account ~= false ) then 
        logIn (source, account, Password) 
        playerAccount = getAccount(Login, Password) 
        setAccountData(playerAccount, "savePassword", CheckBoxStat) 
        --//Remove the ability to change nickname after joined on the [sERVER]. 
        addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
        triggerClientEvent("login_sucsess", getRootElement(), source) 
    triggerEvent("getSavePassword", playerAccount) 
        if not getAccountData (playerAccount, "canSelectTeam") == 1 then 
            triggerClientEvent("step1gangs", source) 
        else 
            local team = getAccountData (playerAccount, "onSavedTeam") 
            local skin = getAccountData(playerAccount, "onSavedSkin") 
            local weapon1 = getAccountData(playerAccount, "onSavedWeapon1") 
            local weapon2 = getAccountData(playerAccount, "onSavedWeapon2") 
            local weapon3 = getAccountData(playerAccount, "onSavedWeapon3") 
            callClientFunction(source,"checkSpawns",team, skin, weapon1, weapon2, weapon3) 
        end 
    else 
        outputChatBox ("#CC0033[sERVER]: #ffffffWrong #CC0033username #ffffffand/or #CC0033password!",source,255,255,255,true) 
    end 
end 
addEvent("submitLogin", true) 
addEventHandler("submitLogin", getRootElement(), LoginPlayer) 
  
--//Check password saved or no 
    function getSavePassword(Login) 
        local playerAccount = getAccount(Login) 
        if ( playerAccount ) then 
            local getSavePassword = getAccountData(playerAccount, "savePassword") 
            local Password = getAccountData(playerAccount, "password") 
            if (getSavePassword == true) then 
                triggerClientEvent("addPassword", getRootElement(), Password, Login) 
            end 
        else 
            outputChatBox ( "I got no account" ) 
        end 
    end 
    addEvent("getSavePassword", true) 
    addEventHandler("getSavePassword", getRootElement(), getSavePassword) 
  
function cancelChangeNick(oldNick, newNick) 
    cancelEvent() 
end 
  
--//Logged players after stop gamemode 
function logOutPlayer(theResourceStopped) 
    if getResourceName(theResourceStopped) == "GangWar" then 
        for k, players in ipairs(getElementsByType("player")) do 
            kickPlayer(players, "Restart Gamemoge") 
        end 
    end 
end 
addEventHandler("onResourceStop", getRootElement(), logOutPlayer) 
  
------------------------------------------ 
-- Call 
------------------------------------------ 
function callServerFunction(funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do arg[key] = tonumber(value) or value end 
    end 
    loadstring("return "..funcname)()(unpack(arg)) 
end 
addEvent("onClientCallsServerFunction", true) 
addEventHandler("onClientCallsServerFunction", resourceRoot , callServerFunction) 
  
function callClientFunction(client, funcname, ...) 
    local arg = { ... } 
    if (arg[1]) then 
        for key, value in next, arg do 
            if (type(value) == "number") then arg[key] = tostring(value) end 
        end 
    end 
    -- If the clientside event handler is not in the same resource, replace 'resourceRoot' with the appropriate element 
    triggerClientEvent(client, "onServerCallsClientFunction", resourceRoot, funcname, unpack(arg or {})) 
end 

Link to comment
  • Moderators
any idea? :((

Yeah maybe this at line 38:

triggerEvent("getSavePassword", source, playerAccount) 

and

--//Check password saved or no 
function getSavePassword( playerAccount ) 
    if ( playerAccount ) then 
        local getSavePassword = getAccountData(playerAccount, "savePassword") 
        local Password = getAccountData(playerAccount, "password") 
        if (getSavePassword == true) then 
            triggerClientEvent("addPassword", getRootElement(), Password, Login) 
        end 
    else 
        outputChatBox ( "I got no account" ) 
    end 
end 
addEvent("getSavePassword", true) 
addEventHandler("getSavePassword", getRootElement(), getSavePassword) 

Also, you did a typo here:

kickPlayer(players, "Restart Gamemoge") 

Gamemode*

Link to comment
any idea? :((

Yeah maybe this at line 38:

triggerEvent("getSavePassword", source, playerAccount) 

and

--//Check password saved or no 
function getSavePassword( playerAccount ) 
    if ( playerAccount ) then 
        local getSavePassword = getAccountData(playerAccount, "savePassword") 
        local Password = getAccountData(playerAccount, "password") 
        if (getSavePassword == true) then 
            triggerClientEvent("addPassword", getRootElement(), Password, Login) 
        end 
    else 
        outputChatBox ( "I got no account" ) 
    end 
end 
addEvent("getSavePassword", true) 
addEventHandler("getSavePassword", getRootElement(), getSavePassword) 

Also, you did a typo here:

kickPlayer(players, "Restart Gamemoge") 

Gamemode*

now it reports bad argument line 49 expected account got string

Link to comment
  • Moderators

Ok try this, I fixed some stuff and renamed some variables/functions to match the conventions.

--//Register the account 
function RegisterPlayer(login, password, sex) 
    if not getAccount(login) then 
        addAccount(login, password) 
    else 
        outputChatBox("#CC0033[sERVER]: #339933This nickname is already registered, choose a other nickname", source, 0, 0, 0, true) 
        return 0 
    end 
  
    local playerAccount = getAccount(login, password) 
    setAccountData(playerAccount, "money", math.random(5000,10000)) 
    setAccountData(playerAccount, "sex", sex) 
    setAccountData(playerAccount, "password", password) 
    setAccountData(playerAccount, "Kills", 0) 
    setAccountData(playerAccount, "Deads", 0) 
    setAccountData(playerAccount, "canSelectTeam", 1) 
    logIn(source, playerAccount, password) 
    outputChatBox("#CC0033[sERVER]: #339933You have successfully registered and logged in automatically, do not forget your password ", source, 0, 0, 0, true) 
    outputChatBox("#339933[sERVER] #ffffffYour login #CC0033"..login.." #ffffffand password #CC0033"..password.."#ffffff! Good game !", source, 0, 0, 0, true) 
    --//Remove the ability to change nickname after joined on the [sERVER]. 
    addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
    triggerClientEvent("login_sucsess", root, source) 
    triggerClientEvent("step1gangs", source) 
end 
addEvent("submitRegister", true) 
addEventHandler("submitRegister", root, RegisterPlayer) 
  
--//Enter in Account 
function loginPlayer(login, password, checkBoxStat) 
    local account = getAccount (login, password) 
    if account then 
        logIn (source, login, password) 
        local playerAccount = getAccount(login, password) 
        setAccountData(playerAccount, "savePassword", checkBoxStat) 
        --//Remove the ability to change nickname after joined on the [sERVER]. 
        addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
        triggerClientEvent("login_sucsess", source, source) 
        triggerEvent("getSavePassword", playerAccount) 
        if not (getAccountData (playerAccount, "canSelectTeam") == 1) then 
            triggerClientEvent("step1gangs", source) 
        else 
            local team = getAccountData (playerAccount, "onSavedTeam") 
            local skin = getAccountData(playerAccount, "onSavedSkin") 
            local weapon1 = getAccountData(playerAccount, "onSavedWeapon1") 
            local weapon2 = getAccountData(playerAccount, "onSavedWeapon2") 
            local weapon3 = getAccountData(playerAccount, "onSavedWeapon3") 
            callClientFunction(source, "checkSpawns", team, skin, weapon1, weapon2, weapon3) 
        end 
    else 
        outputChatBox ("#CC0033[sERVER]: #ffffffWrong #CC0033username #ffffffand/or #CC0033password!", source, 255, 255, 255, true) 
    end 
end 
addEvent("submitLogin", true) 
addEventHandler("submitLogin", root, loginPlayer) 
  
--//Check password saved or no 
function getSavePassword( login ) 
    local playerAccount = getAccount( login ) 
    if playerAccount then 
        local savePass = getAccountData(playerAccount, "savePassword") 
        if savePass then 
            local password = getAccountData(playerAccount, "password") 
            triggerClientEvent("addPassword", root, password, login) 
        end 
    else 
        outputChatBox ( "I got no account" ) 
    end 
end 
addEvent("getSavePassword", true) 
addEventHandler("getSavePassword", root, getSavePassword) 
  
function cancelChangeNick(oldNick, newNick) 
    cancelEvent() 
end 
  
--//Logged players after stop gamemode 
function logOutPlayer(theResourceStopped) 
    if getResourceName(theResourceStopped) == "GangWar" then 
        for k, players in ipairs(getElementsByType("player")) do 
            kickPlayer(players, "Restarting Gamemode") 
        end 
    end 
end 
addEventHandler("onResourceStop", root, logOutPlayer) 

The problem was at line 32, you should use login as second argument

Link to comment
Ok try this, I fixed some stuff and renamed some variables/functions to match the conventions.
--//Register the account 
function RegisterPlayer(login, password, sex) 
    if not getAccount(login) then 
        addAccount(login, password) 
    else 
        outputChatBox("#CC0033[sERVER]: #339933This nickname is already registered, choose a other nickname", source, 0, 0, 0, true) 
        return 0 
    end 
  
    local playerAccount = getAccount(login, password) 
    setAccountData(playerAccount, "money", math.random(5000,10000)) 
    setAccountData(playerAccount, "sex", sex) 
    setAccountData(playerAccount, "password", password) 
    setAccountData(playerAccount, "Kills", 0) 
    setAccountData(playerAccount, "Deads", 0) 
    setAccountData(playerAccount, "canSelectTeam", 1) 
    logIn(source, playerAccount, password) 
    outputChatBox("#CC0033[sERVER]: #339933You have successfully registered and logged in automatically, do not forget your password ", source, 0, 0, 0, true) 
    outputChatBox("#339933[sERVER] #ffffffYour login #CC0033"..login.." #ffffffand password #CC0033"..password.."#ffffff! Good game !", source, 0, 0, 0, true) 
    --//Remove the ability to change nickname after joined on the [sERVER]. 
    addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
    triggerClientEvent("login_sucsess", root, source) 
    triggerClientEvent("step1gangs", source) 
end 
addEvent("submitRegister", true) 
addEventHandler("submitRegister", root, RegisterPlayer) 
  
--//Enter in Account 
function loginPlayer(login, password, checkBoxStat) 
    local account = getAccount (login, password) 
    if account then 
        logIn (source, login, password) 
        local playerAccount = getAccount(login, password) 
        setAccountData(playerAccount, "savePassword", checkBoxStat) 
        --//Remove the ability to change nickname after joined on the [sERVER]. 
        addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
        triggerClientEvent("login_sucsess", source, source) 
        triggerEvent("getSavePassword", playerAccount) 
        if not (getAccountData (playerAccount, "canSelectTeam") == 1) then 
            triggerClientEvent("step1gangs", source) 
        else 
            local team = getAccountData (playerAccount, "onSavedTeam") 
            local skin = getAccountData(playerAccount, "onSavedSkin") 
            local weapon1 = getAccountData(playerAccount, "onSavedWeapon1") 
            local weapon2 = getAccountData(playerAccount, "onSavedWeapon2") 
            local weapon3 = getAccountData(playerAccount, "onSavedWeapon3") 
            callClientFunction(source, "checkSpawns", team, skin, weapon1, weapon2, weapon3) 
        end 
    else 
        outputChatBox ("#CC0033[sERVER]: #ffffffWrong #CC0033username #ffffffand/or #CC0033password!", source, 255, 255, 255, true) 
    end 
end 
addEvent("submitLogin", true) 
addEventHandler("submitLogin", root, loginPlayer) 
  
--//Check password saved or no 
function getSavePassword( login ) 
    local playerAccount = getAccount( login ) 
    if playerAccount then 
        local savePass = getAccountData(playerAccount, "savePassword") 
        if savePass then 
            local password = getAccountData(playerAccount, "password") 
            triggerClientEvent("addPassword", root, password, login) 
        end 
    else 
        outputChatBox ( "I got no account" ) 
    end 
end 
addEvent("getSavePassword", true) 
addEventHandler("getSavePassword", root, getSavePassword) 
  
function cancelChangeNick(oldNick, newNick) 
    cancelEvent() 
end 
  
--//Logged players after stop gamemode 
function logOutPlayer(theResourceStopped) 
    if getResourceName(theResourceStopped) == "GangWar" then 
        for k, players in ipairs(getElementsByType("player")) do 
            kickPlayer(players, "Restarting Gamemode") 
        end 
    end 
end 
addEventHandler("onResourceStop", root, logOutPlayer) 

The problem was at line 32, you should use login as second argument

when i login my camera matrix doesnt stop

and it doesnt say successfully logged in

Link to comment
  • Moderators
when i login my camera matrix doesnt stop

This doesn't make any sense. I couldn't guess what you mean't by saying that.

and it doesnt say successfully logged in

Because the login and password are just wrong ?

Link to comment

there are no errsors reported in the debugscript but the panesl doesnt dispay my saved password why?

client

--//Register / Login panel 
function createLoginPanel() 
    fadeCamera(true, 6, 0, 0, 0) 
    setCameraMatrix(-1475.5, 831.18, 65.5, -1487.5, 800.18, 65.5) 
    showPlayerHudComponent("radar", false) 
    showPlayerHudComponent("area_name", false) 
    local player = string.gsub(getPlayerName(getLocalPlayer()),"#%x%x%x%x%x%x", "") 
  
  
  function guiMyCwindow(w,h,t) 
      local x,y = guiGetScreenSize() 
      return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) 
  end 
  
  
  
    window = guiMyCwindow(417,270,"Login Panel") 
    gang_lbl = guiCreateLabel(16,31,385,19,"'Welcome to the CAOS '",false,window) 
    guiLabelSetHorizontalAlign(gang_lbl,"center",false) 
    guiSetFont(gang_lbl,"default-bold-small") 
    tabs = guiCreateTabPanel(16,54,388,186,false,window) 
    login_tab = guiCreateTab("Login",tabs) 
    lblLogin = guiCreateLabel(10,11,99,24,"Login:",false,login_tab) 
    lblReg = guiCreateLabel(8,38,78,23,"Password:",false,login_tab) 
    remember = guiCreateCheckBox(6,58,109,23,"Remember me?",false,false,login_tab) 
    guiCheckBoxSetSelected(remember,true) 
    login_edit = guiCreateEdit(96,7,212,23,"",false,login_tab) 
    --guiEditSetReadOnly(login_edit,true) 
    pass_edit = guiCreateEdit(95,36,214,23,"",false,login_tab) 
    guiEditSetMasked(pass_edit,true) 
    welcome1 = guiCreateLabel(29,90,336,55,"CAOS RP",false,login_tab) 
    guiLabelSetHorizontalAlign(welcome1,"center",false) 
    guiSetFont(welcome1,"sa-header") 
    login_Btn = guiCreateButton(310,8,75,51,"Login",false,login_tab) 
    reg_tab = guiCreateTab("Register",tabs) 
    reg_lbl = guiCreateLabel(15,15,47,18,"Login:",false,reg_tab) 
    reg_edit = guiCreateEdit(115,10,216,25,player,false,reg_tab) 
    --guiEditSetReadOnly(reg_edit,true) 
    reglbl_pass = guiCreateLabel(14,48,59,17,"Password:",false,reg_tab) 
    reg_pass_edit = guiCreateEdit(115,44,216,25,"",false,reg_tab) 
    cfpass = guiCreateLabel(11,82,101,17,"Confirm Password:",false,reg_tab) 
    guiEditSetMasked(reg_pass_edit,true) 
    confreg_pass = guiCreateEdit(115,77,216,25,"",false,reg_tab) 
    guiEditSetMasked(confreg_pass,true) 
    sexlbl = guiCreateLabel(15,111,68,37,"Sex:",false,reg_tab) 
    guiSetFont(sexlbl,"sa-header") 
    female_radio = guiCreateRadioButton(182,115,16,19,"",false,reg_tab) 
    male_radio = guiCreateRadioButton(115,114,16,19,"",false,reg_tab) 
    guiRadioButtonSetSelected(male_radio,true) 
    male_lbl = guiCreateLabel(114,135,33,14,"Male",false,reg_tab) 
    female_lbl = guiCreateLabel(175,136,39,14,"Female",false,reg_tab) 
    register_btn = guiCreateButton(243,122,137,31,"Register",false,reg_tab) 
    --infotwix = guiCreateLabel(18,245,130,19,"Login Panel by TwiX",false,window) 
    --guiLabelSetColor(infotwix,0,255,0) 
  
    guiWindowSetSizable(window, false)--//Block editing size of the window. 
    guiWindowSetMovable(window, false)--//Block move window. 
end 
  
function LoginPanel() 
    createLoginPanel() 
    triggerServerEvent("getSavePassword", guiGetText(login_edit), guiGetText(pass_edit) ) 
    addEventHandler("onClientGUIClick", login_Btn, clientSubmitLogin) 
    addEventHandler("onClientGUIClick", register_btn, clientSubmitRegister) 
    addEventHandler("onClientPlayerChangeNick", getLocalPlayer(), destroyDataPasswordAndAddlogin) 
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), LoginPanel) 
  
--//Register Players 
function clientSubmitRegister() 
    if source == register_btn then 
        local Login = guiGetText(reg_edit) 
        local Password = guiGetText(reg_pass_edit) 
        local ConfirmPassword = guiGetText(confreg_pass) 
  
    --//Check the floor player. 
        if guiRadioButtonGetSelected(male_radio) then 
            sex = "Male" 
        else 
            sex = "Female" 
        end 
  
        if (Login == "") then 
            outputChatBox("#CC0033[sERVER]: #339933Write your Login!", 0, 0, 0, true) 
            return 0 
        end 
  
        if (Password == "") then 
            outputChatBox("#CC0033[sERVER]: #339933Write your Password!", 0, 0, 0, true) 
            return 0 
        end 
  
        if (Password ~= ConfirmPassword) then 
            outputChatBox("#CC0033[sERVER]: #339933Passwords don't match!", 0, 0, 0,true) 
            return 0 
        end 
        triggerServerEvent("submitRegister", getLocalPlayer(), Login, Password, sex) 
    end 
end 
  
--//Enter in account 
function clientSubmitLogin() 
    if source == login_Btn then 
        local Login = guiGetText(login_edit) 
        local Password = guiGetText(pass_edit) 
        local CheckBoxStat = guiCheckBoxGetSelected(remember) 
  
        if (Login == "") then 
            outputChatBox("#CC0033[sERVER]: #339933Write your Login!", 0, 0, 0, true) 
            return 0 
        end 
  
        if (Password == "") then 
            outputChatBox("#CC0033[sERVER]: #339933Write your Password!", 0, 0, 0, true) 
            return 0 
        end 
  
        triggerServerEvent("submitLogin", getLocalPlayer(), Login, Password, CheckBoxStat) 
    end 
end 
  
--//Close Windows 
addEvent("login_sucsess", true) 
addEventHandler("login_sucsess", getRootElement(), 
    function (forPlayer) 
        if forPlayer == getLocalPlayer() then 
            showCursor(false) 
            guiSetInputEnabled(false) 
            guiSetVisible(window, false) 
      showPlayerHudComponent("radar", true) 
      showPlayerHudComponent("area_name", true) 
        end 
    end 
) 
  
--//Add password and check box true. 
function addPassword(Password, Login) 
    guiCheckBoxSetSelected(remember, true) 
  guiSetText(login_edit, Login) 
    guiSetText(pass_edit, Password) 
end 
addEvent("addPassword", true) 
addEventHandler("addPassword", getRootElement(), addPassword) 
  
--//Remove password when player changed nick 
function destroyDataPasswordAndAddlogin(oldNick, newNick) 
    guiSetText(login_edit, string.gsub(newNick,"#%x%x%x%x%x%x", "")) 
    guiSetText(reg_edit, string.gsub(newNick,"#%x%x%x%x%x%x", "")) 
  
    if (guiGetText(pass_edit) ~= "") then 
        guiSetText(pass_edit, "") 
    end 
  
    if (guiCheckBoxGetSelected(remember) == true) then 
        guiCheckBoxSetSelected(remember, false) 
    end 
end 

server

    --//Register the account 
    function RegisterPlayer(login, password, sex) 
        if not getAccount(login) then 
            addAccount(login, password) 
        else 
            outputChatBox("#CC0033[sERVER]: #339933This nickname is already registered, choose a other nickname", source, 0, 0, 0, true) 
            return 0 
        end 
      
        local playerAccount = getAccount(login, password) 
        setAccountData(playerAccount, "money", math.random(5000,10000)) 
        setAccountData(playerAccount, "sex", sex) 
        setAccountData(playerAccount, "password", password) 
        setAccountData(playerAccount, "Kills", 0) 
        setAccountData(playerAccount, "Deads", 0) 
        setAccountData(playerAccount, "canSelectTeam", 1) 
        logIn(source, playerAccount, password) 
        outputChatBox("#CC0033[sERVER]: #339933You have successfully registered and logged in automatically, do not forget your password ", source, 0, 0, 0, true) 
        outputChatBox("#339933[sERVER] #ffffffYour login #CC0033"..login.." #ffffffand password #CC0033"..password.."#ffffff! Good game !", source, 0, 0, 0, true) 
        --//Remove the ability to change nickname after joined on the [sERVER]. 
        addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
        triggerClientEvent("login_sucsess", root, source) 
        triggerClientEvent("step1gangs", source) 
    end 
    addEvent("submitRegister", true) 
    addEventHandler("submitRegister", root, RegisterPlayer) 
     
     
        --//Check password saved or no 
    function getSavePassword( login, password ) 
      local playerAccount = getAccount( login, password ) 
        if playerAccount then 
            local savePass = getAccountData(playerAccount, "savePassword") 
            if savePass then 
                local password = getAccountData(playerAccount, "password") 
                triggerClientEvent("addPassword", root, password, login) 
            end 
        else 
            outputChatBox ( "I got no account" ) 
        end 
    end 
   addEvent("getSavePassword", true) 
   addEventHandler("getSavePassword", root, getSavePassword) 
     
     
      
    --//Enter in Account 
    function loginPlayer(login, password, checkBoxStat) 
        local account = getAccount (login, password) 
        if account then 
            logIn (source, getAccount(login, password), password) 
            playerAccount = getAccount(login, password) 
            setAccountData(playerAccount, "savePassword", checkBoxStat) 
            --//Remove the ability to change nickname after joined on the [sERVER]. 
            addEventHandler("onPlayerChangeNick", source, cancelChangeNick) 
            triggerClientEvent("login_sucsess", source, source) 
           -- triggerEvent("getSavePassword", playerAccount) 
           getSavePassword ( login, password ) 
            if not (getAccountData (playerAccount, "canSelectTeam") == 1) then 
                triggerClientEvent("step1gangs", source) 
            else 
                local team = getAccountData (playerAccount, "onSavedTeam") 
                local skin = getAccountData(playerAccount, "onSavedSkin") 
                local weapon1 = getAccountData(playerAccount, "onSavedWeapon1") 
                local weapon2 = getAccountData(playerAccount, "onSavedWeapon2") 
                local weapon3 = getAccountData(playerAccount, "onSavedWeapon3") 
                callClientFunction(source, "checkSpawns", team, skin, weapon1, weapon2, weapon3) 
            end 
        else 
            outputChatBox ("#CC0033[sERVER]: #ffffffWrong #CC0033username #ffffffand/or #CC0033password!", source, 255, 255, 255, true) 
        end 
    end 
    addEvent("submitLogin", true) 
    addEventHandler("submitLogin", root, loginPlayer) 
      
  
      
    function cancelChangeNick(oldNick, newNick) 
        cancelEvent() 
    end 
      
    --//Logged players after stop gamemode 
    function logOutPlayer(theResourceStopped) 
        if getResourceName(theResourceStopped) == "GangWar" then 
            for k, players in ipairs(getElementsByType("player")) do 
                kickPlayer(players, "Restarting Gamemode") 
            end 
        end 
    end 
    addEventHandler("onResourceStop", root, logOutPlayer) 

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