Menu scripts

  • Forum Admin

    You can add custom buttons to menus by editing 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": []

    This will add a new button "Test Button" to the main menu. Currently only "main" can be used as menu, later "profilemore" and "adminactions" will be supported. The conditions parameter is currently ignored, but can later be used to show the buttons only to specific players, such as admins.

    In the Script clientclasses/menu_test.js you can define what happens when you click the menu button, react to the event onActivated:

    function onActivated() {
        let popup = GUI.showpopup({title: "Test Window"});
        popup.innerHTML = "This is a test window.< br>< center >< input type=\"submit\" value=\"Test Trigger\" id=\"testbutton\">< /center>";
        var self = this;
        GUI.onclick("testbutton", function(event) {
            self.triggerserver("test", "123");

    (had to add spaces in the html tags so it shows on the forums)

    This opens a popup with some interface elements. It's automatically adding a back button if you show a popup.

    Bildschirmfoto 2019-03-30 um 19.11.32.png

    This script is also sending data to the server once you click a button in the new popup, you can react to it by adding a class scriptclasses/menu_test.js:

    function onClientTest(pl, nr) {
        echo("triggered menu_test: " + nr);
        pl.showmessage("Received test trigger! " + nr);

Log in to reply