..:D&G:.. Posted June 30, 2013 Share Posted June 30, 2013 Hello, I have a script that pops up a window with help. I also have other script that shows information about the server. I made a button for the help script, when clicked the window should close and the info script should acctivate. Button: local butAjutor = guiCreateButton(601, 28, 133, 33, "Ajutor De Început", false, myWindow) I want the button to execute this: - This currently works on a command function toggleHelp( thePlayer, commandName ) The toggleHelp function is on server side in a script, and the button is on client side on another script.. How do I connect this 2? Link to comment
DiSaMe Posted June 30, 2013 Share Posted June 30, 2013 addEvent addEventHandler triggerServerEvent Link to comment
..:D&G:.. Posted June 30, 2013 Author Share Posted June 30, 2013 This confuses me a bit, where do I put the name of the button? ''butAjutor'' triggerServerEvent ( "showHelp", getLocalPlayer( ), butAjutor, true ) Link to comment
iPrestege Posted June 30, 2013 Share Posted June 30, 2013 Using : onClientGUIClick Event. Link to comment
..:D&G:.. Posted June 30, 2013 Author Share Posted June 30, 2013 Can you make it for me please, its the first time I see/use this code And the example from WIKI confuses.. Link to comment
Castillo Posted June 30, 2013 Share Posted June 30, 2013 addEventHandler ( "onClientGUIClick", butAjutor, function ( ) outputChatBox ( "THE BUTTON WAS CLICKED!" ) end ,false ) That'll output a chatbox message when you click that button. Link to comment
..:D&G:.. Posted July 4, 2013 Author Share Posted July 4, 2013 The function that I want to call is in another resource, that won't work.. Link to comment
Castillo Posted July 4, 2013 Share Posted July 4, 2013 Why it won't work? you can export the function from one resource and use it in another. Link to comment
mcer Posted July 4, 2013 Share Posted July 4, 2013 addEventHandler ( "onClientGUIClick", butAjutor, function ( ) outputChatBox ( "THE BUTTON WAS CLICKED!" ) end ,false ) That'll output a chatbox message when you click that button. Copy that in Clientside script. I want the button to execute this: - This currently works on a command function toggleHelp( thePlayer, commandName ) The toggleHelp function is on server side in a script, and the button is on client side on another script.. How do I connect this 2? I think this going to work: callServerFunction(":ResourceName/Function") Link to comment
..:D&G:.. Posted July 5, 2013 Author Share Posted July 5, 2013 This is what I tried to make, but only the outputChatBox works addEventHandler ( "onClientGUIClick", butAjutor, function ( ) outputChatBox ( "THE BUTTON WAS CLICKED!" ) triggerServerEvent("onClientCallsServerFunction", help , toggleHelp) end ,false ) Link to comment
#Al-Ha[J]aRii Posted July 5, 2013 Share Posted July 5, 2013 This is what I tried to make, but only the outputChatBox works addEventHandler ( "onClientGUIClick", butAjutor, function ( ) outputChatBox ( "THE BUTTON WAS CLICKED!" ) triggerServerEvent("onClientCallsServerFunction", help , toggleHelp) end ,false ) you must add the event you maked triggered to server side + you'r trigger must be like this triggerServerEvent("onClientCallsServerFunction", localPlayer) and in server side : addEvent("onClientCallsServerFunction",true) addEventHandler("onClientCallsServerFunction",getRootElement( ), function () -------- your code end Link to comment
mcer Posted July 5, 2013 Share Posted July 5, 2013 This is what I tried to make, but only the outputChatBox works addEventHandler ( "onClientGUIClick", butAjutor, function ( ) outputChatBox ( "THE BUTTON WAS CLICKED!" ) triggerServerEvent("onClientCallsServerFunction", help , toggleHelp) end ,false ) See the examples: https://wiki.multitheftauto.com/wiki/TriggerServerEvent 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