Raised This Month: $12 Target: $400
 3% 

Triggering chat command regardless of case


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 12-09-2016 , 11:43   Triggering chat command regardless of case
Reply With Quote #1

Hey guys, would it be possible to trigger chat commands regardless of case? For example, currently, if a user accidentally types !HELP instead of !help, or !B 2 instead of !b 2, nothing will pop up unless they type it in lowercase. I did quite a bit of searching but couldn't find anything useful. I'd like something that could work for all plugins, not just hardcoded for a particular set of commands.
__________________

Last edited by sneaK; 12-09-2016 at 11:44.
sneaK is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-09-2016 , 12:27   Re: Triggering chat command regardless of case
Reply With Quote #2

Absoluty no idea if this will work...
PHP Code:
#include <sourcemod>
#include <smlib>
#include <scp>

#define PLUGIN_AUTHOR "Arkarr"
#define PLUGIN_VERSION "1.00"

public Plugin myinfo 
{
    
name "[ANY] Command Case Sensitive Eraser",
    
author PLUGIN_AUTHOR,
    
description "Ignore the case sensitive of a command.",
    
version PLUGIN_VERSION,
    
url "http://www.sourcemod.net"
};

public 
void OnChatMessagePost(int authorArrayList recipients, const char[] flagstring, const char[] formatstring, const char[] name, const char[] messagebool processcolorsbool removecolors)
{
    
char cmdargs[10][20];
    
char cmd[200];
    
char final[200];
    
int nbrArgs ExplodeString(message" "cmdargssizeof cmdargssizeof cmdargs[]);
    
    
Format(cmdsizeof(cmd), cmdargs[0]);
    
ReplaceString(cmdsizeof(cmd), "!""sm_");
    
ReplaceString(cmdsizeof(cmd), "/""sm_");

    
String_ToLower(cmdcmdsizeof(cmd));
    
    if(
CheckCommandAccess(authorcmdADMFLAG_ROOT))
    {        
        for (
int i 1nbrArgsi++)
            
Format(final, sizeof(final), "%s"cmdargs[i]);
            
        
Format(final, sizeof(final), "%s %s"cmd, final);
    
        
FakeClientCommand(author, final);
    }

Require https://forums.alliedmods.net/showthread.php?t=286913
__________________

Last edited by Arkarr; 12-09-2016 at 13:02.
Arkarr is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 12-09-2016 , 12:57   Re: Triggering chat command regardless of case
Reply With Quote #3

This is in ZipCore's timer, however I don't really agree with hooking the say command: https://github.com/Zipcore/Timer/blo...er_case_cmd.sp
Mitchell is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 12-09-2016 , 12:58   Re: Triggering chat command regardless of case
Reply With Quote #4

Nice, I'll be sure to test, however is there a chance this could be made to utilize SCP instead of chat-processor? I use SCP across all of my servers and many plugins would need to be changed to accommodate red's new chat processor.
__________________
sneaK is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 12-09-2016 , 13:02   Re: Triggering chat command regardless of case
Reply With Quote #5

Quote:
Originally Posted by blackhawk74 View Post
Nice, I'll be sure to test, however is there a chance this could be made to utilize SCP instead of chat-processor? I use SCP across all of my servers and many plugins would need to be changed to accommodate red's new chat processor.
Done.. but you should use the Zipcore one I guess. I think I did sh*t.
__________________
Arkarr is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 12-09-2016 , 13:03   Re: Triggering chat command regardless of case
Reply With Quote #6

Quote:
Originally Posted by Mitchell View Post
This is in ZipCore's timer, however I don't really agree with hooking the say command: https://github.com/Zipcore/Timer/blo...er_case_cmd.sp
Quote:
Originally Posted by Arkarr View Post
Done.. but you should use the Zipcore one I guess. I think I did sh*t.
Oop, just realized Mitchell posted that a few seconds before my post! I'll try both, thanks to both of you
__________________
sneaK is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 12-09-2016 , 20:12   Re: Triggering chat command regardless of case
Reply With Quote #7

PHP Code:
if (StrEqual(text"!help"true) || StrEqual(text"/help"true)) 
I don't like the idea of making workarounds, why not just do the above on the required commands?
__________________
xines is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 12-09-2016 , 22:36   Re: Triggering chat command regardless of case
Reply With Quote #8

Quote:
Originally Posted by xines View Post
PHP Code:
if (StrEqual(text"!help"true) || StrEqual(text"/help"true)) 
I don't like the idea of making workarounds, why not just do the above on the required commands?
Quote:
Originally Posted by blackhawk74 View Post
I'd like something that could work for all plugins, not just hardcoded for a particular set of commands.
Mainly because I have a lot of available commands, and don't wish to hardcode every single possibility.
__________________
sneaK is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 12-09-2016 , 22:57   Re: Triggering chat command regardless of case
Reply With Quote #9

Please be aware that / and ! are not hardcoded as chat triggers. Server owners can set whatever triggers they want.
__________________
ddhoward 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 02:08.


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