Raised This Month: $ Target: $400
 0% 

[SNIP] Add a tag for your plugin.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
psychonic

BAFFLED
Join Date: May 2008
Old 09-07-2010 , 15:48   Re: [SNIP] Add a tag for your plugin.
Reply With Quote #1

This is what I use.

You still have to add logic to the below if you are concerned with something else clobbering your tag. This shouldn't be necessary as just manually changing cvars that add/remove tags should still leave it in tact.

By the way, if I'm not mistaken, I'm pretty sure sv_tags has a limit of 128 characters (inc. null).

Global
PHP Code:
new Handle:sv_tags
in OnPluginStart
PHP Code:
sv_tags FindConVar("sv_tags"); 
PHP Code:
stock MyAddServerTag(const String:tag[])
{
    
decl String:currtags[128];
    if (
sv_tags == INVALID_HANDLE)
    {
        return;
    }
    
    
GetConVarString(sv_tagscurrtagssizeof(currtags));
    if (
StrContains(currtagstag) > -1)
    {
        
// already have tag
        
return;
    }
    
    
decl String:newtags[128];
    
Format(newtagssizeof(newtags), "%s%s%s"currtags, (currtags[0]!=0)?",":""tag);
    new 
flags GetConVarFlags(sv_tags);
    
SetConVarFlags(sv_tagsflags & ~FCVAR_NOTIFY);
    
SetConVarString(sv_tagsnewtags);
    
SetConVarFlags(sv_tagsflags);
}

stock MyRemoveServerTag(const String:tag[])
{
    
decl String:newtags[128];
    if (
sv_tags == INVALID_HANDLE)
    {
        return;
    }
    
    
GetConVarString(sv_tagsnewtagssizeof(newtags));
    if (
StrContains(newtagstag) == -1)
    {
        
// tag isn't on here, just bug out
        
return;
    }
    
    
ReplaceString(newtagssizeof(newtags), tag"");
    
ReplaceString(newtagssizeof(newtags), ",,""");
    new 
flags GetConVarFlags(sv_tags);
    
SetConVarFlags(sv_tagsflags & ~FCVAR_NOTIFY);
    
SetConVarString(sv_tagsnewtags);
    
SetConVarFlags(sv_tagsflags);


Last edited by psychonic; 09-07-2010 at 15:53.
psychonic 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 18:43.


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