How to create server-wide aliases for console commands in Source games

server-administrationsource-engineteam-fortress-2

I'm an administrator on a couple TF2 servers, and I've installed a couple Sourcemod plugins (MeleeMode, ClassChooser, etc.). However, to get these to work the way I want, I have to set variables manually through the console like

sm_cvar sm_meleemode_enabled 1

While I know how to set up a local alias for a console command, I'd like to be able to create a server-wide "shortcut" so that all the admins will be able to use it without any setup on their end. I'd like them to be able to just open the console and type

meleeon

and this command would execute. Is there something I can add to the server.cfg or autoexec.cfg that will do this? Or maybe another workable solution?

Best Answer

The server alias syntax is the same as on the client side. You can place aliases inside server.cfg or choose to separate them into their own file for the sake of neatness.

server.cfg

exec aliases.cfg

aliases.cfg

alias "meleeon" "sm_cvar sm_meleemode_enabled 1;sm_cvar example 0"
alias "meleeoff" "sm_cvar sm_meleemode_enabled 0;sm_cvar example 1"

You should also be able to change the default values of cvars registered in SourceMod plugins or have them vary by map. Just ask if that interests you.