Jump to content

[HELP] On button clicked


Recommended Posts

Posted

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?

76561198066470453.png

SP37Ecj.jpg?2MTA:Rust Pre-Alpha Build v.0.3:SP37Ecj.jpg?2

https://forum.mtasa.com/viewtopic.php?f=114&t=97848

2Pac: ''Only God can judge me!''

Posted
addEventHandler ( "onClientGUIClick", butAjutor, 
    function ( ) 
        outputChatBox ( "THE BUTTON WAS CLICKED!" ) 
    end 
    ,false 
) 

That'll output a chatbox message when you click that button.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Why it won't work? you can export the function from one resource and use it in another.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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") 

Posted

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 
) 

76561198066470453.png

SP37Ecj.jpg?2MTA:Rust Pre-Alpha Build v.0.3:SP37Ecj.jpg?2

https://forum.mtasa.com/viewtopic.php?f=114&t=97848

2Pac: ''Only God can judge me!''

Posted
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
 

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

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