flashman Posted June 27, 2013 Share Posted June 27, 2013 Hi. I made a GUI with the GUIcreator and used some other script to make the login button. Client: GUIEditor.window[1] = guiCreateWindow(0.37, 0.28, 0.23, 0.35, "", true) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(0.03, 0.85, 0.46, 0.11, "LOGIN", true, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF7F7D7D") GUIEditor.button[2] = guiCreateButton(0.51, 0.85, 0.45, 0.11, "REGISTER", true, GUIEditor.window[1]) GUIEditor.edit[1] = guiCreateEdit(0.12, 0.72, 0.78, 0.08, "", true, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[1] = guiCreateLabel(0.40, 0.67, 0.22, 0.04, "Password:", true, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.staticimage[1] = guiCreateStaticImage(0.03, 0.06, 0.93, 0.43, ":guieditor/images/examples/mtalogo.png", true, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(0.12, 0.56, 0.78, 0.08, "", true, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.label[2] = guiCreateLabel(0.40, 0.52, 0.22, 0.04, "Username:", true, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") function playerJoin() guiSetVisible(GUIEditor.window[1], true ) showCursor( true ) guiSetInputEnabled( true ) setCameraMatrix( -1799.6999511719, 1856.5999755859, 30.39999961853, -1763.9000244141, 1852.5999755859, 19.799999237061 ) fadeCamera (true) end addEvent("onJoin", true) addEventHandler("onJoin", getRootElement(), playerJoin) function closeWindow() guiSetVisible(GUIEditor.window[1], false ) showCursor( false ) guiSetInputEnabled( false ) end addEvent("closeWindow", true) addEventHandler("closeWindow", getRootElement(), closeWindow) function login_player ( source ) triggerServerEvent ( "onLogin", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2])) end addEventHandler("onClientGUIClick", GUIEditor.button[1], login_player,false) Server: -- Default host = "127.0.0.1" -- Database Host username = "root" -- Database Username password = "" -- Database Password db = "accounts" -- Database ( Where you got your tables ) handler = mysql_connect( host, username, password, db ) addEventHandler("onPlayerJoin", getRootElement(), function() triggerClientEvent(source, "onJoin", getRootElement()) end ) function onLogin ( player, user, pass ) handler = mysql_connect( host, username, password, db ) local login = mysql_query(handler,"SELECT * FROM account_data WHERE AccountName = '"..mysql_escape_string( handler, user ).."' AND Password = '"..mysql_escape_string( handler, md5(pass) ).."';") if login then local rows = mysql_num_rows(login) if rows == 1 then triggerClientEvent( player, "closeWindow", getRootElement() ) outputChatBox("* You successfully logged in your account!", player, 255, 255, 255) spawnPlayer( player, 0,0,3 ) fadeCamera( player, true ) setCameraTarget( player, player ) else outputChatBox("* Login failed!", player, 255, 255, 255) end mysql_free_result(login) end end addEvent( "onLogin", true ) addEventHandler( "onLogin", getRootElement(), onLogin ) Meta: type="script" author="Risto" name="Login Register System (MySQL)" version="1.0"/> But when I go in game no gui is displayed for me. Link to comment
Castillo Posted June 27, 2013 Share Posted June 27, 2013 Where's "GUIEditor" table defined? Link to comment
flashman Posted June 27, 2013 Author Share Posted June 27, 2013 I cant understand you very well.. this is all the files I have, I just copy the gui from GUIeditor. C:\Program Files (x86)\MTA San Andreas 1.3\server\mods\deathmatch\resources\guieditor C:\Program Files (x86)\MTA San Andreas 1.3\server\mods\deathmatch\resources\loginsystem Link to comment
Castillo Posted June 27, 2013 Share Posted June 27, 2013 The client side you posted is all you got? if so, then you've got missing the GUIeditor table generated along with the GUI. Link to comment
flashman Posted June 27, 2013 Author Share Posted June 27, 2013 (edited) Thank you very much, Castillo. I don't know why, but I had deleted the part. I really appreciate that you found some time to help me Edited June 27, 2013 by Guest Link to comment
xXMADEXx Posted June 27, 2013 Share Posted June 27, 2013 You should use the default MTA DB functions, not the module.. https://wiki.multitheftauto.com/wiki/Se ... _functions Link to comment
flashman Posted June 28, 2013 Author Share Posted June 28, 2013 Hi: GUIEditor = { staticimage = {}, edit = {}, button = {}, window = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0.37, 0.28, 0.23, 0.35, "", true) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(0.03, 0.85, 0.46, 0.11, "LOGIN", true, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF7F7D7D") GUIEditor.button[2] = guiCreateButton(0.51, 0.85, 0.45, 0.11, "REGISTER", true, GUIEditor.window[1]) GUIEditor.edit[1] = guiCreateEdit(0.12, 0.72, 0.78, 0.08, "", true, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.label[1] = guiCreateLabel(0.40, 0.67, 0.22, 0.04, "Password:", true, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.staticimage[1] = guiCreateStaticImage(0.03, 0.06, 0.93, 0.43, ":loginsystem/mtalogo.png", true, GUIEditor.window[1]) GUIEditor.edit[2] = guiCreateEdit(0.12, 0.56, 0.78, 0.08, "", true, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], false)--username GUIEditor.label[2] = guiCreateLabel(0.40, 0.52, 0.22, 0.04, "Username:", true, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") end ) function playerJoin() guiSetVisible(GUIEditor.window[1], true ) showCursor( true ) guiSetInputEnabled( true ) setCameraMatrix( -1799.6999511719, 1856.5999755859, 30.39999961853, -1763.9000244141, 1852.5999755859, 19.799999237061 ) fadeCamera (true) outputChatBox("Player joined.") end addEvent("onJoin", true) addEventHandler("onJoin", getRootElement(), playerJoin) function closeWindow() guiSetVisible(GUIEditor.window[1], false ) showCursor( false ) guiSetInputEnabled( false ) end addEvent("closeWindow", true) addEventHandler("closeWindow", getRootElement(), closeWindow) function login_player ( source ) outputChatBox("Player clicked on login button, executing server part.") triggerServerEvent ( "onLogin", getRootElement(), getLocalPlayer(), guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2])) end addEventHandler("onClientGUIClick", GUIEditor.button[1], login_player, false) -- button 2 is username That part is not working: "outputChatBox("Player clicked on login button, executing server part.")". The message does not get sent, but the join message does, what's wrong? Link to comment
Castillo Posted June 28, 2013 Share Posted June 28, 2013 addEventHandler("onClientGUIClick", GUIEditor.button[1], login_player, false) -- button 2 is username That has to go inside the onClientResourceStart function. 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