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

sv_tags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r5053
SourceMod Donor
Join Date: May 2007
Location: Germany
Old 08-22-2008 , 11:23   sv_tags
Reply With Quote #1

How can i use sv_tags for my plugins?
__________________
Visit HLPortal.de (this is not my Page)


r5053 is offline
Send a message via ICQ to r5053 Send a message via Skype™ to r5053
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-22-2008 , 13:52   Re: sv_tags
Reply With Quote #2

Grab the value of the convar, check for the string you want to be in it for your plugin. If you find it, do nothing. If you don't find it, use StrCat to put what you want at the end of the string.
bl4nk is offline
r5053
SourceMod Donor
Join Date: May 2007
Location: Germany
Old 08-22-2008 , 15:33   Re: sv_tags
Reply With Quote #3

i tryed this but it doesn't work well
__________________
Visit HLPortal.de (this is not my Page)


r5053 is offline
Send a message via ICQ to r5053 Send a message via Skype™ to r5053
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-22-2008 , 16:29   Re: sv_tags
Reply With Quote #4

PHP Code:
stock tagsCheck(const String:tag[])
{
    new 
Handle:hTags FindConVar("sv_tags");

    
decl String:tags[255];
    
GetConVarString(hTagstagssizeof(tags));

    if (!
StrContains(tagstagfalse))
    {
        
decl String:newTags[255];
        
Format(newTagssizeof(newTags), "%s, %s"tagstag);
        
SetConVarString(hTagsnewTags);
    }

    
CloseHandle(hTags);

Try that out. The only argument is the string you want to insert into sv_tags. It looks for it in the already existing string, and if it doesn't find it, it will add it on.
bl4nk is offline
r5053
SourceMod Donor
Join Date: May 2007
Location: Germany
Old 08-23-2008 , 09:23   Re: sv_tags
Reply With Quote #5

it doesn't work i execute this on plugin load and on mapload but it doesn't change anything
__________________
Visit HLPortal.de (this is not my Page)


r5053 is offline
Send a message via ICQ to r5053 Send a message via Skype™ to r5053
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 08-26-2008 , 12:04   Re: sv_tags
Reply With Quote #6

bl4nk's method doesn't work.

The sv_tags command takes care of all the stuff he did by itself, so you just need to put
Code:
ServerCommand("sv_tags MYTAG\n");
in OnMapStart.

EDIT: Actually, not sure how this will work with multiple plugins.
sv_tags hi will add hi to the end of the server's auto tags
sv_tags hi,tag2 will add both tags to the end
sv_tags tag3 will result in hi and tag2 being removed and tag3 being added
__________________
"Good grammar is essential, Robin."
- Batman

Last edited by L. Duke; 08-26-2008 at 12:06.
L. Duke is offline
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 08-26-2008 , 12:12   Re: sv_tags
Reply With Quote #7

Code:
new Handle:hTags = FindConVar("sv_tags");

    decl String:tags[512];
    GetConVarString(hTags, tags, sizeof(tags));
doesnt seem to return any values even when sv_tags has additional tags set by the user.

I'm not sure how to ADD tags, since the server command will replace them.
__________________
"Good grammar is essential, Robin."
- Batman
L. Duke is offline
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 08-26-2008 , 13:46   Re: sv_tags
Reply With Quote #8

Ok. I've got it working.

You need to call the check in OnConfigsExecuted rather than OnMapStart. Also, StrContains returns -1 if the string is not found so you need to check that rather then just if(StrContains(...

Code:
public OnConfigsExecuted()
{
    TagsCheck("MYTAG");
}
Code:
TagsCheck(const String:tag[])
{
    new Handle:hTags = FindConVar("sv_tags");
    
    decl String:tags[255];
    GetConVarString(hTags, tags, sizeof(tags));

    if (!(StrContains(tags, tag, false)>-1))
    {
        decl String:newTags[255];
        Format(newTags, sizeof(newTags), "%s,%s", tags, tag);
        SetConVarString(hTags, newTags);
        GetConVarString(hTags, tags, sizeof(tags));
    }

    CloseHandle(hTags);
}
__________________
"Good grammar is essential, Robin."
- Batman
L. Duke 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:13.


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