This topic was marked solved by its starter, on March 26th, 02:03 PM
Button not working.

Maximiliano

  • Newbie
  • Posts: 11
Button not working.
«  »
Hello, my problem is that when I want to press the buttons do not work, I need to press "Cerrar" (Close), so that it can work later.
The code had been running for months, but when I edited something it stopped working, and even if I upload the "backup" it does not work.


https://youtu.be/3JgshIA8A1U

Code:

(click to show/hide)
function GUI::ElementRelease(element, mouseX, mouseY)
{
    if (element == CloseMenu)
    {
      local Data = Stream();
       Data.WriteString("CloseMenu");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::Table <-null; ::CloseMenu <- null; ::Arena <- null; ::Arena2 <- null; ::Arena3 <- null; ::Arena4 <- null; ::Arena5 <- null;
      ::Fondoarma <- null; ::Chaleco <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
    }

   switch(element)
   {
   case Arena:
      local Data = Stream();
       Data.WriteString("Arena");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
      ::Table <-null; ::CloseMenu <- null; ::Arena <- null; ::Arena2 <- null; ::Arena3 <- null; ::Arena4 <- null; ::Arena5 <- null;
   break;
   case Arena2:
      local Data = Stream();
       Data.WriteString("Arena2");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::Table <-null; ::CloseMenu <- null; ::Arena <- null; ::Arena2 <- null; ::Arena3 <- null; ::Arena4 <- null; ::Arena5 <- null;
   break;
   case Arena3:
      local Data = Stream();
       Data.WriteString("Arena3");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::Table <- null; ::CloseMenu <- null; ::Arena <- null; ::Arena2 <- null; ::Arena3 <- null; ::Arena4 <- null; ::Arena5 <- null;
   break;
   case Arena4:
      local Data = Stream();
       Data.WriteString("Arena4");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::Table <- null; ::CloseMenu <- null; ::Arena <- null; ::Arena2 <- null; ::Arena3 <- null; ::Arena4 <- null; ::Arena5 <- null;
   break;
   case Arena5:
      local Data = Stream();
       Data.WriteString("Arena5");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::Table <-null; ::Closemenu <- null; ::Arena <- null; ::Arena2 <- null; ::Arena3 <- null; ::Arena4 <- null; ::Arena5 <- null;
   break;
   case Arma1:
      local Data = Stream();
       Data.WriteString("Arma1");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   case Arma2:
      local Data = Stream();
       Data.WriteString("Arma2");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   case Arma3:
      local Data = Stream();
       Data.WriteString("Arma3");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   case Arma4:
      local Data = Stream();
       Data.WriteString("Arma4");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   case Arma5:
      local Data = Stream();
       Data.WriteString("Arma5");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   case Arma6:
      local Data = Stream();
       Data.WriteString("Arma6");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   case Arma7:
      local Data = Stream();
       Data.WriteString("Arma7");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   case Arma8:
      local Data = Stream();
       Data.WriteString("Arma8");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   case Arma9:
      local Data = Stream();
       Data.WriteString("Arma9");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   case Chaleco:
      local Data = Stream();
       Data.WriteString("Chaleco");
       Server.SendData(Data);
      GUI.SetMouseEnabled(false);
      ::CloseMenu <- null;
       ::Fondoarma <- null; ::Chaleco <- null; ::Cerrarmenu <- null; ::Arma1 <- null; ::Arma2 <- null; ::Arma3 <- null; ::Arma4 <- null; ::Arma5 <- null; ::Arma6 <- null; ::Arma7 <- null; ::Arma8 <- null; ::Arma9 <- null;
   break;
   }



dracc

  • Jr. Member
  • Posts: 57
Re: Button not working.
« Reply #1,  »
Wow, that's some next level shitty code.
You assign "null" to the same full array of variables ten times but haven't moved it into its own function.
You have both an if-statement and a switch case for the same variable.
For all we can tell, none of the switch case variables are assigned - none of them should evaluate to "true".

Maximiliano

  • Newbie
  • Posts: 11
Re: Button not working.
« Reply #3,  »Last edited
Quote from dracc on March 25th, 03:20 PM
Wow, that's some next level shitty code.
Oh Thx ^-^ :P
Quote from dracc on March 25th, 03:20 PM
You have both an if-statement and a switch case for the same variable.
The code like this is the only way it works for me. The "CloseMenu" was on the switch, but it did not work.
Quote from dracc on March 25th, 03:20 PM
You assign "null" to the same full array of variables ten times but haven't moved it into its own function.

For all we can tell, none of the switch case variables are assigned - none
of them should evaluate to "true".
I'm an idiot, I forgot to add the array in the elements :/.
Thanks for your comment, otherwise I would not have noticed.