Reduction of slash commands in official plug-ins

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
User avatar
Zehra
Private First Class
Private First Class
Posts: 567
Joined: Sun Oct 18, 2015 3:36 pm
Location: Arctic

Reduction of slash commands in official plug-ins

Post by Zehra » Wed Jan 09, 2019 5:39 pm

One thing, I have noticed which could perhaps be improved on a few plug-ins is the reduction of slash commands.

For example, the following code within the KoTH plug-in:

Code: Select all

    if ( command == "kothautotimeon")
    {
        koth.autoTimeOn = true;
        autoTime();
        bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment on.");
        return true;
    }

    if ( command == "kothautotimeoff")
    {
        koth.autoTimeOn = false;
        koth.adjustedTime = koth.TTH;
        autoTime();
        bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment off.");
        return true;
    }
Could be rewritten as this:

Code: Select all

    if ( command == "kothautotime")
    {
        if (_param->get(0) == "on" || _param->get(0) == "1")
        {
            koth.autoTimeOn = true;
            autoTime();
            bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment on.");
        }
        else if (_param->get(0) == "off" || _param->get(0) == "0")
        {
            koth.autoTimeOn = false;
            koth.adjustedTime = koth.TTH;
            autoTime();
            bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment off.");
        }
        else
        {
            bz_sendTextMessage(BZ_SERVER, playerID, "Usage: /kothautotime on|off");
        }
        return true;
    }
Instead of two slash commands, a single one is used.
This could be done with a few plug-ins, and most likely make them easier to use as well.

-Zehra
Those who are critical of me, I'll likely be the same of them. ~Zehra
There's always something to remember and it's been a game I love. ~Zehra
The time spent is a time which can never be regained, so it's a time to enjoy. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra

See where I've last been active at Strayers.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest