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:fTotalChars, Float:fCapChars;
static String:sText[192]; GetCmdArgString(sText, sizeof(sText));
for (new i = 1; i < (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", command, sText);
PrintToChat(client, MESSAGE);
return Plugin_Handled;
}
return Plugin_Continue;
}
__________________