I've made a tweak to your plugin for my own purposes, but I am sharing it here for others in case they find it useful.
In your version, it checks for any characters other than spaces, periods, and digits.
My version checks for anything that isn't a digit or period, and then if it's all numerical, it checks if the number is >= 30. A space in front of the cl_cmdrate (like cl_cmdrate " 30") will indeed affect ping-masking from my tests. The new regex also reflects that.
A very low cl_cmdrate will show an incorrect ping the same way other characters in the cl_cmdrate will. On a 100-tick server, with a cl_cmdrate of 10, my latency on the scoreboard goes to 5. 30 is the Valve default, so I figured it was a safe number to use, but even with a cl_cmdrate of 30, your ping shows somewhat lower than would be if you had a higher cl_cmdrate.
I changed your IsValidCmdRate function as follows:
Old:
Code:
bool:IsValidCmdRate( String:CmdRate[] )
{
/* Check command rate for invalid characters. */
new nMatches = SimpleRegexMatch( CmdRate, "[^\\d\\s\\.]+" );
if( nMatches >= 1 )
return false;
return true;
}
New:
Code:
bool:IsValidCmdRate( String:CmdRate[] ) {
/* Check command rate for invalid characters. */
new nMatches = SimpleRegexMatch( CmdRate, "[^0-9.]" );
if (nMatches == 0 && StringToInt(CmdRate) >= 30) {
return true;
}
else {
return false;
}
}
I also changed the English translation for "Kicked By Rate" to "cl_cmdrate must be numbers only and 30+". Your original didn't fit in the little box that users are shown when they are kicked (in CS:S anyway), and this explains concisely what they need to do to get back. Previously when I've told people they have an incorrect cl_cmdrate or that they're ping-masking, many of them don't even understand what I'm talking about.
UPDATE:
I fixed my version to allow periods and allow numbers above 100.