2013martin1212 Posted August 27, 2015 Share Posted August 27, 2015 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
KariiiM Posted August 27, 2015 Share Posted August 27, 2015 Any Error in debugscript / console? Link to comment
2013martin1212 Posted August 27, 2015 Author Share Posted August 27, 2015 Its give me this when i press the button A képet a Képfeltöltés.hu tárolja. http://www.kepfeltoltes.hu Link to comment
KariiiM Posted August 27, 2015 Share Posted August 27, 2015 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
2013martin1212 Posted August 27, 2015 Author Share Posted August 27, 2015 Bad argument guiGetText at 47 and 48 lines Link to comment
LoOs Posted August 27, 2015 Share Posted August 27, 2015 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
2013martin1212 Posted August 27, 2015 Author Share Posted August 27, 2015 Now its give me an error at server.lua line 6 attemp to call global 'getElementType' (a nil value ) Link to comment
KariiiM Posted August 27, 2015 Share Posted August 27, 2015 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
LoOs Posted August 27, 2015 Share Posted August 27, 2015 if getElementTpe(thePlayer) == "player" then getElementTpe ? Replace getElementType Link to comment
KariiiM Posted August 27, 2015 Share Posted August 27, 2015 if getElementTpe(thePlayer) == "player" thengetElementTpe ? Replace getElementType Yes you're right about this point, if the function is typed wrong then you can't check the player @martine and try what i sent to you Link to comment
2013martin1212 Posted August 27, 2015 Author Share Posted August 27, 2015 Now i get this debug problem A képet a Képfeltöltés.hu tárolja. http://www.kepfeltoltes.hu Link to comment
HUNGRY:3 Posted August 27, 2015 Share Posted August 27, 2015 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
2013martin1212 Posted August 27, 2015 Author Share Posted August 27, 2015 now i get another problem A képet a Képfeltöltés.hu tárolja. http://www.kepfeltoltes.hu Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now