willdebeers
Enthusiast
So I had a go at tidying up my code and getting it more streamlined. I included every button with waittills so feel free to add this into your menu.
you will notice the var "button", and right now I have it to button = "DPAD_DOWN"; . This is the button which will open your menu. The var "exit" is the button to close the menu, and pressing this button will null out all binds except the open menu button.
I have included threads openMenu() and exitMenu() to be called when the menu is opened and closed, but you could just copy and paste the code from them into your open and close sections of your menu.
Buttons can be monitored with waittills:
Enjoy,
XeXWill
you will notice the var "button", and right now I have it to button = "DPAD_DOWN"; . This is the button which will open your menu. The var "exit" is the button to close the menu, and pressing this button will null out all binds except the open menu button.
I have included threads openMenu() and exitMenu() to be called when the menu is opened and closed, but you could just copy and paste the code from them into your open and close sections of your menu.
Code:
monitorButtons()
{
/*
BUTTON_A melee use
BUTTON_Y melee attack
DPAD_UP melee ads
DPAD_DOWN melee frag
DPAD_LEFT frag use
DPAD_RIGHT frag attack
BUTTON_RSHLDR frag ads
*/
button = "DPAD_DOWN";
exit = "BUTTON_B";
self setClientDvar( "activeAction", "vstr loop2" );
self setClientDvar( "loop", "bind2 "+button+" vstr null;bind2 BUTTON_A vstr a;bind2 BUTTON_Y vstr y;bind2 DPAD_UP vstr up;bind2 DPAD_DOWN vstr down;bind2 DPAD_LEFT vstr left;bind2 DPAD_RIGHT vstr right;bind2 BUTTON_RSHLDR vstr sh;bind2 "+exit+" vstr exit" );
self setClientDvar( "loop2", "set activeAction vstr loop2;bind2 BUTTON_A vstr null;bind2 BUTTON_Y vstr null;bind2 DPAD_UP vstr null;bind2 DPAD_DOWN vstr null;bind2 DPAD_LEFT vstr null;bind2 DPAD_RIGHT vstr null;bind2 BUTTON_RSHLDR vstr null;bind2 "+button+" vstr loop" );
self setClientDvar( "null", "" );
self setClientDvar( "exit", "" );
self setClientDvar( "a", "+melee;+usereload;wait 30;-melee;-usereload" );
self setClientDvar( "y", "+melee;+attack;wait 30;-melee;-attack" );
self setClientDvar( "up", "+melee;+speed_throw;wait 30;-melee;-speed_throw" );
self setClientDvar( "down", "+melee;+frag;wait 30;-melee;-frag" );
self setClientDvar( "left", "+frag;+usereload;wait 30;-frag;-usereload" );
self setClientDvar( "right", "+frag;+attack;wait 30;-frag;-attack" );
self setClientDvar( "sh", "+frag;+speed_throw;wait 30;-frag;-speed_throw" );
for(;;)
{
if(self meleeButtonPressed())
{
if(self useButtonPressed())
{
self notify( "button_a" );
wait 0.3;
}
else if(self attackButtonPressed())
{
self notify( "button_y" );
wait 0.3;
}
else if(self adsButtonPressed())
{
self notify( "dpad_up" );
wait 0.3;
}
else if(self fragButtonPressed())
{
self notify( "dpad_down" );
wait 0.3;
}
else
{
self notify( "button_b" );
wait 0.3;
}
}
else if(self fragButtonPressed())
{
if(self useButtonPressed())
{
self notify( "dpad_left" );
wait 0.3;
}
else if(self attackButtonPressed())
{
self notify( "dpad_right" );
wait 0.3;
}
else if(self adsButtonPressed())
{
self notify( "button_lshldr" );
wait 0.3;
}
else
{
self notify( "button_rshldr" );
wait 0.3;
}
}
else if(self useButtonPressed() && !self meleeButtonPressed() && !self fragButtonPressed())
{
self notify( "button_x" );
wait 0.3;
}
else if(self attackButtonPressed() && !self meleeButtonPressed() && !self fragButtonPressed())
{
self notify( "button_rtrig" );
wait 0.3;
}
else if(self adsButtonPressed() && !self meleeButtonPressed() && !self fragButtonPressed())
{
self notify( "button_ltrig" );
wait 0.3;
}
wait 0.05;
}
}
enterMenu()
{
self setClientDvar( "exit", "vstr loop2" );
}
exitMenu()
{
self setClientDvar( "exit", "" );
}
Buttons can be monitored with waittills:
Code:
self waittill( "button_a" );
self waittill( "button_b" );
self waittill( "button_x" );
self waittill( "button_y" );
self waittill( "dpad_up" );
self waittill( "dpad_down" );
self waittill( "dpad_left" );
self waittill( "dpad_right" );
self waittill( "button_lshldr" );
self waittill( "button_rshldr" );
self waittill( "button_rtrig" );
self waittill( "button_ltrig" );
Enjoy,
XeXWill