Raised This Month: $32 Target: $400
 8% 

TOG Case Commands


Post New Thread Reply   
 
Thread Tools Display Modes
Author
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Plugin ID:
4239
Plugin Version:
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Old 06-07-2014 , 19:23   TOG Case Commands
    Reply With Quote #1

    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 <<<
    Attached Files
    File Type: sp Get Plugin or Get Source (togcasecommands.sp - 923 views - 1.3 KB)
    __________________

    Last edited by ThatOneGuy; 07-21-2017 at 16:43.
    ThatOneGuy is offline
    `666
    AlliedModders Donor
    Join Date: Jan 2006
    Old 07-07-2020 , 12:26   Re: TOG Case Commands
    Reply With Quote #2

    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;
    }
    `666 is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 20:34.


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