SOLVED: Diasble a gui button after it has been mouse clicked x amount of times..

Started by barefoot, Mon 02/05/2011 06:36:57

Previous topic - Next topic

barefoot

Hi

Iv'e looked here, on internet and tried scripting but to no avail so far.

I'm trying to disable a gui button after it has been mouse clicked x amount of times..

I have a score system set up which affects score if conditions are met (after button has been clicked on);

I don't need it disabled when score reaches x.. (which can be easily done) as i have other buttons which can affect the score also.

I have 7 buttons that i need to check how many times they've been mouse clicked on.

I am also looking into variables (ints) for a way if this be a solution.

Have made Variable: fire, int...  I think i need a way to take one off each time a button is clicked on and disable button when it reached 0.

cheers for any guidance.

barefoot










I May Not Be Perfect but I Have A Big Heart ..

monkey0506

You can use an array for this:

Code: ags
// top of script
int clicked[7];

function Button1_Click(GUIControl *control, MouseButton button)
{
  clicked[0]++;
  if (clicked[0] == 5) Button1.Enabled = false; // if button 1 was clicked 5 times, disable it
}

function Button2_Click(GUIControl *control, MouseButton button)
{
  clicked[1]++;
  if (clicked[1] == 3) Button2.Enabled = false; // if button 2 was clicked 3 times, disable it
}

// . . .

function Button7_Click(GUIControl *control, MouseButton button)
{
  clicked[6]++;
  if (clicked[6] == 4) Button7.Enabled = false; // if button 7 was clicked 4 times, disable it
}


Since you have 7 buttons, you make the array have seven slots. Then you just use one slot for each button, and update when it gets clicked on. This isn't actually that difficult when you approach it the right way. ;)

barefoot

Thank you very much Monkey

Update: after some tweaking it works a treat  :=

------------------------------------------------

I had this idea in mind but was a little unsure of doing it..

cheers again

barefoot
I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk