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: 915
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Reduction of slash commands in official plug-ins

Post by Zehra »

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
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.
Visit BZList.net for a modern HTML5 server stats site.

Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
Post Reply