AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [ANY] ADVANCED and silent CVAR change [AGO 2019] (https://forums.alliedmods.net/showthread.php?t=317790)

axelnieves2012 07-30-2019 02:31

[ANY] ADVANCED and silent CVAR change [AGO 2019]
 
2 Attachment(s)
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:

aykocity 07-30-2019 19:19

Re: [ANY] ADVANCED and silent CVAR change [JUL 2019]
 
hi;

Quote:

I have some requests

Example:
sm_adcvar_server 30.0 sm_blind @all 300
sm_adcvar_server 50.0 sm_blind @all 0

and reset each round
thanks for sharing

axelnieves2012 07-30-2019 22:51

Re: [ANY] ADVANCED and silent CVAR change [JUL 2019]
 
Quote:

Originally Posted by aykocity (Post 2661219)
hi;



thanks for sharing

Hello, I cannot understand your request. Can you explain me, please?
I know a plugin that reloads current map (sm_reloadmap command).
And I know a plugins that execs commands with delay (sm_delaycmd command).
You can combine them:
sm_delaycmd 5.0 sm_reloadmap.

Is this what you are looking for?

aykocity 07-31-2019 09:28

Re: [ANY] ADVANCED and silent CVAR change [JUL 2019]
 
no :(

Quote:

example:

in de.cfg

1.round
sm_adcvar_server 30.0 sm_blind @all 300
sm_adcvar_server 50.0 sm_blind @all 0

2.round
sm_adcvar_server 30.0 sm_blind @all 300
sm_adcvar_server 50.0 sm_blind @all 0

3.4.5.6.... etc..
currently only works when the map is newly opened
next rounds not working

axelnieves2012 07-31-2019 22:56

Re: [ANY] ADVANCED and silent CVAR change [JUL 2019]
 
Quote:

Originally Posted by aykocity (Post 2661295)
no :(



currently only works when the map is newly opened
next rounds not working

Hello. I think you may be confused. As I could see, "sm_blind" is a command.
This script manages CONVARS, not commands.
Tell me exactly what are you trying to do. Maybe you are using this plugin by mistake.

I think you should do is:
Code:

sm_delaycmd 30.0 sm_blind @all 300
sm_delaycmd 50.0 sm_blind @all 0

In above code, you should know that both 'sm_delaycmd' commands are executed at the same time. This means that if you executed your CFG at 00:00:00s, you will blind @all at 0:00:30s. And @all will be unblinded at 0:00:50s, not at 0:01:20s.

You should also use a plugin that automatically loads your CFG on each round.
listenserver.cfg and server.cfg are executed on each mapchange, not on each new round.

Mi.Cura 01-19-2020 12:51

Re: [ANY] ADVANCED and silent CVAR change [AGO 2019]
 
Great job, works well and is very useful.
Thank you for sharing this solution.

:bacon!::bacon!:

alphaearth 01-19-2020 13:23

Re: [ANY] ADVANCED and silent CVAR change [AGO 2019]
 
I no longer need to change the codes of the plugins.

Code:

SetCvar("mp_maxrounds", 30);
SetCvar("mp_maxmoney", 16000);
SetCvar(char cvarName[64], value)
{
        Handle IntCvar;
        IntCvar = FindConVar(cvarName);
        if (IntCvar)
        {
                int flags = GetConVarFlags(IntCvar);
                flags &= -257;
                SetConVarFlags(IntCvar, flags);
                SetConVarInt(IntCvar, value, false, false);
                flags |= 256;
                SetConVarFlags(IntCvar, flags);
        }
}


Tonblader 03-14-2021 14:46

Re: [ANY] ADVANCED and silent CVAR change [AGO 2019]
 
Quote:

Originally Posted by axelnieves2012 (Post 2661102)
sm_adcvar_server 5.0 mp_friendlyfire 1

When the game restarts, round ends, round restarts, opens server, closes server, changes map, etc, is there any command to deactivate all the commands that were sent to be executed in the future?

[Any] Delay Command

axelnieves2012 03-17-2021 23:21

Re: [ANY] ADVANCED and silent CVAR change [AGO 2019]
 
Quote:

Originally Posted by Tonblader (Post 2740466)
When the game restarts, round ends, round restarts, opens server, closes server, changes map, is there any command to deactivate all the commands that were sent to be executed in the future?

[Any] Delay Command

Hello, I think this is easy. I have abandoned programming for long time. But I think I can post a Beta testing version for your needings. Maybe I will release it in the future. Stay tunned ^uwu^

axelnieves2012 03-18-2021 00:35

Re: [ANY] ADVANCED and silent CVAR change [AGO 2019]
 
Quote:

Originally Posted by Tonblader (Post 2740466)
When the game restarts, round ends, round restarts, opens server, closes server, changes map, is there any command to deactivate all the commands that were sent to be executed in the future?

[Any] Delay Command

I think it's done, but I haven't tested.
Check new file on top, under section: "Beta testing versions".
Please, tell me if this is ok. It hooks two Left4Dead events. I dont remember if this may be conflictive with other games.

You must now set sm_acvar_override_flags


All times are GMT -4. The time now is 16:45.

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