AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [SNIPPET] Is SteamID banned (https://forums.alliedmods.net/showthread.php?t=239081)

klausenbusk 04-21-2014 11:20

[SNIPPET] Is SteamID banned
 
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

Mitchell 04-21-2014 11:38

Re: [SNIPPET] Is SteamID banned
 
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.

klausenbusk 04-21-2014 12:03

Re: [SNIPPET] Is SteamID banned
 
Quote:

Originally Posted by Mitchell (Post 2127639)
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..


All times are GMT -4. The time now is 18:29.

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