Raised This Month: $ Target: $400
 0% 

Modify command args


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Afronanny
Veteran Member
Join Date: Aug 2009
Old 05-24-2010 , 18:04   Modify command args
Reply With Quote #1

Is there any way to modify a command's arguments, then allow it to pass through as normal (Plugin_Continue)? What I'm trying to do is when people type messages in all caps, to make it lowercase then return Plugin_Continue so their message can be seen and handled as normal, but not in all caps.

Last edited by Afronanny; 05-24-2010 at 18:59.
Afronanny is offline
rcarm
Member
Join Date: Feb 2010
Old 05-24-2010 , 19:32   Re: Modify command args
Reply With Quote #2

Have you tried hooking onto player_say and change the text using SetEventString()?
rcarm is offline
atom0s
Senior Member
Join Date: Jul 2009
Old 05-24-2010 , 19:41   Re: Modify command args
Reply With Quote #3

Also look into the 3rd parameter of HookEvent/HookEventEx allowing you to hook events and handle them before the game does.

PHP Code:
HookEvent"player_say"PlayerSay_HandlerEventHookMode_Pre 
atom0s is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 05-24-2010 , 22:32   Re: Modify command args
Reply With Quote #4

I tried this a while ago. Changing text and using Plugin_Changed didn't work for the pre-hooked event or the CommandListener from what I remember. Ended up blocking and faking a new one .
PHP Code:
#define MAX_CAPS_PERCENTAGE 75.0
#define MESSAGE "\x04Please refrain from using CAPS."

public OnPluginStart() {
    
AddCommandListener(SayCallback"say");
    
AddCommandListener(SayCallback"say_team");
}

public 
Action:SayCallback(client, const String:command[], argc) {
    new 
Float:fTotalCharsFloat:fCapChars;
    static 
String:sText[192]; GetCmdArgString(sTextsizeof(sText));
    for (new 
1< (strlen(sText)-1); i++) {
        
fTotalChars++;
        if (
IsCharUpper(sText[i])) {
            
sText[i] = CharToLower(sText[i]);
            
fCapChars++;
        }
    }
    if ((
fCapChars/fTotalChars) > (MAX_CAPS_PERCENTAGE/100.0)) {
        
FakeClientCommandEx(client"%s %s"commandsText);
        
PrintToChat(clientMESSAGE);
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;

__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
Reply



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 06:25.


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