Jump to content

[HELP] On button clicked


Recommended Posts

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
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

This is what I tried to make, but only the outputChatBox works :P

addEventHandler ( "onClientGUIClick", butAjutor, 
    function ( ) 
        outputChatBox ( "THE BUTTON WAS CLICKED!" ) 
        triggerServerEvent("onClientCallsServerFunction", help , toggleHelp) 
    end 
    ,false 
) 

Link to comment
This is what I tried to make, but only the outputChatBox works :P
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...