Jump to content

Problems doing a Login/Register system. ²


LucasMorais

Recommended Posts

Hi, it's me again and again.. err.. i'm trying to do a login/register system for a roleplay server. But when I click "REGISTRO", nothing happens.. help?

login.lua ( GUI )

function loginWindow() 
    GUIEditor_Window = {} 
    GUIEditor_Button = {} 
    GUIEditor_Memo = {} 
    GUIEditor_Label = {} 
    GUIEditor_Edit = {} 
    GUIEditor_Scrollbar = {} 
    guiSetInputEnabled(true) 
    showCursor(true) 
    GUIEditor_Window[1] = guiCreateWindow(284,338,483,172,"LOGUE-SE OU REGISTRE-SE!",false) 
    guiWindowSetMovable(GUIEditor_Window[1],false) 
    guiWindowSetSizable(GUIEditor_Window[1],false) 
    LoginEdit = guiCreateLabel(13,28,118,19,"Nome de usuário:",false,GUIEditor_Window[1]) 
    GUIEditor_Edit[1] = guiCreateEdit(9,47,143,19,"",false,GUIEditor_Window[1]) 
    GUIEditor_Label[2] = guiCreateLabel(11,68,118,19,"Senha:",false,GUIEditor_Window[1]) 
    GUIEditor_Edit[2] = guiCreateEdit(9,47,143,19,"",false,GUIEditor_Window[1]) 
    guiEditSetMaxLength(GUIEditor_Edit[2],15) 
    PassEdit = guiCreateEdit(9,84,143,19,"",false,GUIEditor_Window[1]) 
    guiEditSetMasked(PassEdit,true) 
    LoginB = guiCreateButton(9,113,70,29,"Login",false,GUIEditor_Window[1]) 
    RegB = guiCreateButton(84,114,70,29,"Registro",false,GUIEditor_Window[1]) 
    GUIEditor_Label[3] = guiCreateLabel(100,149,313,18,"Connect Roleplay 2011 - [url=http://www.connect-rp.com]http://www.connect-rp.com[/url]",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Label[3],"default-bold-small") 
    GUIEditor_Label[4] = guiCreateLabel(164,22,308,18,"Atualizações:",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Label[4],"clear-normal") 
    GUIEditor_Memo[1] = guiCreateMemo(164,42,298,98,"v0.1 BETA:\n- GUI @ Login feita.\n-------------------------------------------------------------------\nPróximas atualizações:\nv0.2 BETA:\n- Sistema de salvamento de contas.",false,GUIEditor_Window[1]) 
    guiSetVisible(GUIEditor_Window[1], true) 
    local sound = playSound("sounds/mario.mp3") --Play wasted.mp3 from the sounds folder 
    setSoundVolume(sound, 1.0) -- set the sound volume to 50% 
    end 
    addEventHandler("onClientResourceStart", getResourceRootElement(), loginWindow) 
  
  
  
function activateThis() 
triggerClientEvent("thisThing", getRootElement()) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(), loginwindow) 

account.lua

addEvent("thisThing", true) 
  
local playerRegister = false 
    function onPlayerRegister(username, password) 
onClientGUIClick(left, up, 114,70) 
guiGetText(LoginEdit) 
guiGetText(PassEdit) 
if(password ~= "" and password ~= nil and username ~= and username ~= nil and playerRegister = false) then 
triggerServerEvent("addTheAccount", getRootElement()) 
end 
addEventHandler("onClientGUIClick", RegB) 

contas.lua (add the account)

addEvent("addTheAccount", true) 
  
function registerThePlayer(source, username, password) 
local accountAdded = addAccount(username, password) 
if(accountAdded) then 
outputChatBox("Obrigado por se registrar, agora logue-se.", source) 
playerRegister = true 
else 
outputChatBox("Ocorreu um erro enquanto estávamos criando sua conta, tente novamente.", source) 
end 
if(playerRegister == true) then 
outputChatBox("Este nome de usuário já está registrado, escolha outro!", source) 
end 
end 
addEventHandler("addTheAccount", getRootElement(), registerThePlayer) 

I am trying to solve, I would be happy if anyone tries to help me :)

Link to comment

This is a mess of client side functions and server side, I don't even get some things..

-- client side:

function loginWindow() 
    GUIEditor_Window = {} 
    GUIEditor_Button = {} 
    GUIEditor_Memo = {} 
    GUIEditor_Label = {} 
    GUIEditor_Edit = {} 
    GUIEditor_Scrollbar = {} 
    guiSetInputEnabled(true) 
    showCursor(true) 
    GUIEditor_Window[1] = guiCreateWindow(284,338,483,172,"LOGUE-SE OU REGISTRE-SE!",false) 
    guiWindowSetMovable(GUIEditor_Window[1],false) 
    guiWindowSetSizable(GUIEditor_Window[1],false) 
    LoginEdit = guiCreateLabel(13,28,118,19,"Nome de usuário:",false,GUIEditor_Window[1]) 
    GUIEditor_Edit[1] = guiCreateEdit(9,47,143,19,"",false,GUIEditor_Window[1]) 
    GUIEditor_Label[2] = guiCreateLabel(11,68,118,19,"Senha:",false,GUIEditor_Window[1]) 
    GUIEditor_Edit[2] = guiCreateEdit(9,47,143,19,"",false,GUIEditor_Window[1]) 
    guiEditSetMaxLength(GUIEditor_Edit[2],15) 
    PassEdit = guiCreateEdit(9,84,143,19,"",false,GUIEditor_Window[1]) 
    guiEditSetMasked(PassEdit,true) 
    LoginB = guiCreateButton(9,113,70,29,"Login",false,GUIEditor_Window[1]) 
    RegB = guiCreateButton(84,114,70,29,"Registro",false,GUIEditor_Window[1]) 
    addEventHandler("onClientGUIClick",RegB,onPlayerRegister,false) 
    GUIEditor_Label[3] = guiCreateLabel(100,149,313,18,"Connect Roleplay 2011 - [url=http://www.connect-rp.com]http://www.connect-rp.com[/url]",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Label[3],"default-bold-small") 
    GUIEditor_Label[4] = guiCreateLabel(164,22,308,18,"Atualizações:",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Label[4],"clear-normal") 
    GUIEditor_Memo[1] = guiCreateMemo(164,42,298,98,"v0.1 BETA:\n- GUI @ Login feita.\n-------------------------------------------------------------------\nPróximas atualizações:\nv0.2 BETA:\n- Sistema de salvamento de contas.",false,GUIEditor_Window[1]) 
    guiSetVisible(GUIEditor_Window[1], true) 
    local sound = playSound("sounds/mario.mp3") --Play wasted.mp3 from the sounds folder 
    setSoundVolume(sound, 1.0) -- set the sound volume to 50% 
    end 
addEventHandler("onClientResourceStart", resourceRoot, loginWindow) 
  
function onPlayerRegister() 
local username = guiGetText(LoginEdit) 
local password = guiGetText(PassEdit) 
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil) then 
triggerServerEvent("addTheAccount", localPlayer, localPlayer) 
     end 
end 

-- server side:

function registerThePlayer(player, username, password) 
local account = getAccount (username, password) 
if (account) then 
      outputChatBox("Este nome de usuário já está registrado, escolha outro!", player) 
      return 
end 
local accountAdded = addAccount(username, password) 
if(accountAdded) then 
     outputChatBox("Obrigado por se registrar, agora logue-se.", player) 
else 
     outputChatBox("Ocorreu um erro enquanto estávamos criando sua conta, tente novamente.", player) 
      end 
end 
addEvent("addTheAccount", true) 
addEventHandler("addTheAccount", getRootElement(), registerThePlayer) 

Link to comment

:lol:

--- Client Side ---

function loginWindow() 
    GUIEditor_Window = {} 
    GUIEditor_Button = {} 
    GUIEditor_Memo = {} 
    GUIEditor_Label = {} 
    GUIEditor_Edit = {} 
    GUIEditor_Scrollbar = {} 
    guiSetInputEnabled(true) 
    showCursor(true) 
    local x,y = guiGetScreenSize() 
    GUIEditor_Window[1] = guiCreateWindow(x/2-243, y/2-86,486,172,"LOGUE-SE OU REGISTRE-SE!",false) 
    guiWindowSetMovable(GUIEditor_Window[1],false) 
    guiWindowSetSizable(GUIEditor_Window[1],false) 
    LoginEdit = guiCreateLabel(13,28,118,19,"Nome de usuário:",false,GUIEditor_Window[1]) 
    GUIEditor_Edit[1] = guiCreateEdit(9,47,143,19,"",false,GUIEditor_Window[1]) 
    GUIEditor_Label[2] = guiCreateLabel(11,68,118,19,"Senha:",false,GUIEditor_Window[1]) 
    PassEdit = guiCreateEdit(9,84,143,19,"",false,GUIEditor_Window[1]) 
    guiEditSetMasked(PassEdit,true) 
    LoginB = guiCreateButton(9,113,70,29,"Login",false,GUIEditor_Window[1]) 
    RegB = guiCreateButton(84,114,70,29,"Registro",false,GUIEditor_Window[1]) 
    addEventHandler("onClientGUIClick",LoginB,onPlayerLogin,false) 
    addEventHandler("onClientGUIClick",RegB,onPlayerRegister,false) 
    GUIEditor_Label[3] = guiCreateLabel(100,149,313,18,"Connect Roleplay 2011 - [url=http://www.connect-rp.com]http://www.connect-rp.com[/url]",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Label[3],"default-bold-small") 
    GUIEditor_Label[4] = guiCreateLabel(164,22,308,18,"Atualizações:",false,GUIEditor_Window[1]) 
    guiSetFont(GUIEditor_Label[4],"clear-normal") 
    GUIEditor_Memo[1] = guiCreateMemo(164,42,298,98,"v0.1 BETA:\n- GUI @ Login feita.\n-------------------------------------------------------------------\nPróximas atualizações:\nv0.2 BETA:\n- Sistema de salvamento de contas.",false,GUIEditor_Window[1]) 
    guiSetVisible(GUIEditor_Window[1], true) 
    local sound = playSound("sounds/mario.mp3") --Play wasted.mp3 from the sounds folder 
    setSoundVolume(sound, 1.0) -- set the sound volume to 50% 
    end 
addEventHandler("onClientResourceStart", resourceRoot, loginWindow) 
  
function onPlayerLogin() 
local username = guiGetText(GUIEditor_Edit[1]) 
local password = guiGetText(PassEdit) 
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil) then 
triggerServerEvent("loginTheAccount", localPlayer, username, password) 
     end 
end 
  
function onPlayerRegister() 
local username = guiGetText(GUIEditor_Edit[1]) 
local password = guiGetText(PassEdit) 
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil) then 
triggerServerEvent("addTheAccount", localPlayer, username, password) 
     end 
end 
  
function HideGui() 
          guiSetInputEnabled(false) 
          guiSetVisible(GUIEditor_Window[1], false) 
          showCursor(false) 
end 
addEvent("hideTheGui", true) 
addEventHandler("hideTheGui", root, HideGui) 

--- Server Side ---

function registerThePlayer(username, password) 
local account = getAccount (username) 
if (account) then 
    outputChatBox("Este nome de usuário já está registrado, escolha outro!", source) 
      return 
end 
local accountAdded = addAccount(username, password) 
if(accountAdded) then 
        outputChatBox("Obrigado por se registrar, agora logue-se.", source) 
else 
        outputChatBox("Ocorreu um erro enquanto estávamos criando sua conta, tente novamente.", source) 
      end 
end 
addEvent("addTheAccount", true) 
addEventHandler("addTheAccount", getRootElement(), registerThePlayer) 
  
function loginThePlayer(username, password) 
    local account = getAccount (username, password) 
    if ( account ~= false ) then 
        if (logIn ( source, account, password ) == true) then 
            outputChatBox ("Com sucesso logado!", source) 
            triggerClientEvent ( source, "hideTheGui", source ) 
        else 
            outputChatBox ("Ocorreu um erro enquanto estávamos de login da sua conta, tente novamente!", source) 
        end 
    else 
        outputChatBox ("Nome de usuário ou senha errada!", source) 
    end 
end 
addEvent("loginTheAccount", true) 
addEventHandler("loginTheAccount", getRootElement(), loginThePlayer) 

Edited by Guest
Link to comment
  
function registerThePlayer(username, password) 
local account = getAccount (username) 
if (account) then 
    outputChatBox("Este nome de usuário já está registrado, escolha outro!", source) 
      return 
end 
local accountAdded = addAccount(username, password) 
if(accountAdded) then 
        outputChatBox("Obrigado por se registrar, agora logue-se.", source) 
else 
        outputChatBox("Ocorreu um erro enquanto estávamos criando sua conta, tente novamente.", source) 
      end 
end 
addEvent("addTheAccount", true) 
addEventHandler("addTheAccount", root, registerThePlayer) 
  
function loginThePlayer(username, password) 
    local account = getAccount (username, password) 
    if ( account ~= false ) then 
        if (logIn ( source, account, password ) == true) then 
            if (getAccountData (account, "IsFirsTime") == false) then 
            setAccountData (account, "IsFirsTime", "true") 
            outputChatBox ("This is First Time for You!", source) 
            -- Your Code Here 
            else 
            outputChatBox ("Com sucesso logado!", source) 
            triggerClientEvent ( source, "hideTheGui", source ) 
            end 
        else 
            outputChatBox ("Ocorreu um erro enquanto estávamos de login da sua conta, tente novamente!", source) 
        end 
    else 
        outputChatBox ("Nome de usuário ou senha errada!", source) 
    end 
end 
addEvent("loginTheAccount", true) 
addEventHandler("loginTheAccount", root, loginThePlayer) 

Link to comment

not tested

  
function registerThePlayer(username, password) 
local account = getAccount (username) 
if (account) then 
    outputChatBox("Este nome de usuário já está registrado, escolha outro!", source) 
      return 
end 
local accountAdded = addAccount(username, password) 
if(accountAdded) then 
        outputChatBox("Obrigado por se registrar, agora logue-se.", source) 
else 
        outputChatBox("Ocorreu um erro enquanto estávamos criando sua conta, tente novamente.", source) 
      end 
end 
addEvent("addTheAccount", true) 
addEventHandler("addTheAccount", root, registerThePlayer) 
  
function loginThePlayer(username, password) 
    local account = getAccount (username, password) 
    if ( account ~= false ) then 
        if (logIn ( source, account, password ) == true) then 
            if (getAccountData (account, "IsFirsTime") == false) then 
            setAccountData (account, "IsFirsTime", "true") 
            outputChatBox ("This is First Time for You!", source) 
            -- Your Code Here 
            else 
            PosX = getAccountData ( account, "posX" ) 
            PosY = getAccountData ( account, "posY" ) 
            PosZ = getAccountData ( account, "posZ" ) 
            setTimer(setElementPosition, 500, 1, source, PosX, PosY, PosZ) 
            outputChatBox ("Com sucesso logado!", source) 
            triggerClientEvent ( source, "hideTheGui", source ) 
            end 
        else 
            outputChatBox ("Ocorreu um erro enquanto estávamos de login da sua conta, tente novamente!", source) 
        end 
    else 
        outputChatBox ("Nome de usuário ou senha errada!", source) 
    end 
end 
addEvent("loginTheAccount", true) 
addEventHandler("loginTheAccount", root, loginThePlayer) 
  
function onQuit() 
local account = getPlayerAccount ( source ) 
  if not isGuestAccount(account) then 
    if (account) then 
        local x, y, z = getElementPosition(source) 
        setAccountData (account, "posX", x) 
        setAccountData (account, "posY", y) 
        setAccountData (account, "posZ", z) 
    end 
  end 
end 
addEventHandler ("onPlayerQuit", root, onQuit) 

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