I want to be able to cycle through names, scripts or source commands.

By cycling i mean switching to another name, script or command after i press a button. Pressing this button repeatedly will go through all those entries until the end where it will reach the first entry again.

For example if I have 3 nicknames A, B and C and want to cycle through those.

Pressing a button shall execute a command that changes my name to B and after pressing the same button again my name will be changed to C. Pressing again will result in my name changing to A again, completing the cycle.

How would a template for this look like?

  • While I do like the sharing of information by answering your own question, this is a poor question when looked at on its own. It's pretty unclear what you're asking.
    – House
    Commented Dec 18, 2013 at 15:21
  • it was formated this way on arqade by high rep users so i just copied over since arqade do claim this is offtopic on their site. could you give me any advice what to improve? if you are not familiar with source engine scripts (and what users demand in it) it may not be clear to you at first but at the same time the question might not be interesting for you in the first place.
    – Wandang
    Commented Dec 18, 2013 at 16:40
  • 2
    Provide some brief background on what exactly you are "cycling" in or what exactly you mean by "cycling" in this context. Even though the question is specific in its focus you should be able to write it in such a way as include enough basic background information to give somebody who doesn't know the details of the Source engine to understand what are asking. As written, this question is only vaguely clarified by your answer, which is bad.
    – user6789
    Commented Dec 18, 2013 at 16:45
  • @Wandang Thanks, that's a bit clearer. In the future, if you frame the question in the context of the problem you're trying to solve (instead of just "How to do X?"), along with how you want it to work it'll give people a good idea of what you want and why.
    – House
    Commented Dec 18, 2013 at 16:58
  • This should not have been migrated in the first place.
    – 3ventic
    Commented Dec 20, 2013 at 20:58

2 Answers 2


To cycle through different names/settings/scripts etc you need to follow the following pattern (At the end there is the full code if you want to skip the details):

Cycling through self made scripts using alias

Step 1: Set a starting point

alias cycler "useName1"

Now if we trigger cycler -> useName1 will be executed.

cycler and useName1 are names i made up. You can change those to whatever fits your needs.

Step 2: Define useName1 and set cycler

alias useName1 "setinfo name "First_name"; alias cycler useName2"

This will execute the namechange (or your script or your setting) and set the cycler to useName2. The next time we trigger cycler -> useName2 will be executed.

useName2 is a name i made up too.

Step 3: Define useName2 and set cycler

alias useName2 "setinfo name "Second_name"; alias cycler useName1"

This will execute the second namechange (or your script or your setting) and set the cycler back to useName1. The next time we trigger cycler -> useName1 will be executed again. The cycle is complete.

Step 4: Bind your cycler to a key

bind "key" cycler

We are done. You can repeat part 2 and 3 for other definitions (if you switch through 15 names, go for it). Just let the last set the cycler onto the first!

Full Code Solution 1

alias cycler "useName1"
alias useName1 "setinfo name "First_name"; alias cycler useName2"
alias useName2 "setinfo name "Second_name"; alias cycler useName1"
bind "key" cycler

Cycling through settings provided by the source engine

If you want to iterate through settings that are predefined by the source engine and require a number as a value, for example:

net_graph x (value 0 to 3 are possible)
sensitivity x (any value is possible)

then you don't need to use the cycler above.

Instead source provides us with two nifty commands:


toggle command value1 value2 value3

This command let's us cycle through the setting with specific values.

For example:

toggle net_graph 1 2 3

Starts with executing net_graph 1. Using this command again executes net_graph 2 and so forth.

To use this command quickly just go ahead and bind it to a key

Full Code toggle

bind "x" "toggle net_graph 1 2 3"


incrementvar command min max steps

This let's us cycle through the setting in defined steps.

For example:

incrementvar net_graph 1 3 1

Starts with net_graph 1 and increases each step +1. This means executing the command again results in net_graph 2. The next would be net_graph 3. After that it will jump back to net_graph 1 because we told him that the max value would be 3.

The other example would be:

incrementvar sensitivity 200 800 200

which increases the sensitivity by 200 each time we execute this until it reaches 800 at which point it will drop to 200 again.

The steps can be negative to (cycle backwards) like:

incrementvar sensitivity 200 800 -200

To use this command we still need to bind it:

Full Code incrementvar

bind "key" "incrementvar sensitivity 200 800 200"

Another Solution

Another solution to cycle through variables (settings,commands etc) would be to rebind the button directly.

This however is discouraged since it takes more resources from the system while just changing an alias to another does not interfere with keymapping at all which is therefore quite static.

Still I will show it for completeness

Full Code Solution 2

alias useName1 "setinfo name "First_name"; bind "key" useName2"
alias useName2 "setinfo name "Second_name"; bind "key" useName1"
bind "key" useName1

Full Code Solution 2 - work fine WITHOUT setinfo

alias useName1 "dota_spectator_mode "1"; bind "c" useName2"
alias useName2 "dota_spectator_mode "3"; bind "c" useName1"
bind "c" useName1
  • The only thing you've really changed is the part which sets the users name, which is specifically what the original question asks for :\
    – DBS
    Commented Nov 3, 2015 at 0:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .