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

[SNIPPET] Is SteamID banned


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
klausenbusk
AlliedModders Donor
Join Date: Jan 2011
Old 04-21-2014 , 11:20   [SNIPPET] Is SteamID banned
Reply With Quote #1

PHP Code:
new Handle:g_hRegex;

public 
OnPluginStart() 
{
    
g_hRegex CompileRegex("STEAM_[0-9]:[0-9]:[0-9]+");
}

new 
bool:IsSteamIDBanned(const String:SteamID[])
{
    
decl String:buffer[16384]; // Should be enough for like 450 bans
    
ServerCommandEx(buffersizeof(buffer), "listid");
    new 
String:BSteamID[32], skip_text;

    while(
MatchRegex(g_hRegexbuffer[skip_text]))
    {
        
GetRegexSubString(g_hRegex0BSteamIDsizeof(BSteamID));
        if (
StrEqual(SteamIDBSteamID))
        {
            return 
true;
        }

        
skip_text += StrContains(buffer[skip_text], BSteamID) + strlen(BSteamID);
    }
    return 
false;

Could be useful, I think it could be more optimized..

Thanks to:
https://forums.alliedmods.net/showthread.php?t=198804
https://forums.alliedmods.net/showthread.php?t=177900
https://forums.alliedmods.net/showthread.php?p=2127550

Last edited by klausenbusk; 04-21-2014 at 11:22.
klausenbusk is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-21-2014 , 11:38   Re: [SNIPPET] Is SteamID banned
Reply With Quote #2

Lets just hope people wont use this on their 5000+ bans server.
Never really got the regex part, why not just use StrContains on the huge buffer?
plus, you should do listid on mapstart or plugin start, and store the ban ids in a ADT array, or something like that, then hook:
├OnBanClient
├OnBanIdentity
├OnRemoveBan
to add/remove from that array.

Last edited by Mitchell; 04-21-2014 at 11:39.
Mitchell is offline
klausenbusk
AlliedModders Donor
Join Date: Jan 2011
Old 04-21-2014 , 12:03   Re: [SNIPPET] Is SteamID banned
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
Lets just hope people wont use this on their 5000+ bans server.
Never really got the regex part, why not just use StrContains on the huge buffer?
plus, you should do listid on mapstart or plugin start, and store the ban ids in a ADT array, or something like that, then hook:
├OnBanClient
├OnBanIdentity
├OnRemoveBan
to add/remove from that array.
I kind of know that, when I coded this.
Think it will be better just hook server_addban and server_removeban, that should do the job. Was also thinking about ADT array.
Maybe I get confused by what asherkin said..
About why not StrContains, think it could be useful is people want to print out banned ids.. Think I should just have published the parser.. Hmm..

Will rewrite it later today, I hope..

Last edited by klausenbusk; 04-21-2014 at 12:04.
klausenbusk is offline
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 04:42.


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