..:D&G:.. Posted June 30, 2013 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?
..:D&G:.. Posted June 30, 2013 Author Posted June 30, 2013 This confuses me a bit, where do I put the name of the button? ''butAjutor'' triggerServerEvent ( "showHelp", getLocalPlayer( ), butAjutor, true )
..:D&G:.. Posted June 30, 2013 Author 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..
Castillo Posted June 30, 2013 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.
..:D&G:.. Posted July 4, 2013 Author Posted July 4, 2013 The function that I want to call is in another resource, that won't work..
Castillo Posted July 4, 2013 Posted July 4, 2013 Why it won't work? you can export the function from one resource and use it in another.
mcer Posted July 4, 2013 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")
..:D&G:.. Posted July 5, 2013 Author 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 )
#Al-Ha[J]aRii Posted July 5, 2013 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
mcer Posted July 5, 2013 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
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