Jump to content

[HELP] A few buttons in function


Erlkonig

Recommended Posts

Posted (edited)

Hello, I have a similar functions which activated when the client clicked on the button. Now Im calling they like different functions.

 

addEventHandler("onClientGUIClick", ctrl[1], setCtrl1, false)
addEventHandler("onClientGUIClick", ctrl[2], setCtrl2, false)
addEventHandler("onClientGUIClick", ctrl[3], setCtrl3, false)

 

I want to call one function when I push the different buttons

addEventHandler("onClientGUIClick", ctrl[1], setCtrl, false)
addEventHandler("onClientGUIClick", ctrl[2], setCtrl, false)
addEventHandler("onClientGUIClick", ctrl[3], setCtrl, false)

But also I want to do this with a different actions in function. Unfortunely, I did not found the way how can I check the button which clicked. 

Im planing to do something like this:

-- This just an example

function()

    if ctrl[1] then
      --do something
    elseif ctrl[2] then
      --do anything
    elseif ctrl[3] then
      --do this but it actually looks like previous
    end

end

addEventHandler("onClientGUIClick", ctrl[1], setCtrl, false)
addEventHandler("onClientGUIClick", ctrl[2], setCtrl, false)
addEventHandler("onClientGUIClick", ctrl[3], setCtrl, false)

 

Edited by Erlkonig
Posted
addEventHandler("onClientGUIClick", resourceRoot, function()
    if source == ctrl[1] then
        -- do something
    elseif source == ctrl[2] then
        -- do something else
        --etc...
    end
end, false)

 

  • Like 1
Posted
3 minutes ago, Tekken said:


addEventHandler("onClientGUIClick", resourceRoot, function()
    if source == ctrl[1] then
        -- do something
    elseif source == ctrl[2] then
        -- do something else
        --etc...
    end
end, false)

 

Sure! Thank you!

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