bo2 need help with menu script getting bad syntax any help will be appreciate

rui vieira

Veteran
Messages
23
Reaction score
5
Points
783
menuinit()
{
self endon( "disconnect" );
self endon( "destroyMenu" );
level endon( "game_ended" );
self welcomemessage();
self iprintln( "^2W^7elcome ^1" + ( self.name + "^2Z^7ombies ^2M^7enu" ) );
self iprintln( "Press [{+actionslot 1}] To Open The Menu" );
self freezecontrols( 0 );
self.menu = spawnstruct();
self.menu.open = 0;
self storeshaders();
self createmenu();
if( !(self.menu.open)self.menu.open )
{
openmenu();
wait 0.2;
}
if( self.menu.open && self meleebuttonpressed() )
{
closemenuanywhere();
}
if( self.menu.open )
{
if( self stancebuttonpressed() )
{
if( IsDefined( self.menu.previousmenu[ self.menu.currentmenu] ) )
{
self submenu( self.menu.previousmenu[ self.menu.currentmenu], self.menu.subtitle[ self.menu.previousmenu[ self.menu.currentmenu]] );
self playsoundtoplayer( "cac_grid_equip_item", self );
}
else
{
closemenu();
}
wait 0.2;
}
if( self actionslottwobuttonpressed() || self actionslotonebuttonpressed() )
{
self.menu.curs[self.menu.currentmenu] += iif( self actionslottwobuttonpressed(), 1, -1 );
self.menu.curs[self.menu.currentmenu] = iif( self.menu.curs[ self.menu.currentmenu] < 0, self.menu.menuopt[ self.menu.currentmenu].size - 1, iif( self.menu.curs[ self.menu.currentmenu] > self.menu.menuopt[ self.menu.currentmenu].size - 1, 0, self.menu.curs[ self.menu.currentmenu] ) );
self updatescrollbar();
wait 0.124;
}
if( self usebuttonpressed() )
{
self thread [[ ]]( self.menu.menuinput[ self.menu.currentmenu][ self.menu.curs[ self.menu.currentmenu]], self.menu.menuinput1[ self.menu.currentmenu][ self.menu.curs[ self.menu.currentmenu]] );
self playsoundtoplayer( "wpn_semtex_pin_pull", self );
wait 0.2;
}
}
wait 0.05;


}
 

CF4_99

Veteran
Messages
145
Reaction score
56
Points
888
This should fix the syntax, other than one part. Check the comments I added under self usebuttonpressed().
After you fix that, you shouldn't have a problem.
Also, I made it into a loop. Without looping the binds, you won't be able to use the menu.

C++:
menuinit()
{
    self endon( "disconnect" );
    self endon( "destroyMenu" );
    level endon( "game_ended" );

    self welcomemessage();
    self iprintln( "^2W^7elcome ^1"+self.name+" ^2T^7o ^2Z^7ombies ^2M^7enu");
    self iprintln( "Press [{+actionslot 1}] To Open The Menu" );
    self freezecontrols( 0 );
    self.menu = spawnstruct();
    self.menu.open = 0;
    self storeshaders();
    self createmenu();

    while(1)
    {
        if(!self.menu.open)
        {
            self openmenu();
            wait 0.2;
        }
        else
        {
            if(self meleebuttonpressed())
                self closemenuanywhere();
            if(self stancebuttonpressed())
            {
                if(IsDefined(self.menu.previousmenu[self.menu.currentmenu]))
                {
                    self submenu(self.menu.previousmenu[self.menu.currentmenu], self.menu.subtitle[self.menu.previousmenu[self.menu.currentmenu]]);
                    self playsoundtoplayer("cac_grid_equip_item", self);
                }
                else
                    self closemenu();
            }
            wait 0.2;
            if(self actionslottwobuttonpressed() || self actionslotonebuttonpressed())
            {
                self.menu.curs[self.menu.currentmenu] += iif(self actionslottwobuttonpressed(), 1, -1);
                self.menu.curs[self.menu.currentmenu] = iif(self.menu.curs[self.menu.currentmenu] < 0, self.menu.menuopt[self.menu.currentmenu].size - 1, iif(self.menu.curs[self.menu.currentmenu] > self.menu.menuopt[self.menu.currentmenu].size - 1, 0, self.menu.curs[self.menu.currentmenu]));
                self updatescrollbar();
                wait 0.124;
            }
            if(self usebuttonpressed())
            {
                //You need to add the variable for the function of the selected option
                //for example, self thread [[ self.menu.curs[self.menu.currentmenu].function ]]
                //You Will Continue To Get Bad Syntax Until You Add That
                self thread [[  ]](self.menu.menuinput[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]], self.menu.menuinput1[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]);
                self playsoundtoplayer("wpn_semtex_pin_pull", self);
                wait 0.2;
            }
        }
        wait 0.05;
    }
}
 
Last edited:
Top