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

Regex to check players names


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ecca
Sexy Santa
Join Date: Jan 2011
Old 03-11-2014 , 11:37   Regex to check players names
Reply With Quote #1

Good evening.

So basically i'm trying todo a simple check if a players name contains other chars then what i want to , i tried doing as i'm doing in PHP but it seems like it doesnt work.

PHP Code:
new Handle:regeex INVALID_HANDLE;

public 
OnPluginStart()
{
    
RegConsoleCmd("say"Command_SayChat);
    
RegConsoleCmd("say_team"Command_SayChat);
    
    
regeex CompileRegex("/^[a-zA-Z0-9]+$/");
}

public 
Action:Command_SayChat(clientargs)
{    
        
decl String:text[192];
        
GetCmdArgString(textsizeof(text));
        if (
MatchRegex(regeextext) > 0) {                        
            
LogAction(client, -1"char was blocked");
            return 
Plugin_Handled;                
        }            
    return 
Plugin_Continue;    

Edit: The matching text is just for testing purposes to easier try it out , the function will be against names later!
__________________

Last edited by ecca; 03-11-2014 at 12:08.
ecca is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-14-2014 , 10:29   Re: Regex to check players names
Reply With Quote #2

Ok, if you are using chat messages to compare with regex, remember you get "quotes" when type message in game chat panel.

some bad tutorial
Try Regex

anyway... try this and don't include slashes
PHP Code:
// Same as = /[^\w -.]/
// Matching any character, expect [A-Za-z0-9_], space, dot, stroce

"[^\\w -.]" 
some test, don't rely 100%
Bacardi 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 16:23.


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