Bacchus Posted July 16, 2015 Share Posted July 16, 2015 (edited) Hello, I have created a GUI Window and I would like to test the onClientGUIClick event but when I click on the button, nothing happen : Client Side -- Auteur : Bacchus -- Script : Connexion (client ) -- Version : 1.0 -- Constantes local GUIEditor = { button = {}, window = {}, edit = {}, label = {} } -- Création de la fenêtre de connexion function create_connection_windows() GUIEditor.window[1] = guiCreateWindow(0.42, 0.40, 0.18, 0.16, "Connexion au serveur", true) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(0.06, 0.14, 0.88, 0.23, "Mot de passe", true, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[1], "center") GUIEditor.edit[1] = guiCreateEdit(0.06, 0.39, 0.89, 0.19, "", true, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[1], true) GUIEditor.button[1] = guiCreateButton(0.06, 0.71, 0.87, 0.25, "Connexion", true, GUIEditor.window[1]) guiSetVisible( GUIEditor.window[1], false ) end -- Afficher la fenêtre de connexion function connection_windows() create_connection_windows() guiSetVisible( GUIEditor.window[1], true ) showCursor( true ) guiSetInputEnabled( true ) end addEvent( "onPlayerAttemptToConnect", true ) addEventHandler( "onPlayerAttemptToConnect", localPlayer, connection_windows ) -- Tentative de connexion ... function trying_to_connect( button, state ) outputChatBox( "test", localPlayer ) end addEventHandler( "onClientGUIClick", GUIEditor.button[1], trying_to_connect, false ) Server side -- Auteur : Bacchus -- Script : Authentification -- Version : 1.0 -- Constantes local connection = exports.db:getDatabase() addEventHandler( "onPlayerJoin", getRootElement(), function() local query = dbQuery( connection, "SELECT * FROM account WHERE username = ?", getPlayerName( source ) ) local result, num_affected_rows, last_insert_id = dbPoll( query, -1 ) if num_affected_rows >= 1 then triggerClientEvent( source, "onPlayerAttemptToConnect", source ) else triggerClientEvent( source, "onUnregAccount", source ) end end ) In fact, the window appears, but when I click on "Connexion" button, nothing happens. (It should send a "test" message to the client in fact) Do you know where's the bug? Regards, Edited July 16, 2015 by Guest Link to comment
Bacchus Posted July 16, 2015 Author Share Posted July 16, 2015 Hey, Problem solved. In fact, I put the addEventHandler( "onClientGUIClick") inside the function that creates the window. 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