Auto disabling a module

Avatar

By Hotkeq 4 February 2019 17:08

Member · 2 comments

Is there a line i can put in the onEnable which will disable the module?

Avatar

By Senk Ju 4 February 2019 19:02

Administrator · 709 comments

You can do it in the onUpdate event:

var scriptName = "AutoDisable";
var scriptAuthor = "Senk Ju";
var scriptVersion = 1.0;

function AutoDisableModule() {

    this.getName = function() {
        return "AutoDisable";
    }

    this.getDescription = function() {
        return "A module which automatically disables itself.";
    }

    this.getCategory = function() {
        return "Misc";
    }

    this.onEnable = function() {
        chat.print("Enabled module.");
    }

    this.onUpdate = function() {
        var autoDisableModule = moduleManager.getModule("AutoDisable");
        autoDisableModule.setState(false);
    }

    this.onDisable = function() {
        chat.print("Disabled module.");
    }
}

var autoDisableModule = new AutoDisableModule();
var autoDisableModuleClient;

function onEnable() {
    autoDisableModuleClient = moduleManager.registerModule(autoDisableModule);
}

function onDisable() {
    moduleManager.unregisterModule(autoDisableModuleClient);
}

CCBlueX Co-Owner