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

CreateConVar exits, what about DeleteConVar ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-09-2018 , 07:07   CreateConVar exits, what about DeleteConVar ?
Reply With Quote #1

Like the topic says. When I unload a certain plugin, I would like all of its created convars to be removed from the server memory. Is that possible, without restarting the server?
Visual77 is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 04-09-2018 , 10:41   Re: CreateConVar exits, what about DeleteConVar ?
Reply With Quote #2

This is actually a great question. I imagined closing the ConVar handles would automatically delete the ConVars themselves, however, it doesn't.
ThatKidWhoGames is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-09-2018 , 13:13   Re: CreateConVar exits, what about DeleteConVar ?
Reply With Quote #3

Someone asked the same question in 2007 and Bailopan said no. If nothing has changed, this probably still stands true to this day. What would it take for the sm-devs to include such a feature in the developer versions of SM?

Another thing I'm trying to figure out. Plugin A creates cvar1 with the FCVAR_NOTIFY flag. Plugin B removes the FCVAR_NOTIFY flag from cvar1. But in HLSW, gametracker, gamemonitor, cvar1 remains with the NOTIFY flag. Why is that? The flag is gone but the FCVAR_NOTIFY is somehow still in server memory. (clearing provider cache in HLSW doesn't work here).

Last edited by Visual77; 04-09-2018 at 13:20.
Visual77 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-09-2018 , 13:24   Re: CreateConVar exits, what about DeleteConVar ?
Reply With Quote #4

Why do you need to delete the convar, only one plugin should be creating it. If you want to find it in another plugin use FindConVar()
Mitchell is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-09-2018 , 13:34   Re: CreateConVar exits, what about DeleteConVar ?
Reply With Quote #5

I want to delete them in order to tidy up the A2S_RULES list (the publicly quired server convars).

Lets say I load a plugin that is creating 10 public cvars with FCVAR_NOTIFY. During play, I unload this plugin without restarting the server that day. 1. The ConVars will still be in memory. and 2. They are still going to show up in the A2S_Rules list. These ConVars will be falsely quiered by HLSW, when the plugin is not even loaded on the server anymore.
Visual77 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-09-2018 , 13:45   Re: CreateConVar exits, what about DeleteConVar ?
Reply With Quote #6

I don't think HLSW is also setup to "forget" and recache what it found from the server.
Mitchell is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-09-2018 , 13:53   Re: CreateConVar exits, what about DeleteConVar ?
Reply With Quote #7

Quote:
Originally Posted by Mitchell View Post
I don't think HLSW is also setup to "forget" and recache what it found from the server.
You are right there, but I did some more tests (like installing HLSW on a virtual machine for the first time). The convars are unfortunetly still there? Only a reboot really clears the convars from HLSW, however I really want to avoid reboots when the server is full.

Last edited by Visual77; 04-09-2018 at 13:55.
Visual77 is offline
psychonic

BAFFLED
Join Date: May 2008
Old 04-09-2018 , 18:15   Re: CreateConVar exits, what about DeleteConVar ?
Reply With Quote #8

Quote:
Originally Posted by Visual77 View Post
Lets say I load a plugin that is creating 10 public cvars with FCVAR_NOTIFY. During play, I unload this plugin without restarting the server that day. 1. The ConVars will still be in memory. and 2. They are still going to show up in the A2S_Rules list. These ConVars will be falsely quiered by HLSW, when the plugin is not even loaded on the server anymore.
The A2S_Rules responses are provided by the steamclient bin. It has its own caching, and do not provide a way to clear a value, only a way to add/set a value and to clear all values. While workarounds could be made in SM (clearing all and re-adding all current NOTIFY values when the flag is cleared from one), SM doesn't interact directly with the Steamworks interfaces. You could probably do your own workaround using the Steamworks extension posted in the Extensions forum section. Look for AddKeyValue and ClearKeyValues.
psychonic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-09-2018 , 20:08   Re: CreateConVar exits, what about DeleteConVar ?
Reply With Quote #9

Quote:
Originally Posted by Visual77 View Post
Like the topic says. When I unload a certain plugin, I would like all of its created convars to be removed from the server memory. Is that possible, without restarting the server?
CreateConVar tells SourceMod to create a convar or if that convar already exists, return the handle for it.

The second half of the above sentence should tell you why DeleteConVar doesn't exist.

Quote:
Originally Posted by ThatKidWhoGames View Post
This is actually a great question. I imagined closing the ConVar handles would automatically delete the ConVars themselves, however, it doesn't.
When SourceMod creates a convar, SourceMod's core owns said convar (not the plugin) and it sets up the handle security so that plugins/extensions can't close the handle for said convar.

Edit 2 (Edit 1 got baleeted): In the Source 2013 source code, the only command I see for unregistering a ConVar will unregister every convar that a DLL owns. As I mentioned above, SourceMod owns all convars it creates on behalf of a plugin.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 04-09-2018 at 20:23.
Powerlord is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-10-2018 , 04:42   Re: CreateConVar exits, what about DeleteConVar ?
Reply With Quote #10

Quote:
Originally Posted by psychonic View Post
The A2S_Rules responses are provided by the steamclient bin. It has its own caching, and do not provide a way to clear a value, only a way to add/set a value and to clear all values. While workarounds could be made in SM (clearing all and re-adding all current NOTIFY values when the flag is cleared from one), SM doesn't interact directly with the Steamworks interfaces. You could probably do your own workaround using the Steamworks extension posted in the Extensions forum section. Look for AddKeyValue and ClearKeyValues.
These you mean?
Code:
native bool:SteamWorks_SetRule(const String:sKey[], const String:sValue[]);
native bool:SteamWorks_ClearRules();
Afaik, steamworks is only csgo, css, tf2. A linux fork exists somewhere with limited support for l4d2. I need .dll bins here.

Here's a test plugin btw of something I'm trying to achieve. I'm adding sv_region to A2S_Rules list, on plugin unload or convar unload, well you know what I want to do. Like you said, it doesn't clear the convar from the A2S list.
Attached Files
File Type: sp Get Plugin or Get Source (sv_region_public.sp - 141 views - 1.2 KB)

Last edited by Visual77; 04-10-2018 at 04:44.
Visual77 is offline
Reply


Thread Tools
Display Modes

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 19:11.


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