Raised This Month: $32 Target: $400
 8% 

i can't understand cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
watashiwal
New Member
Join Date: Jun 2021
Old 06-24-2021 , 13:57   i can't understand cvar
Reply With Quote #1

the title says it

i know cvar=convar=console variables but i cant understand them are them every console command or what

i can use mp_roundtime in console and in servercommand("mp_roundtime")
but i cant use servercommand("sv_autobunnyhopping") despite i can use it in console,i have to use it like servercommand("sm_cvar sv_autobunnyhopping")


can anyone help me about in which cases i should use sm_cvar and not
watashiwal is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 06-24-2021 , 17:33   Re: i can't understand cvar
Reply With Quote #2

If you're dealing with ConVars, you can directly change their values without using ServerCommand().
Code:
ConVar sv_autobunnyhopping = FindConVar( "sv_autobunnyhopping" );
if ( sv_autobunnyhopping != null ) {
	sv_autobunnyhopping.BoolValue = true; // change sv_autobunnyhopping to "1"
}
sm_cvar is just an admin command to use in game (but you can also call it in code to change ConVar values, but that's not very effective).

You can use find <name> command to find ConVars and commands. For example:
Code:
find mp_footsteps
"mp_footsteps" = "1"
 game notify
if it prints equal sign and value - this is ConVar, otherwise this would be command.

You can also use CommandExists to ensure that specified command is valid.
__________________

Last edited by MAGNAT2645; 06-24-2021 at 17:34.
MAGNAT2645 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 14:27.


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