Skip to content

Menu Buttons

You can add additional menu buttons using the configuration file menubuttons.json :

{
    "menubuttons": [
        {
          "menu": "main",
          "buttonid": "testbutton",
          "image": "bbuilder_newbutton_items.png",
          "text": "Test Button",
          "help": "This is a test button!",
          "scriptclasses": ["menu_test"],
          "conditions": []
        }
    ]
}

Currently supported are following menu types: main, admin, profilemore, adminactions, clans, manageclan, claninfo

The scriptclasses property defines which script is run when you click the button, here the client-side class clientclasses/menu_test.js:

function onActivated(player, data, newmenu, oldmenu) {
    echo(`Menu button activated for ${this.buttonid}/${this.menu}:`, data);

    const popup = GUI.showpopup({ title: 'Test Window' });
    popup.innerHTML = `This is a test window.<br><center><input type='submit' value='Test Trigger' id='testbutton'></center>`;
    GUI.onclick('testbutton', (event) => {
        this.triggerserver('test', '123');
        GUI.hidepopup();
    });
}

This script is opening a new window with a button which is triggering an action on the server, add following server-side class scriptclasses/menu_test.js:

function onClientTest(player, nr) {
    echo(`triggered menu_test: ${nr}`);
    player.showmessage(`Received test trigger! ${nr}`);
}

PS: When you show a new popup window, it will automatically add a back button so that the user can return to the previous menu.