View Single Post
Author Message
axelnieves2012
Senior Member
Join Date: Oct 2014
Location: Argentina
Old 07-30-2019 , 02:31   [ANY] ADVANCED and silent CVAR change [AGO 2019]
Reply With Quote #1

WELCOME

INTRODUCTION:
For months I've been looking for a way to get rid of those annoying chat reports whenever a CVAR changed (requested by admin, automatic plugins, etc), and I've not found a working solution.
So I made this plugin.

DESCRIPTION:
This plugin adds new commands which replace sm_cvar, with the same functionality, and no chat spamming (it even works on FCVAR_NOTIFY convars).

BONUS 1: You can also print result to server console. And you can also add a delay before a cvar is changed.
*NEW*: Now you can set a cvar pointing to another cvar's value.

INFO:
Delay must be given as float string. 1.0=1 second // 0.5=half second.
If omited, or <=0.0, plugin will change your cvar inmediatelly.

REQUERIMENTS:
- Sourcemod >= 1.9

Change log:
Version 1.1 [1 AGO 2019]
- Added ability to set a cvar pointing to another cvar's value.
Version 1.0 [30 JUL 2019] (23 downloads)
- Initial release.

Convars:
PHP Code:
sm_acvar_server_always "1"
Print always result to server console when using sm_acvar and sm_adcvarIt`s a good idea enabling it if you pretend to use "sm_acvar" replacing "sm_cvar". 
Admin commands:
PHP Code:
sm_acvar convar_name "convar value".
Changes a cvar value without printing result to chatnor consolenor serverResult will be printed to server if sm_acvar_always is enabled.

sm_acvar_console convar_name "convar value".
Changes a cvar value printing result to admin`s console only. This command is not affected by sm_acvar_always.

sm_acvar_server convar_name "convar value".
Changes a cvar value printing result to server
`s console only.

sm_adcvar float:delay=0.0 convar_name "convar value".
Changes a cvar value without printing result to chatnor consolenor serverCVar will be changed after specified delayResult will be printed to server if sm_acvar_always is enabled.

sm_adcvar_console float:delay=0.0 convar_name "convar value".
Changes a cvar value printing result to admin`s console only. CVar will be changed after specified delay. This command is not affected by sm_acvar_always.

sm_adcvar_server float:delay=0.0 convar_name "convar value".
Changes a cvar value printing result to server
`s console onlyCVar will be changed after specified delay
Console commands:
No user commands implemented.

Known bugs:
- None at the moment. Please, report here.

To do list:
- Post suggestions here.

Using CVar pointing to another CVar value:
To set a cvar to another cvar's value, you should pass its name prepended by a dollar sign, AT THE VERY BEGINING OF THE ARGUMENT.
Example 1:
Code:
sm_acvar mp_footsteps $mp_flashlight
You can only point to one cvar per command.
Above example will set "mp_footsteps" according to mp_flashlight's value.

Example 2 (This is wrong):
Code:
sm_acvar hostname "welcome to $mp_gamemode"
This will not work because you cannot point to a cvar in a mid-string.

If you want to use a dollar sign at the begining of a string, and it doesnt be parsed as a cvar, you should use a double dollar sign to override its functionality.

Example 3:
Code:
sm_acvar hostname "$$peedfire"
Above code will set "hostname" to "$speedfire".


Examples:
sm_acvar sv_cheats 1
Changes 'sv_cheats' to '1' without any chat message.
sm_acvar_server hostname "L4D1 TANK RUSH 24/7"
Changes 'hostname' to 'L4D1 TANK RUSH 24/7' and prints result to server console only.
sm_adcvar_server 5.0 mp_friendlyfire 1
Will change 'mp_friendlyfire' to '1' within next 5 seconds after command is entered. And result will be printed to serverīs console.
sm_adcvar 0.1 sv_gametypes "coop, versus, teamversus"
Will change 'sv_gametypes' to 'coop, versus, teamversus' within next 0.1 second after command is entered.
Examples pointing to another cvar value:
sm_acvar z_hunter_limit $survivor_limit
Will set z_hunter_limit to survivor_limit's current value.
sm_acvar mp_freezetime $mp_buytime
Will set mp_freezetime to mp_buytime's current value.
sm_acvar hostname "$$uPeR cR4zy $erVer"
Will set hostname to $uPeR cR4zy $erver.
IMPORTANT: In this example, only $$uPeR needs double '$' to avoid cvar pointing. $erVer doesn't need double dollar sign because it's not at the very begining of the string.
Beta testing versions:
- Beta testing versions will be posted here.
The purpose of this is posting my work progress oftenly. They may include unused code, unstable behaviors, non-working features, and some stuff can be removed on next official release.
Click "show" for BETA versions:
Spoiler


Official last version:
Attached Files
File Type: sp Get Plugin or Get Source (sm_acvar.sp - 1221 views - 6.4 KB)

Last edited by axelnieves2012; 03-18-2021 at 00:48.
axelnieves2012 is offline