- nav:
- cs-nation home
- counter-strike info
- scripting
- toggling aliases tutorial
toggling aliases tutorial
Introduction
Tired of having too many keys bound to 'on' and 'off'? or other variations? well in this tutorial we will go over how to make a toggling alias, which will allow you to turn on and off the netgraph with only one button.
Step one, the basics.
First off we need something to toggle between on and off, I would suggest the ever useful net graph for this one =), so now that we have something to toggle, we have to start with the scripting, the first thing we need is alias so plop that down into your cfg, then we need a name for the command we are making, lets go with ngon and ngoff for this example, so so far it should look like this:
alias ngon
alias ngoff
Purdy ain't it? now, for the next part, we need the commands. But we have to decide on whether or not it echo's to the game screen, or just the console, or not at all. We'll start out without it and add it afterwards. Now we need the command for net graph, which is net_graph it has 4 settings, 1, 2, 3, and 0. For now we'll only use 0 and 3. so, add this after ngon:
alias ngoff
"net_graph 3;
So now, it should look like this:
alias ngon "net_graph 3;
alias ngoff
The reason why there is no closing quote is because we are not finished.
Now we need a key to have bound through the toggle, the choice is yours but I'll use "n". So now we add the cross bind:
alias ngoff
alias ngon "net_graph 3; bind n ngoff"
And lets complete ngoff now too, fairly simple, change the 3 to a 0, and switch ngon with ngoff, and ngoff with ngon:
alias ngoff "net_graph 0; bind n ngon"
So, now that we have the commands all done, lets finish it off with a bind KEY command.
Final Product:
alias ngon "net_graph 3; bind n ngoff"
alias ngoff "net_graph 0; bind n ngon"
bind n "ngon"
Now, everytime you hit "n" it will turn on/off the net graph at setting 3, which reports your frames and any packetloss you may have.
alias ngoff "net_graph 0; bind n ngon"
bind n "ngon"
Step two, echoing it to your console and screen
Well we have this done:
alias ngon "net_graph 3; bind n ngoff"
alias ngoff "net_graph 0; bind n ngon"
bind n "ngon"
Were gonna take that and add a few commands to it, lets start with echoing it to the console alone. Now we need something to say, for this lets use "Net Graph on" and "Net Graph off", so the command will be echo Net Graph on and echo Net Graph off, lets add that now:
alias ngoff "net_graph 0; bind n ngon"
bind n "ngon"
alias ngon "echo Net Graph on; net_graph 3; bind n ngoff"
alias ngoff "echo Net Graph off; net_graph 0; bind n ngon"
bind n "ngon"
There! we did it! now it will report to the console that the net graph is on, or off. Now lets get it to report that to the game screen. To do this we have to use a special command.. which is developer, this command has 3 settings if i'm not mistaken... 0, 1, and 2, setting 1 is three or four lines on screen, and setting 2 probably has double (NOTE: this lets everything the console says be reported to the screen). so before the echo command we need a developer 1 and after it we need a developer 0. Lets add that:
alias ngoff "echo Net Graph off; net_graph 0; bind n ngon"
bind n "ngon"
alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; bind n ngoff"
alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; bind n ngon"
bind n "ngon"
alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; bind n ngon"
bind n "ngon"
Step three, user friendlizing
To make it so it can be added to the control's menu, we need to take out all those alias binds, and change them to an alias.
(example: alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; BIND N NGOFF")
Its not as tough as it sounds. Replace it with alias ng ngoff, and be sure to change the other as well. So now we have this:
alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; alias ng ngoff"
alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ngon"
But this also means we have to add another alias, put this below it: alias ng ngon, so we now have:
alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ngon"
alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; alias ng ngoff"
alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ngon"
alias ng "ngon"
And now all we have to do is bind ng:
alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ngon"
alias ng "ngon"
alias ngon "developer 1; echo Net Graph on; developer 0; net_graph 3; alias ng ngoff"
alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ngon"
alias ng "ngon" bind n "ng"
There we go! now to change this toggle all we have to do is change the bind, simple! so we can add this to kb_act.lst (open with notepad):
alias ngoff "developer 1; echo Net Graph off; developer 0; net_graph 0; alias ng ngon"
alias ng "ngon" bind n "ng"
"ng" "Toggle the net graph"
-Corpo
