1. Post #1
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    This is a small library that allows you to change the flags of any CVar on the server.

    For example CVars like sv_accelerate and sv_airaccelerate 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.
    require("cvar2")
    cvar2.SetFlags("sv_airaccelerate", cvar2.GetFlags("sv_airaccelerate") - FCVAR_DEVELOPMENTONLY)

    This CVar can now be set from .cfg files and from RCon.

    Functions in cvar2
    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
    

    Download(DLL Binary)
    http://gmod-haza.googlecode.com/svn/...e/gm_cvar2.dll

    Download(SVN Source Code)
    http://gmod-haza.googlecode.com/svn/trunk/gm_cvar2


    CVars Affected by FCVAR_DEVELOPMENTONLY in Orange Box SDK
    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

    Now for the paradox of win! Good thing to do yo your admins.
    ] sv_cheats 1
    Can't use cheat cvar sv_cheats in multiplayer, unless the server has sv_cheats set to 1.
    Reply With Quote Edit / Delete Reply Australia Show Events Funny x 21Useful x 7Agree x 2Lua King x 1Informative x 1Winner x 1Bad Reading x 1 (list)

  2. Post #2
    Gold Member
    LuaStoned's Avatar
    September 2007
    1,358 Posts
    Awesome! D:

    Can you give us a list with all cvars that are not accessable yet?

  3. Post #3
    Gold Member
    Nevec's Avatar
    June 2008
    1,094 Posts
    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?

  4. Post #4
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,017 Posts
    Pretty handy! Thanks for making and sharing this!

    Could you add ConVar:SetHelpText(), please.
    Reply With Quote Edit / Delete Reply Australia Show Events Dumb Dumb x 1 (list)

  5. Post #5
    CactusMelon's Avatar
    April 2009
    8 Posts
    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).
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Agree Agree x 1 (list)

  6. Post #6
    shutup he made fretta everyone [s]plays that[/s] [s]will play it[/s].

  7. Post #7
    Reposting BUG threads since 2011!
    TehBigA's Avatar
    March 2007
    426 Posts
    Looks cool, probably going to mess around with it.

    shutup he made fretta everyone [s]plays that[/s] [s]will play it[/s].
    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.
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 4Funny Funny x 1Informative Informative x 1 (list)

  8. Post #8
    metromod.net
    ChewGum's Avatar
    October 2007
    1,138 Posts
    Cool.

  9. Post #9
    hfs
    hfs's Avatar
    February 2008
    62 Posts
    someone reupload this to somewhere that doesn't suck

  10. Post #10
    Ywa
    Ywa's Avatar
    June 2007
    211 Posts
    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.
    Fix download please.

  11. Post #11
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    Updated, Download Fixed, New version with more functions.

    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?
    Go for it.

  12. Post #12
    Dennab
    March 2009
    1,572 Posts
    Surf in GMod anyone? ^^

  13. Post #13
    hfs
    hfs's Avatar
    February 2008
    62 Posts
    thanks for the reupload hunnybuns

  14. Post #14
    hfs
    hfs's Avatar
    February 2008
    62 Posts
    in case it helps, i found this in the sdk:
    Code:
    m_nFlags &= ~FCVAR_DEVELOPMENTONLY;
    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.

  15. Post #15
    jonney934's Avatar
    December 2007
    238 Posts
    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.
    Reply With Quote Edit / Delete Reply United States Show Events Bad Spelling Bad Spelling x 1Optimistic Optimistic x 1 (list)

  16. Post #16
    likes men
    Python1320's Avatar
    May 2007
    1,722 Posts
    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 =(
    Reply With Quote Edit / Delete Reply Finland Show Events Dumb Dumb x 1Lua King Lua King x 1 (list)

  17. Post #17
    hfs
    hfs's Avatar
    February 2008
    62 Posts
    slightly modified the setflags function

    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;
    }

  18. Post #18
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    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

  19. Post #19
    Gold Member
    TomatoSoup's Avatar
    December 2006
    253 Posts
    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.

  20. Post #20
    likes men
    Python1320's Avatar
    May 2007
    1,722 Posts
    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): http://www.easy-share.com/1905198603/gmsv_cvar2.dll
    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.

  21. Post #21
    Box collector
    haza55's Avatar
    October 2005
    545 Posts
    You need the replicate flag otherwise it wont send it to the clients.

  22. Post #22
    likes men
    Python1320's Avatar
    May 2007
    1,722 Posts
    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.

  23. Post #23
    Gold Member
    TomatoSoup's Avatar
    December 2006
    253 Posts
    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.
    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.

  24. Post #24
    likes men
    Python1320's Avatar
    May 2007
    1,722 Posts
    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.

  25. Post #25
    wormsdk's Avatar
    January 2009
    30 Posts
    does this here works clientside?
    Reply With Quote Edit / Delete Reply Denmark Show Events Dumb Dumb x 7 (list)

  26. Post #26
    likes men
    Python1320's Avatar
    May 2007
    1,722 Posts
    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.

  27. Post #27
    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.
    It was sarcasm, you could tell by the [s] which doesn't work on facepunch.

  28. Post #28
    Gold Member
    DOG X9282's Avatar
    June 2007
    748 Posts
    Bump.

    Where do I put this?
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Dumb Dumb x 3 (list)

  29. Post #29
    kevkev's Avatar
    April 2007
    1,093 Posts
    lua/includes/modules if i am correct.
    Reply With Quote Edit / Delete Reply Netherlands Show Events Agree Agree x 3 (list)

  30. Post #30
    Raider Munch's Avatar
    September 2007
    204 Posts
    I shove the dll in the modules folder but it won't work.
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 1Funny Funny x 1 (list)

  31. Post #31
    You need to require it in your script.
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Agree Agree x 1 (list)

  32. Post #32

    February 2009
    305 Posts
    How do you do that?
    Reply With Quote Edit / Delete Reply Australia Show Events Dumb Dumb x 4Funny Funny x 2 (list)

  33. Post #33
    likes men
    Python1320's Avatar
    May 2007
    1,722 Posts
    You need to require it in your script.
    How do you do that?
    require"modulename"

  34. Post #34

    February 2009
    305 Posts
    Where do i put the code

    Edited:

    Also can u set sv_airaccelerate
    Reply With Quote Edit / Delete Reply Australia Show Events Dumb Dumb x 6 (list)

  35. Post #35
    Gold Member
    Helix Alioth's Avatar
    August 2009
    2,566 Posts
    -snip, didn't know this at time, now I do-
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 5 (list)

  36. Post #36
    Salads's Avatar
    November 2008
    176 Posts
    require("modulename")
    There isn't anything wrong with Python1320's syntax. Either way works.
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 8 (list)

  37. Post #37
    cheiftiger's Avatar
    March 2009
    231 Posts
    Ok guys, I don't know why, but this just isn't working for my server. Here's my code (very simple):

    require("cvar2")
    cvar2.SetFlags("sv_airaccelerate", cvar2.GetFlags("sv_airaccelerate") - FCVAR_DEVELOPMENTONLY)
    

    And I have that code saved in its own LUA file in lua/autorun/server and it's not working. At some points I can see the convar (I used this for sv_airaccelerate which is defaulty 10), but I can't change it to something else. Every other time it will just say unknown command...

    Help?
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 6Agree Agree x 1 (list)

  38. Post #38
    cheiftiger's Avatar
    March 2009
    231 Posts
    I don't see how asking for help is dumb, but hey, it's facepunch.
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 6Dumb Dumb x 4Funny Funny x 3 (list)

  39. Post #39

    July 2009
    350 Posts
    sadly if you dont give us any more information you are going to keep getting rated dumb
    did you download GM_cvar2?
    have you extracted the zip file?
    Where have you place GM_cvar2?
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Dumb x 6Disagree x 1Funny x 1Agree x 1Bad Spelling x 1 (list)

  40. Post #40
    cheiftiger's Avatar
    March 2009
    231 Posts
    sadly if you dont give us any more information you are going to keep getting rated dumb
    did you download GM_cvar2?
    have you extracted the zip file?
    Where have you place GM_cvar2?
    I'm not a total idiot. I have a commercially hosted server and they have it on their mods list (because they're bitchy and won't let you upload dlls), and YES I have checked and it IS installed properly. For those of you that just HAVE to have the directory it's in, it's located in "lua/includes/modules" and for added obviousness is named "gm_cvar2.dll"

    That good enough for ya?
    Reply With Quote Edit / Delete Reply United States Show Events Funny Funny x 2Dumb Dumb x 1Zing Zing x 1 (list)