Jump to content

login


Monty

Recommended Posts

hi i have this script but after registering people cannot connect... it says wrong username or password... here is the code

server-side ( the console says the error is in server side)

  
--//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", 2000) 
    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_success", 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 
  

client-side

--//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", "") 
  
    window = guiCreateWindow(300,220,417,270,"Login Panel",false) 
    gang_lbl = guiCreateLabel(16,31,385,19,"'Welcome to the Gang War Server'",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,player,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,"Welcome!",false,login_tab) 
    guiLabelSetHorizontalAlign(welcome1,"center",false) 
    guiSetFont(welcome1,"sa-gothic") 
    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 Stolka",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", getLocalPlayer(), guiGetText(login_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) 
        end 
    end 
) 
  
--//Add password and check box true. 
function addPassword(Password, Login) 
    guiCheckBoxSetSelected(remember, true) 
    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 
  
  

Link to comment

try this:

--//Register the account 
function RegisterPlayer(Login, Password, sex) 
    if (getAccount(Login)) then 
        outputChatBox("#CC0033[sERVER]: #339933This nickname is already registered, choose a other nickname", client, 0, 0, 0,true) 
        return 0 
    else 
        addAccount(Login, Password) 
    end 
  
    local playerAccount = getAccount(Login) 
    setAccountData(playerAccount, "money", 2000) 
    setAccountData(playerAccount, "sex", sex) 
    setAccountData(playerAccount, "password", Password) 
    setAccountData(playerAccount, "Kills", 0) 
    setAccountData(playerAccount, "Deads", 0) 
    setAccountData(playerAccount, "canSelectTeam", 1) 
    logIn(client, playerAccount, Password) 
    outputChatBox("#CC0033[sERVER]: #339933You have successfully registered and logged in automatically, do not forget your password ", client, 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\" />!", client, 0, 0, 0,true) 
    --//Remove the ability to change nickname after joined on the [sERVER]. 
    addEventHandler("onPlayerChangeNick", client, cancelChangeNick) 
    triggerClientEvent("login_success", getRootElement(), client) 
    triggerClientEvent("step1gangs", client) 
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 (client, account, Password) 
        local playerAccount = getAccount(Login, Password) 
        setAccountData(playerAccount, "savePassword", CheckBoxStat) 
        --//Remove the ability to change nickname after joined on the [sERVER]. 
        addEventHandler("onPlayerChangeNick", client, cancelChangeNick) 
        triggerClientEvent(client,"login_sucsess", getRootElement()) 
        if not getAccountData (playerAccount, "canSelectTeam") == 1 then 
            triggerClientEvent("step1gangs", client) 
        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(client,"checkSpawns",team, skin, weapon1, weapon2, weapon3) 
        end 
    else 
        outputChatBox ("#CC0033[sERVER]: #ffffffWrong #CC0033username #ffffffand/or #CC0033password!",client,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(theReclientStopped) 
    if getReclientName(theReclientStopped) == "GangWar" then 
        for k, players in ipairs(getElementsByType("player")) do 
            kickPlayer(players, "Restart Gamemoge") 
        end 
    end 
end 
addEventHandler("onReclientStop", 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", reclientRoot , 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 reclient, replace 'reclientRoot' with the appropriate element 
    triggerClientEvent(client, "onServerCallsClientFunction", reclientRoot, funcname, unpack(arg or {})) 
end 

Link to comment
try this:
--//Register the account 
function RegisterPlayer(Login, Password, sex) 
    if (getAccount(Login)) then 
        outputChatBox("#CC0033[sERVER]: #339933This nickname is already registered, choose a other nickname", client, 0, 0, 0,true) 
        return 0 
    else 
        addAccount(Login, Password) 
    end 
  
    local playerAccount = getAccount(Login) 
    setAccountData(playerAccount, "money", 2000) 
    setAccountData(playerAccount, "sex", sex) 
    setAccountData(playerAccount, "password", Password) 
    setAccountData(playerAccount, "Kills", 0) 
    setAccountData(playerAccount, "Deads", 0) 
    setAccountData(playerAccount, "canSelectTeam", 1) 
    logIn(client, playerAccount, Password) 
    outputChatBox("#CC0033[sERVER]: #339933You have successfully registered and logged in automatically, do not forget your password ", client, 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\" />!", client, 0, 0, 0,true) 
    --//Remove the ability to change nickname after joined on the [sERVER]. 
    addEventHandler("onPlayerChangeNick", client, cancelChangeNick) 
    triggerClientEvent("login_success", getRootElement(), client) 
    triggerClientEvent("step1gangs", client) 
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 (client, account, Password) 
        local playerAccount = getAccount(Login, Password) 
        setAccountData(playerAccount, "savePassword", CheckBoxStat) 
        --//Remove the ability to change nickname after joined on the [sERVER]. 
        addEventHandler("onPlayerChangeNick", client, cancelChangeNick) 
        triggerClientEvent(client,"login_sucsess", getRootElement()) 
        if not getAccountData (playerAccount, "canSelectTeam") == 1 then 
            triggerClientEvent("step1gangs", client) 
        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(client,"checkSpawns",team, skin, weapon1, weapon2, weapon3) 
        end 
    else 
        outputChatBox ("#CC0033[sERVER]: #ffffffWrong #CC0033username #ffffffand/or #CC0033password!",client,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(theReclientStopped) 
    if getReclientName(theReclientStopped) == "GangWar" then 
        for k, players in ipairs(getElementsByType("player")) do 
            kickPlayer(players, "Restart Gamemoge") 
        end 
    end 
end 
addEventHandler("onReclientStop", 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", reclientRoot , 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 reclient, replace 'reclientRoot' with the appropriate element 
    triggerClientEvent(client, "onServerCallsClientFunction", reclientRoot, funcname, unpack(arg or {})) 
end 

don't work

Link to comment

Your first code works perfectly, there's no problem with it:

--//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", "") 
  
    window = guiCreateWindow(300,220,417,270,"Login Panel",false) 
    gang_lbl = guiCreateLabel(16,31,385,19,"'Welcome to the Gang War Server'",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,player,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,"Welcome!",false,login_tab) 
    guiLabelSetHorizontalAlign(welcome1,"center",false) 
    guiSetFont(welcome1,"sa-gothic") 
    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 Stolka",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", getLocalPlayer(), guiGetText(login_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() 
        if getLocalPlayer() then 
            showCursor(false) 
            guiSetInputEnabled(false) 
            guiSetVisible(window, false) 
        end 
    end 
) 
  
--//Add password and check box true. 
function addPassword(Password, Login) 
    guiCheckBoxSetSelected(remember, true) 
    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 

--//Register the account 
function RegisterPlayer(Login, Password, sex) 
    if (getAccount(Login)) then 
        outputChatBox("#CC0033[sERVER]: #339933This nickname is already registered, choose a other nickname", source, 0, 0, 0,true) 
        return 0 
    else 
        addAccount(Login, Password) 
    end 
  
    local playerAccount = getAccount(Login, Password) 
    setAccountData(playerAccount, "money", 2000) 
    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(source,"login_success", 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
hi i have this script but after registering people cannot connect... it says wrong username or password... here is the code

server-side ( the console says the error is in server side)

  
--//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", 2000) 
    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_success", 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 
  

client-side

--//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", "") 
  
    window = guiCreateWindow(300,220,417,270,"Login Panel",false) 
    gang_lbl = guiCreateLabel(16,31,385,19,"'Welcome to the Gang War Server'",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,player,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,"Welcome!",false,login_tab) 
    guiLabelSetHorizontalAlign(welcome1,"center",false) 
    guiSetFont(welcome1,"sa-gothic") 
    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 Stolka",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", getLocalPlayer(), guiGetText(login_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) 
        end 
    end 
) 
  
--//Add password and check box true. 
function addPassword(Password, Login) 
    guiCheckBoxSetSelected(remember, true) 
    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 
  
  

this code will not work,

use my login panel (read pm (LAST LINK ON THIS RESOURCE))

there code perfect working on my sv.. when i modify resource for you

give admin rights to this resource

infotwix = guiCreateLabel(18,245,130,19,"Login Panel by Stolka",false,window)

login panel by me (TwiX)

do not violate copyrights, and respect my work (I thought you the good guy,i was wrong)

now all my help for you will NOT FREE

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