[SNIP] Add a tag for your plugin.
Today I was looking through my server browser, and noticed the lack of tags for game mode indication. I would assume this primarily comes from the fact that sv_tags is a cvar, and I think people are scared of messing with it. With the code here, you will be able to ensure that a tag is always included for your game mode or plugin. Please note this isn't the only way to do this, and probably isn't the most efficient either, but it works.
I didn't code in support for multiple tags per plugin (or at least I didn't intend to)... this can be accomplished easily, but I didn't design this specific example with it in mind. To be honest, one tag is all a plugin should really allocate in order to show it's presence. Code:
#define CUSTOM_TAG "mycoolplugin" |
Re: [SNIP] Add a tag for your plugin.
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:
PHP Code:
PHP Code:
|
Re: [SNIP] Add a tag for your plugin.
Thanks for contributing. What exactly am I missing?
Quote:
|
Re: [SNIP] Add a tag for your plugin.
Quote:
|
Re: [SNIP] Add a tag for your plugin.
Oh gotcha. Yeah sorry that makes more sense now that I re-read your post.
On a side note, is there enough interest in this to make it an interface? Something as simple as: AddPluginTag("blah"); RemovePluginTag("blah"); You could handle all the logic is one plugin. Let me know. |
Re: [SNIP] Add a tag for your plugin.
Quote:
PHP Code:
|
Re: [SNIP] Add a tag for your plugin.
Yeah, however if sv_tags gets manually changed the hook isn't in place. The include would be perfect if we added one more stock: InitAndHookTags()
|
Re: [SNIP] Add a tag for your plugin.
Quote:
|
Re: [SNIP] Add a tag for your plugin.
Sorry didn't mean it like that, I just meant that with the current include people should be aware that they should probably re-add the tag any time sv_tags is changed. Your code is great as you already know.
|
Re: [SNIP] Add a tag for your plugin.
Quote:
|
Re: [SNIP] Add a tag for your plugin.
Quote:
|
Re: [SNIP] Add a tag for your plugin.
Absolutely, I'll take a look and update this post in a bit.
|
Re: [SNIP] Add a tag for your plugin.
Updated post one more time to fix an invalid handle error that could occur when trying to remove a custom tag before adding one (which shouldn't happen if used properly, but better safe than rte).
Also of note, it would be nice for plugins to remove any added custom tag in OnPluginEnd. Edit, rather than double post: I decided to remove my attachment after realizing that half of the games that support tags (l4d1/2, swarm) still have a limit of 63+/0 total characters (including tags the game itself puts on). If more than a few tags get added, they will start getting cut off. While this supposedly isn't an issue for matchmaking like it was in the past, it's still less than ideal to have to fight for very limited tag space. (the 127+\0 in ep2v was a bit more reasonable). TL;DR tag system sucks |
Re: [SNIP] Add a tag for your plugin.
Hmm, anyone that plans on using this, wait until I get a chance to test it with multiple plugins. See if I can provoke an infinite loop.
|
| All times are GMT -4. The time now is 18:43. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.