script for chat help (simple?)

Avatar

By soulplexis 9 February 2019 02:12

Donator · 144 comments

I have made a module which debugs some things aka speed of timer speed, but the colors of each message are the same so it's hard to see if it's actually updating or if it's just still.
How do i make so where it will print like this so its a bit easier to read?:
chat.print("§4Timer speed:" + mc.timer.timerSpeed)
§5Timer speed 1.1 etc.
§4Timer speed 1.2 etc.

Last edited by soulplexis (9 February 2019 05:29)


->Best cheats<-

Avatar

By icewormy3 9 February 2019 03:01

Member · 207 comments

i think its chat.print

Avatar

By soulplexis 9 February 2019 05:28

Donator · 144 comments
icewormy3 wrote

i think its chat.print

I know,  i meant how do you alternate between two colors? it's really hard to read


->Best cheats<-

Avatar

By Shiv3R 9 February 2019 06:27

Member · 75 comments

if (mc.timer.timerSpeed > 1.1 && mc.timertimerSpeed < 1.2)
{
chat.print("§5Timer speed" + mc.timer.timerSpeed);
}
if (mc.timer.timerSpeed > 1.2 && mc.timertimerSpeed < 1.3)
{
chat.print("§4Timer speed" + mc.timer.timerSpeed);
}
etc

Avatar

By Senk Ju 9 February 2019 14:28

Administrator · 536 comments

If you just wanted to make it easier to distinguish between multiple messages, you can use the code below. Otherwise you would have to do it like Shiv3R suggested.

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

var colorIndex = 0;

function printMessage(message) {
    var availableColors = ["§4", "§c", "§6", "§e", "§2", "§a", "§b", "§3", "§1", "§9", "§d", "§5"];

    var color = availableColors[colorIndex];
    
    colorIndex += 1;
    if (colorIndex >= availableColors.length) {
        colorIndex = 0;
    }

    chat.print(color + message + "§r");

}

function ColorChatModule() {

    var ticks = 0;

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

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

    this.getDescription = function() {
        return "Chooses a random color for every chat message.";
    }

    this.onUpdate = function() {
        ticks++;

        if (ticks >= 20) {
            ticks = 0;

            printMessage("Axolotls are cool!");
        }
    }
}

var colorChatModule = new ColorChatModule();
var colorChatModuleClient;

function onEnable() {
    colorChatModuleClient = moduleManager.registerModule(colorChatModule);
}

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

CCBlueX Co-Owner