Creating a convar that changes part of a code

Hello. Question, in a gamemode, how would I create a console command that changes parts of a code? I’m trying to create a console command that would edit my GM:PlayerSpawn hook when enabled, and when disabled would run the hook but with different code. How would I do this?




local myConvar = CreateConVar() -- Actually give a name to your convar

if (myConvar:GetBool()) then
    -- myConvar is true
    -- myConvar is false

GetConVarNumber and GetConVarString (any method that fetches a convar by its name) is noticeably slow when used often, such as in an HUDPaint hook. You should really use _FR_Starfox4’s method (which is super super fast).

Yeah, I thought he was speaking about start up settings.

It’s just a pet peeve of mine because so many addons do it and it actually does have a notable framerate imapct.

Just searching on GitHub can lead to an example of it being used badly within seconds:

Oh, sorry if I was unclear, I meant a console command that does this.

I don’t see what using concommands would help you achieve when there’s already a lib that does what you need.