• gm_cvar2
    147 replies, posted
This is a small library that allows you to change the flags of any CVar on the server. For example CVars like [b]sv_accelerate[/b] and [b]sv_airaccelerate[/b] ever since Orange Box have been flagged as FCVAR_DEVELOPMENTONLY. (This means you cannot set them from console, rcon or cfg files) To remove this flag and have access to this CVar you can do the following. [lua]require("cvar2") cvar2.SetFlags("sv_airaccelerate", cvar2.GetFlags("sv_airaccelerate") - FCVAR_DEVELOPMENTONLY)[/lua] This CVar can now be set from .cfg files and from RCon. [b]Functions in cvar2[/b] [lua] cvar2.SetFlags(cvarName, FCVAR_* Constants) cvar2.GetFlags(cvarName) cvar2.SetHelpText(cvarName, text) // Do not call this too much. Do not call in a think func, you will create a memory leak. cvar2.GetAll() // returns a table of the name of every cvar ccmd on the server and client replicated ones. cvar2.ToggleFlag(cvarName, flag) cvar2.GetValue(cvarName) cvar2.SetValue(cvarName, value) // value can be a string, bool or number(float and integer) cvar2.IsFlagSet(cvarName, flag) cvar2.ResetValue(cvarName) // resets value to default value [b]REMOVED[/b]cvar2.ExecuteCommandOnClient(playerid, command) // Executes a command on a player through INetChannel [b]REMOVED[/b]cvar2.GetUserSetting(playerid, clientCvar) // only works on cvars with FCVAR_USERINFO [b]REMOVED[/b]cvar2.ReplicateData(playerid, cvarName, datastr) // Doesn't seem to work with things like mat_fullbright sadly, just left it here for others to try out. FCVAR_DEVELOPMENTONLY [/lua] [b]Download(DLL Binary)[/b] [url]http://gmod-haza.googlecode.com/svn/trunk/gm_cvar2/Release/gm_cvar2.dll[/url] [b]Download(SVN Source Code)[/b] [url]http://gmod-haza.googlecode.com/svn/trunk/gm_cvar2[/url] CVars Affected by FCVAR_DEVELOPMENTONLY in Orange Box SDK [lua]sv_showanimstate sv_suppress_viewpunch sv_optimizedmovement sv_stopspeed sv_maxspeed sv_accelerate sv_airaccelerate sv_wateraccelerate sv_waterfriction sv_footsteps sv_rollspeed sv_rollangle sv_friction sv_bounce sv_maxvelocity sv_stepsize sv_backspeed sv_waterdist[/lua] [b]Now for the paradox of win! Good thing to do yo your admins.[/b] [quote] ] sv_cheats 1 Can't use cheat cvar sv_cheats in multiplayer, unless the server has sv_cheats set to 1. [/quote]
Awesome! D: Can you give us a list with all cvars that are not accessable yet?
Hm, interesting. Can I suggest a function for setting restricted convars? I know you can do it by using either of the two available console modules, but having a separate function is a bit more smoother. If not, then can I use your method of retrieving ICvar interface from the server dll and use it in my module?
Pretty handy! Thanks for making and sharing this! Could you add ConVar:SetHelpText(), please.
Great job bud! I agree with Deco Da Man, a SetHelpText would be awesome! (Cause garry wouldn't add anything useful like this, he just likes to remove features).
shutup he made fretta everyone [s]plays that[/s] [s]will play it[/s].
Looks cool, probably going to mess around with it. [QUOTE=JetBoom;14764840]shutup he made fretta everyone [s]plays that[/s] [s]will play it[/s].[/QUOTE] Yea he made fretta, as in TAKING someones Base idea and turning it into his then removing features for no reason. Stop being a garry fanboy.
Cool.
someone reupload this to somewhere that doesn't suck
[quote]This file is neither allocated to a Premium Account, or a Collector's Account, and can therefore only be downloaded 10 times. This limit is reached.[/quote] Fix download please.
Updated, Download Fixed, New version with more functions. [QUOTE=Nevec;14763498]Hm, interesting. Can I suggest a function for setting restricted convars? I know you can do it by using either of the two available console modules, but having a separate function is a bit more smoother. If not, then can I use your method of retrieving ICvar interface from the server dll and use it in my module?[/QUOTE] Go for it.
Surf in GMod anyone? ^^
thanks for the reupload hunnybuns
in case it helps, i found this in the sdk: [code]m_nFlags &= ~FCVAR_DEVELOPMENTONLY;[/code] this is the proper way to toggle off flags, in this case for FCVAR_DEVELOPMENTONLY. you can use a single xor operation if you want to toggle them.
Thanks, if it gets removed from GMod.org just upload it to someplace like solidfiles.com. I went ahead and uploaded it to solidfiles, I don't want to loose this module. [url=http://solidfiles.com/d/8tK2][img]http://solidfiles.com/info_imgs/8tK2.jpg[/img][/url]
What could I say, nice! I had something similar but I was stripping FCVAR_CHEAT off. That way I am able to change cvars like physcannon_tracelength or physcannon_maxmass on server without cheats turned on. Command flags can also be stripper so ent_fire could be possible without sv_cheats 1. I have done a FCVAR_CHEAT stripper for concommands too but haven't really tested it as I haven't found any nice commands except this ent_fire. Now if it would be possible for the server to allow for example "mat_fullbright" or "thirdperson" on build servers =(
slightly modified the setflags function [cpp]LUA_FUNCTION(ToggleFlag) { gLua->CheckType(1, GLua::TYPE_STRING); gLua->CheckType(2, GLua::TYPE_NUMBER); if(!cvar2) { gLua->Error("cvar2 interface not loaded."); return 0; } ConCommandBase *var = (*cvar2)->FindCommandBase(gLua->GetString(1)); if(!var) { gLua->Error("cvar/ccmd not found."); return 0; } // m_nFlags needs to be made public in convar.h, this will only affect this dll, the class struct will stay the same but the compiler won't complain. int *flags = &var->m_nFlags; *flags ^= gLua->GetInteger(2); (*flags & gLua->GetInteger(2)) ? gLua->Msg("Flag turned on.\n") : gLua->Msg("Flag turned off.\n"); return 0; }[/cpp]
Ahh very nice hfs, I'll put this in my new version. I am also going to do research in forcing a client var to change. Edit: Updated with version 4
I may be wrong, but the latest update may have broken this. They're no longer accessible even though I have not changed a thing other than updating.
The precompiled module doesn't work for some reason. Compile it yourself or use the one my friend compiled for me (I couldn't get the Source SDK to behave): [url]http://www.easy-share.com/1905198603/gmsv_cvar2.dll[/url] I'll hang you from your toes if you say that is a virus :) EDIT: I've been trying to get sv_cheats to be 1 on clients and 0 on server. This works to a point. The clients already on server have sv_cheats turned to 1 but new clients still get 0. How could I change this? How I did it so far is by turning sv_cheats on and removing the notify and replicate flags and then turning cheats off.
You need the replicate flag otherwise it wont send it to the clients.
Clients default to sv_cheats 0 Server should have sv_cheats 0 I want all clients to have sv_cheats 1 Replicate flag would just replicate sv_cheats 0, right? I need a cvar fake change reporter or something.
[QUOTE=Python1320;15253497]Clients default to sv_cheats 0 Server should have sv_cheats 0 I want all clients to have sv_cheats 1 Replicate flag would just replicate sv_cheats 0, right? I need a cvar fake change reporter or something.[/QUOTE] I'd write a timer to, say, every five minutes, add the replicate flag, set cheats to 1, turn off the replicate, and then reenable them. Hell, make it do this every 30 seconds.
Thought the same, or make it do that on player initial spawn. Guess there isn't any other way.. EDIT: Player inital spawn and cvar2.ReplicateData works for sv_cheats. Now people can have fun with their mat_fullbright and other stuff.
does this here works clientside?
Enlighten me, what would you do with this clientside? On the other hand, the module is named gm_ which usually means it is both client and server or the developer forgot to rename it.
[QUOTE=TehBigA;14767162]Looks cool, probably going to mess around with it. Yea he made fretta, as in TAKING someones Base idea and turning it into his then removing features for no reason. Stop being a garry fanboy.[/QUOTE] It was sarcasm, you could tell by the [s] which doesn't work on facepunch.
Bump. Where do I put this? :downs:
lua/includes/modules if i am correct.
I shove the dll in the modules folder but it won't work. :downs:
Sorry, you need to Log In to post a reply to this thread.