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

Solved How to prevent cvar to be changed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 12-02-2018 , 13:07   How to prevent cvar to be changed
Reply With Quote #1

I have cvar sm_max_items and I want to prevent it to be changed from other plugins for a while.
For example, I have a function, in beginning of this, I change this cvar to 9999, in the end I change this cvar to default, but another functions, which are used in this function can also change this cvar. Is it possible to make cvar 'constant' for a while?

Last edited by impossible_cc; 12-03-2018 at 05:47.
impossible_cc is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 12-02-2018 , 13:51   Re: How to prevent cvar to be changed
Reply With Quote #2

You add a change hook on that cvar, end whenever it get changed, to any value besides yours change it back.
https://sm.alliedmods.net/new-api/co.../AddChangeHook

Or you can try settings its bounds, if that cvar is meant to be a float/int, just set both bounds to your value.
https://sm.alliedmods.net/new-api/co...nVar/SetBounds
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!
Papero is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 12-03-2018 , 02:30   Re: How to prevent cvar to be changed
Reply With Quote #3

Quote:
Originally Posted by Papero View Post
You add a change hook on that cvar, end whenever it get changed, to any value besides yours change it back.
https://sm.alliedmods.net/new-api/co.../AddChangeHook

Or you can try settings its bounds, if that cvar is meant to be a float/int, just set both bounds to your value.
https://sm.alliedmods.net/new-api/co...nVar/SetBounds
Thanks, solved.
Btw am I able to close thread?
impossible_cc is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 12-03-2018 , 03:02   Re: How to prevent cvar to be changed
Reply With Quote #4

Quote:
Originally Posted by impossible_cc View Post
Thanks, solved.
Btw am I able to close thread?
Just mark it as solved.
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!
Papero 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 12:47.


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