AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   TOG Case Commands (https://forums.alliedmods.net/showthread.php?t=241693)

ThatOneGuy 06-07-2014 19:23

TOG Case Commands
 
1 Attachment(s)
Description
This plugin converts chat trigger to all lowercase. This is useful if someone commonly toggles caps lock for whatever reason. Specifically, it checks to see if the chat text starts with ! or /, and if it does, it checks whether the next character is capitolized. If it is, then it blocks the command and resends it as all lowercase.

I only check the first letter for caps because someone might troll with a command like !kick @All (wouldnt do anything because of the capitol 'A' in @All). As such, I check the first letter, and if it is capitolized, the plugin assumes caps lock and converts it.

I originally made this as part of my Chat Tags plugin, but made it into it's own plugin in case someone wants just that feature.

Installation
Place the .smx file in your cstrike/addons/sourcemod/plugins folder.

Servers using this plugin
>>> Click here to check out my other plugins <<<

`666 07-07-2020 12:26

Re: TOG Case Commands
 
Thanks.
Update to new syntax:
Code:

#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1.0"

#include <sourcemod>

public Plugin myinfo =
{
        name = "TOG Case Commands",
        author = "That One Guy",
        description = "Converts chat triggers to lowercase so that they work",
        version = PLUGIN_VERSION,
        url = "https://forums.alliedmods.net"
}

public void OnPluginStart()
{
        CreateConVar("togcasecommands_version", PLUGIN_VERSION, "TOG Case Commands: Version", FCVAR_NOTIFY|FCVAR_DONTRECORD);
       
        AddCommandListener(Command_Say, "say");
        AddCommandListener(Command_Say, "say2");
        AddCommandListener(Command_Say, "say_team");
}

public Action Command_Say(int client, const char[] command, int argc)
{
        if(!IsValidClient(client))
        {
                return Plugin_Continue;
        }
       
        char sText[300];
        GetCmdArgString(sText, sizeof(sText));
        StripQuotes(sText);

        if((sText[0] == '!') || (sText[0] == '/'))
        {
                if(IsCharUpper(sText[1]))
                {
                        for(int i = 0; i <= strlen(sText); ++i)
                        {
                                sText[i] = CharToLower(sText[i]);
                        }

                        FakeClientCommand(client, "say %s", sText);
                        return Plugin_Handled;
                }
        }
               
        return Plugin_Continue;
}

public bool IsValidClient(int client)
{
        if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || IsFakeClient(client))
        {
                return false;
        }
        return true;
}



All times are GMT -4. The time now is 18:49.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.