Jump to content

Login.


#DaMiAnO

Recommended Posts

Hi!

My resource, not working. When I click "Zaloguj", the GUI will close. 0 error messages (outputChatBox).

Errors in Console:

[2012-04-14 10:15:35] WARNING: GameMode\LoginRegister_s.lua:7: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got nil] 
[2012-04-14 10:15:35] ERROR: GameMode\LoginRegister_s.lua:8: attempt to call global 'dbPool' (a nil value) 

Client-side:

  
function createLoginBox() 
    LoginGUI = guiCreateWindow(527,159,380,407,"Truck - Logowanie",false) 
    guiSetAlpha(LoginGUI,0.69999998807907) 
    guiWindowSetSizable(LoginGUI,false) 
    IntroLabel = guiCreateLabel(47,62,290,32,"                       Witamy na Truck!\nWpisz poniżej Login oraz Hasło, aby się zalogować!",false,LoginGUI) 
    guiSetFont(IntroLabel,"default-bold-small") 
    LoginLabel = guiCreateLabel(76,181,38,16,"Login:",false,LoginGUI) 
    guiSetFont(LoginLabel,"default-bold-small") 
    PassLabel = guiCreateLabel(72,218,40,16,"Hasło:",false,LoginGUI) 
    guiSetFont(PassLabel,"default-bold-small") 
    LoginBox = guiCreateEdit(128,179,137,19,"",false,LoginGUI) 
    PassBox = guiCreateEdit(129,216,137,19,"",false,LoginGUI) 
    guiEditSetMasked(PassBox,true) 
    LoginButton = guiCreateButton(35,259,306,52,"Zaloguj!",false,LoginGUI) 
    RegisterButton = guiCreateButton(35,330,306,52,"Zarejesrtuj!",false,LoginGUI) 
     
    guiSetVisible(LoginGUI, false) 
     
    addEventHandler("onClientGUIClick", LoginButton, submitLogin, false) 
    addEventHandler("onClientGUIClick", RegisterButton, registerPlayer, false) 
end 
  
function startLoginRegisterModule() 
    createLoginBox() 
     
    if (LoginGUI ~= nil) then 
        guiSetVisible(LoginGUI, true) 
    else 
        outputDebugString("Nie moge utworzyc GUI odpowiedzialnego od Logowania/Rejestracji!", 3, 255, 0, 0) 
    end  
     
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginRegisterModule) 
  
function submitLogin(button, state) 
    if button == "left" and state == "up" then 
         
        local login = guiGetText(LoginBox) 
        local pass = guiGetText(PassBox) 
  
        if login and pass then 
            triggerServerEvent("submitLoginServer", getRootElement(), login, pass) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(LoginGUI, false) 
            showCursor(false) 
        else 
            outputChatBox("#EE5555* #C0C0C0Proszę wpisać #EE5555Login #C0C0C0i #EE5555Hasło#C0C0C0!") 
        end 
    end 
end 

Server-side:

  
function loginHandler(login, pass) 
local getAccount = dbQuery(connection, "SELECT * FROM `accounts` WHERE `account` = `%s` AND `password` = `%s`", login, pass) 
local result = dbPool(getAccount, 0) 
  
    if result then 
        if client then 
            spawnPlayer(client, 1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
            setCameraTarget(client, client) 
        end 
    else 
        outputChatBox("#EE5555* #C0C0C0Podano zły #EE5555Login #C0C0C0lub #EE5555Hasło#C0C0C0!") 
    end      
end 
addEvent("submitLoginServer", true) 
addEventHandler("submitLoginServer", root, loginHandler) 

Link to comment
mysql = dbConnect("mysql", "dbname=mta;host=192.166.219.226", "damiano", "Censored", "share=1") 
  
if(mysql) then 
    outputServerLog("\n[MySQL] Pomyslnie polaczono z MySQL!") 
    outputDebugString("Pomyslnie polaczono z MySQL!", 3, 0, 224, 0) 
    else 
    outputServerLog("\n[MySQL] Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...") 
    outputDebugString("Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...", 3, 255, 0, 0) 
    destroyElement(mysql) 
end 

Link to comment

Client-side:

  
function createLoginBox() 
    LoginGUI = guiCreateWindow(527,159,380,407,"Truck - Logowanie",false) 
    guiSetAlpha(LoginGUI,0.69999998807907) 
    guiWindowSetSizable(LoginGUI,false) 
    IntroLabel = guiCreateLabel(47,62,290,32,"                       Witamy na Truck!\nWpisz poniżej Login oraz Hasło, aby się zalogować!",false,LoginGUI) 
    guiSetFont(IntroLabel,"default-bold-small") 
    LoginLabel = guiCreateLabel(76,181,38,16,"Login:",false,LoginGUI) 
    guiSetFont(LoginLabel,"default-bold-small") 
    PassLabel = guiCreateLabel(72,218,40,16,"Hasło:",false,LoginGUI) 
    guiSetFont(PassLabel,"default-bold-small") 
    LoginBox = guiCreateEdit(128,179,137,19,"",false,LoginGUI) 
    PassBox = guiCreateEdit(129,216,137,19,"",false,LoginGUI) 
    guiEditSetMasked(PassBox,true) 
    LoginButton = guiCreateButton(35,259,306,52,"Zaloguj!",false,LoginGUI) 
    RegisterButton = guiCreateButton(35,330,306,52,"Zarejesrtuj!",false,LoginGUI) 
     
    guiSetVisible(LoginGUI, false) 
     
    addEventHandler("onClientGUIClick", LoginButton, submitLogin, false) 
    addEventHandler("onClientGUIClick", RegisterButton, registerPlayer, false) 
end 
  
function startLoginRegisterModule() 
    createLoginBox() 
     
    if (LoginGUI ~= nil) then 
        guiSetVisible(LoginGUI, true) 
    else 
        outputDebugString("Nie moge utworzyc GUI odpowiedzialnego od Logowania/Rejestracji!", 3, 255, 0, 0) 
    end  
     
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginRegisterModule) 
  
function submitLogin(button, state) 
    if button == "left" and state == "up" then 
         
        local login = guiGetText(LoginBox) 
        local pass = guiGetText(PassBox) 
  
        if login and pass then 
            triggerServerEvent("submitLoginServer", getRootElement(), login, pass) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(LoginGUI, false) 
            showCursor(false) 
        else 
            outputChatBox("#EE5555* #C0C0C0Proszę wpisać #EE5555Login #C0C0C0i #EE5555Hasło#C0C0C0!") 
        end 
    end 
end 

Server-side:

  
function loginHandler(login, pass) 
mysql = dbConnect("mysql", "dbname=mta;host=192.166.219.226", "damiano", "Censored", "share=1") 
  
if(mysql) then 
    outputServerLog("\n[MySQL] Pomyslnie polaczono z MySQL!") 
    outputDebugString("Pomyslnie polaczono z MySQL!", 3, 0, 224, 0) 
    else 
    outputServerLog("\n[MySQL] Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...") 
    outputDebugString("Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...", 3, 255, 0, 0) 
    destroyElement(mysql) 
end 
  
local acc = dbQuery(mysql, "SELECT * FROM `accounts` WHERE `account` = `%s` AND `password` = `%s`", login, pass) 
local result = dbPoll(acc, 0) 
  
    if result then 
        if client then 
            spawnPlayer(client, 1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
            setCameraTarget(client, client) 
        end 
    else 
        outputChatBox("#EE5555* #C0C0C0Podano zły #EE5555Login #C0C0C0lub #EE5555Hasło#C0C0C0!") 
    end      
end 
addEvent("submitLoginServer", true) 
addEventHandler("submitLoginServer", root, loginHandler) 

Link to comment
Client-side:
  
function createLoginBox() 
    LoginGUI = guiCreateWindow(527,159,380,407,"Truck - Logowanie",false) 
    guiSetAlpha(LoginGUI,0.69999998807907) 
    guiWindowSetSizable(LoginGUI,false) 
    IntroLabel = guiCreateLabel(47,62,290,32,"                       Witamy na Truck!\nWpisz poniżej Login oraz Hasło, aby się zalogować!",false,LoginGUI) 
    guiSetFont(IntroLabel,"default-bold-small") 
    LoginLabel = guiCreateLabel(76,181,38,16,"Login:",false,LoginGUI) 
    guiSetFont(LoginLabel,"default-bold-small") 
    PassLabel = guiCreateLabel(72,218,40,16,"Hasło:",false,LoginGUI) 
    guiSetFont(PassLabel,"default-bold-small") 
    LoginBox = guiCreateEdit(128,179,137,19,"",false,LoginGUI) 
    PassBox = guiCreateEdit(129,216,137,19,"",false,LoginGUI) 
    guiEditSetMasked(PassBox,true) 
    LoginButton = guiCreateButton(35,259,306,52,"Zaloguj!",false,LoginGUI) 
    RegisterButton = guiCreateButton(35,330,306,52,"Zarejesrtuj!",false,LoginGUI) 
     
    guiSetVisible(LoginGUI, false) 
     
    addEventHandler("onClientGUIClick", LoginButton, submitLogin, false) 
    addEventHandler("onClientGUIClick", RegisterButton, registerPlayer, false) 
end 
  
function startLoginRegisterModule() 
    createLoginBox() 
     
    if (LoginGUI ~= nil) then 
        guiSetVisible(LoginGUI, true) 
    else 
        outputDebugString("Nie moge utworzyc GUI odpowiedzialnego od Logowania/Rejestracji!", 3, 255, 0, 0) 
    end  
     
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginRegisterModule) 
  
function submitLogin(button, state) 
    if button == "left" and state == "up" then 
         
        local login = guiGetText(LoginBox) 
        local pass = guiGetText(PassBox) 
  
        if login and pass then 
            triggerServerEvent("submitLoginServer", getRootElement(), login, pass) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(LoginGUI, false) 
            showCursor(false) 
        else 
            outputChatBox("#EE5555* #C0C0C0Proszę wpisać #EE5555Login #C0C0C0i #EE5555Hasło#C0C0C0!") 
        end 
    end 
end 

Server-side:

  
function loginHandler(login, pass) 
mysql = dbConnect("mysql", "dbname=mta;host=192.166.219.226", "damiano", "Censored", "share=1") 
  
if(mysql) then 
    outputServerLog("\n[MySQL] Pomyslnie polaczono z MySQL!") 
    outputDebugString("Pomyslnie polaczono z MySQL!", 3, 0, 224, 0) 
    else 
    outputServerLog("\n[MySQL] Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...") 
    outputDebugString("Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...", 3, 255, 0, 0) 
    destroyElement(mysql) 
end 
  
local acc = dbQuery(mysql, "SELECT * FROM `accounts` WHERE `account` = `%s` AND `password` = `%s`", login, pass) 
local result = dbPoll(acc, 0) 
  
    if result then 
        if client then 
            spawnPlayer(client, 1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
            setCameraTarget(client, client) 
        end 
    else 
        outputChatBox("#EE5555* #C0C0C0Podano zły #EE5555Login #C0C0C0lub #EE5555Hasło#C0C0C0!") 
    end      
end 
addEvent("submitLoginServer", true) 
addEventHandler("submitLoginServer", root, loginHandler) 

Can you make for me, when player write bad login or pass, GUI will not hide?

BUG: My account is in DB, but when i loging, i see message "Bad login or pass".

How to fix?

Link to comment

I'm using now mysql module, my code:

  
function createLoginBox() 
    LoginGUI = guiCreateWindow(527,159,380,407,"Truck - Logowanie",false) 
    guiSetAlpha(LoginGUI,0.69999998807907) 
    guiWindowSetSizable(LoginGUI,false) 
    IntroLabel = guiCreateLabel(47,62,290,32,"                       Witamy na Truck!\nWpisz poniżej Login oraz Hasło, aby się zalogować!",false,LoginGUI) 
    guiSetFont(IntroLabel,"default-bold-small") 
    LoginLabel = guiCreateLabel(76,181,38,16,"Login:",false,LoginGUI) 
    guiSetFont(LoginLabel,"default-bold-small") 
    PassLabel = guiCreateLabel(72,218,40,16,"Hasło:",false,LoginGUI) 
    guiSetFont(PassLabel,"default-bold-small") 
    LoginBox = guiCreateEdit(128,179,137,19,"",false,LoginGUI) 
    PassBox = guiCreateEdit(129,216,137,19,"",false,LoginGUI) 
    guiEditSetMasked(PassBox,true) 
    LoginButton = guiCreateButton(35,259,306,52,"Zaloguj!",false,LoginGUI) 
    RegisterButton = guiCreateButton(35,330,306,52,"Zarejesrtuj!",false,LoginGUI) 
    
    guiSetVisible(LoginGUI, false) 
    
    addEventHandler("onClientGUIClick", LoginButton, submitLogin, false) 
    addEventHandler("onClientGUIClick", RegisterButton, registerPlayer, false) 
end 
  
function startLoginRegisterModule() 
    createLoginBox() 
    
    if (LoginGUI ~= nil) then 
        guiSetVisible(LoginGUI, true) 
    else 
        outputDebugString("Nie moge utworzyc GUI odpowiedzialnego od Logowania/Rejestracji!", 3, 255, 0, 0) 
    end 
    
    showCursor(true) 
    guiSetInputEnabled(true) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginRegisterModule) 
  
function submitLogin(button, state) 
    if button == "left" and state == "up" then 
        
        local login = guiGetText(LoginBox) 
        local pass = guiGetText(PassBox) 
  
        if login and pass then 
            triggerServerEvent("submitLoginServer", getRootElement(), login, pass) 
  
            guiSetInputEnabled(false) 
            guiSetVisible(LoginGUI, false) 
            showCursor(false) 
        else 
            outputChatBox("#EE5555* #C0C0C0Proszę wpisać #EE5555Login #C0C0C0i #EE5555Hasło#C0C0C0!") 
        end 
    end 
end 

  
  
function loginHandler(login, pass) 
local acc = mysql_query(connect, "SELECT * FROM `accounts` WHERE `accounts` = '%s' AND `password` = '%s'", login, pass) 
    if result then 
        if client then 
            spawnPlayer(client, 1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
            setCameraTarget(client, client) 
        end 
    else 
        outputChatBox("#EE5555* #C0C0C0Podano zły #EE5555Login #C0C0C0lub #EE5555Hasło#C0C0C0!", client) 
    end     
end 
addEvent("submitLoginServer", true) 
addEventHandler("submitLoginServer", root, loginHandler) 

Link to comment

Connect:

mysql = mysql_connect("localhost", "root", "", "truck") 
  
if(mysql) then 
    outputServerLog("\n[MySQL] Pomyslnie polaczono z MySQL!") 
    outputDebugString("Pomyslnie polaczono z MySQL!", 3, 0, 224, 0) 
    else 
    outputServerLog("\n[MySQL] Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...") 
    outputDebugString("Wystapil blad podczas laczenia z MySQL! Polaczenie zostalo zerwane...", 3, 255, 0, 0) 
    mysql_close(mysql) 
end 

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