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

[tf2] how to get cvar value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr.Doctor
AlliedModders Donor
Join Date: Feb 2017
Location: Hong Kong
Old 02-25-2017 , 09:30   [tf2] how to get cvar value
Reply With Quote #1

cvar sm_yoyoyo, "2"

how to get the value 2?
Dr.Doctor is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 02-25-2017 , 09:36   Re: [tf2] how to get cvar value
Reply With Quote #2

Read the API then come back here if you any questions.
__________________
Benoist3012 is offline
Dr.Doctor
AlliedModders Donor
Join Date: Feb 2017
Location: Hong Kong
Old 02-25-2017 , 10:20   Re: [tf2] how to get cvar value
Reply With Quote #3

is it possible to get value of cvar from other plugin?
Dr.Doctor is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 02-25-2017 , 11:27   Re: [tf2] how to get cvar value
Reply With Quote #4

If I'm not mistaken yes, use FindConVar native and store it in a global variable, and under OnAllPluginsLoaded forward not OnPluginStart()!
__________________

Last edited by Benoist3012; 02-25-2017 at 11:29.
Benoist3012 is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 02-25-2017 , 13:27   Re: [tf2] how to get cvar value
Reply With Quote #5

Why not in Onpluginstart
__________________
Chdata is offline
sdz
Senior Member
Join Date: Feb 2012
Old 02-25-2017 , 13:40   Re: [tf2] how to get cvar value
Reply With Quote #6

@Dr.Doctor
Examples of the above suggestions:
PHP Code:
#include <sourcemod>

new g_iYoyoyo = -1;

//Looks like it's from another sourcemod plugin, so we'll wait until all are loaded for safety...
public OnAllPluginsLoaded()
{
    
g_iYoyoyo GetConVarInt(FindConVar("sm_yoyoyo"));

sdz is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 02-25-2017 , 14:30   Re: [tf2] how to get cvar value
Reply With Quote #7

Quote:
Originally Posted by Chdata View Post
Why not in Onpluginstart
Because your plugin could load before the plugin you want to retrieve the cvar from.
__________________
Benoist3012 is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 02-25-2017 , 21:03   Re: [tf2] how to get cvar value
Reply With Quote #8

Quote:
Originally Posted by Benoist3012 View Post
If I'm not mistaken yes, use FindConVar native and store it in a global variable, and under OnAllPluginsLoaded forward not OnPluginStart()!
Quote:
Originally Posted by Chdata View Post
Why not in Onpluginstart
Quote:
Originally Posted by Benoist3012 View Post
Because your plugin could load before the plugin you want to retrieve the cvar from.
Have you seen OnConfigsExecuted?
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].

Last edited by DarkDeviL; 02-25-2017 at 21:04.
DarkDeviL is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-26-2017 , 00:47   Re: [tf2] how to get cvar value
Reply With Quote #9

Quote:
Originally Posted by arne1288 View Post
Have you seen OnConfigsExecuted?
OnConfigsExecuted is called once per map change and as such is the wrong place to call FindConVar, which doesn't change from map to map.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 02-26-2017 , 02:37   Re: [tf2] how to get cvar value
Reply With Quote #10

Quote:
Originally Posted by Powerlord View Post
OnConfigsExecuted is called once per map change and as such is the wrong place to call FindConVar, which doesn't change from map to map.
OnConfigsExecuted:
Quote:
Originally Posted by OnConfigsExecuted
Called when the map has loaded, servercfgfile (server.cfg) has been executed, and all plugin configs are done executing. This is the best place to initialize plugin functions which are based on cvar data.
I guess I may have misunderstood the red part then. :-(
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL 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 08:58.


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