Wins Command With Kill Counter


#1

PhantomBot Version: 2.4.2 (Revision: 5c75a7b2)
OS Version: Windows Server 2016 10.0 (x86)
Java Version: 1.8.0_181-b13
Panel Version: 1.1
Stock PhantomBot: Yes

I want to create a !wins command with a kill counter. It would look something like this:

 !addwin 10 –> (channelname) has won a game with 10 kills!
 !wins –> (channelname) has won 1 game(s) today (10K)
 !addwin 8 –> (channelname) has won a game with 8 kills!
 !wins –> (channelname) has won 2 game(s) today (10K, 8K)
 !resetwins –> Wins have been reset
 !wins –> (channelname) has won 0 game(s) today

Is this possible? Please let me know. Thanks :slight_smile:


#2

first off this should be under feature request not support as its noting todo with something thats wrong with the bot that you need help with and

secondly yes this is potable with a custom script almost everything except pink flying unicorns can be done with this bot :slight_smile:


#3

Moved to Feature Requests. My apologies.


#4

I have already asked the developers about it, but was refused. I myself use a modified deathctrCommand.js with deaths and wins. However, if your request will get something like 10+ votes, devs may accept the request for consideration. They’re interested in votes, it’s a good incentive.


#5

Could always make the script below and try this out scripts/custom/systems/winSystem.js

/**
 * winSystem.js
 *
 * Command handler for a wins system!
 */
(function() {
    var userStore = [];

    /**
     * @event command
     */
    $.bind('command', function(event) {
        var sender = event.getSender().toLowerCase(),
            channel = $.username.resolve($.botName),
            command = event.getCommand(),
            args = event.getArgs(),
            action = args[0];

        if (command.equalsIgnoreCase('wins')) {
            if (userStore.length > 0) {
                $.say($.username.resolve($.channelName) + ' has won ' + userStore.length + ' game(s) today (' + userStore.join(', ') + ')');
            }  else {
                $.say($.username.resolve($.channelName) + ' has not got any kills yet!');
            }
        }

        if (command.equalsIgnoreCase('addwin')) {
            if (action != undefined) {
                userStore.push(action + 'K');
                $.say($.username.resolve($.channelName) + ' has won a game with ' + action + ' kills!')
            }
        }

        if (command.equalsIgnoreCase('resetwin')) {
            userStore = [];
            $.say('Wins have been reset')
        }
    });

    /**
     * @event initReady
     */
    $.bind('initReady', function() {
        if ($.bot.isModuleEnabled('./custom/systems/winSystem.js')) {
            $.registerChatCommand('./custom/systems/winSystem.js', 'wins', 7);
            $.registerChatCommand('./custom/systems/winSystem.js', 'addwin', 1);
            $.registerChatCommand('./custom/systems/winSystem.js', 'resetwin', 1);
        }
    });
})();

#6
[ERROR] [loadScript()@ScriptManager.java:46] Failed to load module: .\scripts\.\custom\systems\winSystem.js: JavaScript Error: missing ) after argument list (winSystem.js#20)
[ERROR] [loadScript()@ScriptManager.java:49] Terminating PhantomBot due to Bad JavaScript File

#7

Fixed the post above i forgot a dam ; LUL


#8

One more thing:
.\scripts\.\custom\systems\winSystem.js
--------- ^ ----------


#9

i think thats just in the error cus of this but i could be wrong

if ($.bot.isModuleEnabled('./custom/systems/winSystem.js')) {

see even i get that same error location


#10

It’s probably famous Scania’s typos :grimacing: :smile:


#11


#12

I made this months ago:

It probably doesn’t work on the panel anymore.


#13

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.