Jump to content

Please Help


Recommended Posts

I try to create a mysql login panel the connection was work now , but dont let me to log in :( please help to figure out the problem

my clien side is :

-----* Created by Core  
-----* cG_AccountSystem client.lua file. 
  
local X = 0.375 
local Y = 0.375 
     
local Width = 0.25 
local Height = 0.25 
     
local alap = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) 
local userNameClick =  guiCreateEdit(60, 60, 250, 30, "Username", false, alap) 
guiSetAlpha(userNameClick,1) 
local passWordClick =  guiCreateEdit(60, 120, 250, 30, "Password", false, alap) 
local loginClick =  guiCreateButton(80, 160, 200, 50, "Log In", false, alap) -- x, y, z, meret 
local timeElapsed = 0 
guiSetInputMode("no_binds") 
fadeCamera(true, 0.5) 
showCursor(true) 
local userNameTable = {} 
local passWordTable = {} 
  
function cC() 
    for i = 0, 25 do  
        outputChatBox(" ") 
    end 
    outputChatBox("#FFFFFFÜdvözöllek a #217AA2Core Game System #FFFFFFszerveren " .. getPlayerName(localPlayer) .. ".", 0, 0, 0, true) 
end 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
     
    guiSetText(userNameClick, "") 
    guiSetText(userNameClick, "") 
     
    guiSetText(userNameClick, playername) 
    guiSetText(userNameClick, playername) 
  
    guiSetVisible (  alap, true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
  
function onClickBtn ( button, state ) 
    if (source == loginClick) then 
        triggerServerEvent ( "logIn", getRootElement(), localPlayer, guiGetText(LoginUsername), guiGetText(LoginPassword) ) 
    end 
end 
  
  
  
function hideLGP() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLGP", true ) 
addEventHandler( "hideLGP", getRootElement(), hideLGP ) 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
  
addEventHandler ( "onClientGUIClick", loginClick, onClickBtn, false ) 
  
  
  

My Server side

local mysql = exports.cG_MySQL 
  
  
function logThePlayer(thePlayer, username, password) 
    if thePlayer and username and password then 
        if getElementTpe(thePlayer) == "player" then 
            local account = mysql:dbQuery("SELECT * FROM accounts WHERE username='" .. username .. "'") 
            for i, sor in ipairs(account) do 
                if sor["password"] == password then 
                local lastLogin = getRealTime() 
                if tostring(lastLogin.month+1):len() < 2 then 
                    lastLogin.month = "0" ..tostring(lastLogin.month)+1 
                end 
                if tostring(lastLogin.monthday):len() < 2 then 
                    lastLogin.monthday = "0" ..tostring(lastLogin.monthday) 
                end 
                local lastLoginText = tostring(lastLogin.year+1900 .. "-" .. lastLogin.month .. "-" .. lastLogin.monthday) 
                    mysql:dbQuery("UPDATE accounts SET LastLogin='" .. lastLoginText .. "' WHERE username='" .. username .. "'" ) 
                    --egyenlore csak a utolso belepest elenorzi 
                     
                    local character = mysql:dbQuery("SELECT * FROM characters WHERE accountname='" .. username .. "'") 
                        if character then  
                        outputChatBox("van karaktered") 
                        else outputChatBox("meg nincs karaktered") 
                end 
                else 
                    triggerClientEvent(thePlayer, "hideLGP", getRootElement()) 
                end 
            end 
        end 
    end 
end 
addEvent("logIn", true) 
addEventHandler("logIn", getRootElement(), logThePlayer) 

Link to comment

Try this

--client side

-----* Created by Core 
-----* cG_AccountSystem client.lua file. 
  
local X = 0.375 
local Y = 0.375 
    
local Width = 0.25 
local Height = 0.25 
    
local alap = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) 
local userNameClick =  guiCreateEdit(60, 60, 250, 30, "Username", false, alap) 
guiSetAlpha(userNameClick,1) 
local passWordClick =  guiCreateEdit(60, 120, 250, 30, "Password", false, alap) 
local loginClick =  guiCreateButton(80, 160, 200, 50, "Log In", false, alap) -- x, y, z, meret 
local timeElapsed = 0 
guiSetInputMode("no_binds") 
fadeCamera(true, 0.5) 
showCursor(true) 
local userNameTable = {} 
local passWordTable = {} 
  
function cC() 
    for i = 0, 25 do 
        outputChatBox(" ") 
    end 
    outputChatBox("#FFFFFFÜdvözöllek a #217AA2Core Game System #FFFFFFszerveren " .. getPlayerName(localPlayer) .. ".", 0, 0, 0, true) 
end 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
    
    guiSetText(userNameClick, "") 
    guiSetText(userNameClick, "") 
    
    guiSetText(userNameClick, playername) 
    guiSetText(userNameClick, playername) 
  
    guiSetVisible (  alap, true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
  
function onClickBtn ( button, state ) 
if button == "left" and state == "up" then 
    if (source == loginClick) then 
        local username = guiGetText(LoginUsername) 
        local password = guiGetText(LoginPassword) 
        if username and password then 
        showChat(true) 
        triggerServerEvent ( "logIn", getRootElement(), localPlayer, username, password ) 
        else 
        outputChatBox ("Enter unsername and password!",255,0,0) 
          end  
       end 
   end 
end 
   
function hideLGP() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLGP", true ) 
addEventHandler( "hideLGP", getRootElement(), hideLGP ) 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
addEventHandler ( "onClientGUIClick", loginClick, onClickBtn, false ) 

Link to comment

edit :#

local X = 0.375 
local Y = 0.375 
    
local Width = 0.25 
local Height = 0.25 
    
local alap = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) 
local userNameClick =  guiCreateEdit(60, 60, 250, 30, "Username", false, alap) 
guiSetAlpha(userNameClick,1) 
local passWordClick =  guiCreateEdit(60, 120, 250, 30, "Password", false, alap) 
local loginClick =  guiCreateButton(80, 160, 200, 50, "Log In", false, alap) -- x, y, z, meret 
local timeElapsed = 0 
guiSetInputMode("no_binds") 
fadeCamera(true, 0.5) 
showCursor(true) 
local userNameTable = {} 
local passWordTable = {} 
  
function cC() 
    for i = 0, 25 do 
        outputChatBox(" ") 
    end 
    outputChatBox("#FFFFFFÜdvözöllek a #217AA2Core Game System #FFFFFFszerveren " .. getPlayerName(localPlayer) .. ".", 0, 0, 0, true) 
end 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
    
    guiSetText(userNameClick, "") 
    guiSetText(userNameClick, "") 
    
    guiSetText(userNameClick, playername) 
    guiSetText(userNameClick, playername) 
  
    guiSetVisible (  alap, true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
  
function onClickBtn ( button, state ) 
if button == "left" and state == "up" then 
    if (source == loginClick) then 
        local username = guiGetText(userNameClick) 
        local password = guiGetText(passWordClick) 
        if username and password then 
        showChat(true) 
        triggerServerEvent ( "logIn", getRootElement(), localPlayer, username, password ) 
        else 
        outputChatBox ("Enter unsername and password!",255,0,0) 
          end 
       end 
   end 
end 
  
function hideLGP() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLGP", true ) 
addEventHandler( "hideLGP", getRootElement(), hideLGP ) 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
addEventHandler ( "onClientGUIClick", loginClick, onClickBtn, false ) 

Link to comment

I think i got it, the problem is in client side not in server side

-----* Created by Core 
-----* cG_AccountSystem client.lua file. 
  
local X = 0.375 
local Y = 0.375 
    
local Width = 0.25 
local Height = 0.25 
    
local alap = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) 
local userNameClick =  guiCreateEdit(60, 60, 250, 30, "Username", false, alap) 
guiSetAlpha(userNameClick,1) 
guiEditSetMaxLength(userNameClick, 50) 
local passWordClick =  guiCreateEdit(60, 120, 250, 30, "Password", false, alap) 
guiSetAlpha(passWordClick,1) 
guiEditSetMaxLength(passWordClick, 50) 
local loginClick =  guiCreateButton(80, 160, 200, 50, "Log In", false, alap) -- x, y, z, meret 
  
editUsername = guiCreateEdit(79,52,181,25,"",false,windowLogin) 
     
local timeElapsed = 0 
guiSetInputMode("no_binds") 
fadeCamera(true, 0.5) 
showCursor(true) 
local userNameTable = {} 
local passWordTable = {} 
  
function cC() 
    for i = 0, 25 do 
        outputChatBox(" ") 
    end 
    outputChatBox("#FFFFFFÜdvözöllek a #217AA2Core Game System #FFFFFFszerveren " .. getPlayerName(localPlayer) .. ".", 0, 0, 0, true) 
end 
  
function windowHandler( ) 
    local playername = getPlayerName(localPlayer) 
    
    guiSetText(userNameClick, "") 
    guiSetText(userNameClick, "") 
    
    guiSetText(userNameClick, playername) 
    guiSetText(userNameClick, playername) 
  
    guiSetVisible (  alap, true ) 
  
    guiSetInputEnabled(true) 
    showCursor ( true ) 
end 
  
function onClickBtn ( button, state ) 
if button == "left" and state == "up" then 
    if (source == loginClick) then 
        local username = guiGetText(userNameClick) 
        local password = guiGetText(passWordClick) 
        if username and password then 
        showChat(true) 
        triggerServerEvent ( "logIn", getRootElement(), localPlayer, username, password ) 
        else 
        outputChatBox ("Enter unsername and password!",255,0,0) 
          end 
       end 
   end 
end 
  
function hideLGP() 
    guiSetInputEnabled(false) 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    showCursor ( false ) 
end 
addEvent( "hideLGP", true ) 
addEventHandler( "hideLGP", getRootElement(), hideLGP ) 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler ) 
addEventHandler ( "onClientGUIClick", loginClick, onClickBtn, false ) 

Link to comment
local mysql = exports.cG_MySQL 
  
  
function logThePlayer(thePlayer, username, password) 
    if thePlayer and username and password then 
        if getElementType(thePlayer) == "player" then 
            local account = mysql:dbQuery("SELECT * FROM accounts WHERE username='" .. username .. "'") 
            for i, sor in ipairs(account) do 
                if sor["password"] == password then 
                local lastLogin = getRealTime() 
                if tostring(lastLogin.month+1):len() < 2 then 
                    lastLogin.month = "0" ..tostring(lastLogin.month)+1 
                end 
                if tostring(lastLogin.monthday):len() < 2 then 
                    lastLogin.monthday = "0" ..tostring(lastLogin.monthday) 
                end 
                local lastLoginText = tostring(lastLogin.year+1900 .. "-" .. lastLogin.month .. "-" .. lastLogin.monthday) 
                    mysql:dbQuery("UPDATE accounts SET LastLogin='" .. lastLoginText .. "' WHERE username='" .. username .. "'" ) 
                    --egyenlore csak a utolso belepest elenorzi 
                    
                    local character = mysql:dbQuery("SELECT * FROM characters WHERE accountname='" .. username .. "'") 
                        if character then 
                        outputChatBox("van karaktered") 
                        else outputChatBox("meg nincs karaktered") 
                end 
                else 
                    triggerClientEvent(thePlayer, "hideLGP", getRootElement()) 
                end 
            end 
        end 
    end 
end 
addEvent("logIn", true) 
addEventHandler("logIn", getRootElement(), logThePlayer) 

lol

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