Jump to content

GUI question


DakiLLa

Recommended Posts

is it possible to check if gui button already clicked ?

Buttons are just like any other components elements in the MTA world. This means that you can set data. Meaning you have more than one options to keep track of "clicks".

  
setElementData(button, "clicks", count) 
clicks = getElementData(button, "clicks") 
  

Link to comment
is it possible to check if gui button already clicked ?

How do you mean that? That if you press the same button again something else happens? I always use a global variable for that. ^^

if isButtonAlreadyClicked~=true then 
    outputChatBox("You clicked the button!!!!") 
    isButtonAlreadyPressed=true 
else 
    outputChatBox("You already clicked the button fool! -.-") 
end 

Due to another post in the meantime because I'm so SLOOOOOOOOOW with typing: xD

Or what Ace said also is a possibility.

Link to comment
  • 2 weeks later...

how can i set visibility of button for all players not for only local player ?

.... 
if ( source == ButtonOne ) then 
            guiSetVisible ( ButtonOne, false ) 

this disable button only for one player, who clicked buttonOne, but how to disable this button for all players when anybody clicked on it? i think it's not possible or not?

Edited by Guest
Link to comment
how can i set visibility of button for all players not for only local player ?
  
.... 
if ( source == ButtonOne ) then 
            guiSetVisible ( ButtonOne, false ) 
  

this disable button only for one player, who clicked buttonOne, but how to disable this button for all players when anybody clicked on it? i think it's not possible or not?

You need to do triggerServerEvent and then something like...

function letsDisableThisForAllPlayers() 
    outputChatBox("Warning: " .. getClientName(source) .. " pushed the big button!") 
    triggerClientEvent(getRootElement(),"disableTheBigButton",source) 
end 
addEvent("onBigButtonPressed",true) 
addEventHandler("onBigButtonPressed",getRootElement(),letsDisableThisForAllPlayers) 

Only parts you need to add:

--triggerServerEvent when the button is pressed.

--addEvent and addEventHandler in client-side, for "onBigButtonPressed" to work.

That should work. Not tested though since I'm at school... -.-

EDIT: Line 2 fixed for as far as I can see... =/

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