Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Will modify the CS1.5 script, come on, master high score! Also add points!
Will modify the CS1.5 script, come on, master high score! Also add points!
preparation:

open your config.cfg (under the cstrick directory) with wordpad. Change the line "console "".""

to console ""1"".

Then add

-console -zone 496 -dev

such as: c: Sierra Half-lifehl.exe-console-zone 499 after the program address in cstrike shortcut.

It can be said that scripts are built on the basis of macros, which is also the first question we must understand.

The general format of macros is as follows:

alias [alias-name] ""[command1]; [command 2]; [command #] ... ""

We can see that a macro is actually a collection of a series of instructions, so any macro can also be applied to other macros.

some of the most commonly used commands in scripts

menu #-# are numbers from 1 to 9. This command indicates the # th option in the selection menu. For example,

alias joinct ""chooseteam; Menuselect 2""

The contents in quotation marks indicate that item 2 of the team menu is selected. That is, the CT side

bind KEY COMMAND-

defines a specific COMMAND to a key. Note:' command' can also be a macro.

For example, bind ""k """kill" "

defines the command kill to k, If you press k, you will commit suicide

Another example is: bind ""k """Join CT" "

If you press k, you will join the CT side.

exec name.cfg-

Import a cfg file. HL will automatically import config.cfg and autoexec.cfg files every time it enters the game.

Wait-< The wait in is to let the previous instruction finish. How many waits are used depends on different computer and network conditions. Too many waits will cause lag, and too few may make the next instruction too late to execute.

Simple macros

Let's look at some of the simplest macros to get familiar with

Open autoexec.cfg and write the following lines:

alias hello ""say welcome to. ; wait; wait; kill; wait;

wait; say_team Welcome to CsChina.net! ""

Let's take a look at the structure of this macro:

There is an instruction set in quotation marks, in which say is used to speak to everyone in the game and say_team is used to speak to all teammates

Note: semicolons are used between individual instructions;

this instruction set is defined as a macro called hello

Don't worry, you must define the macro you just made to a certain key position before you can use it. Enter the game and type

bind ""k """hello" "

in the control panel. Ok, now let's press k to see the effect. Hoho~~

The types of macros and simple scripting

The basic concepts of scripting are clear to us. Now let's take a look at several types of macros and put them into simple scripting

+/- aliases

The meaning is that when a key is pressed, one instruction set is executed, while when the key is released, another instruction set is executed (note: these two instruction sets can be the same or unrelated). say_team Cover me while I reload! ""

alias-say reload ""-reload ""

+/-

aliases can make your original simple actions more diversified, such as expanding to be more complex but more effective meta

bindings (

meta bindings

meta bindings is actually a kind of +/- alias. Meta

bindings redefined the key after releasing the definition key (←Archangel note: this line is in red font.) Be sure to pay attention to this difference, which will be very helpful to understand the types of these two macros.

let's look at a common example of making a quick buy and grab script:

Example:

alias preset1 ""buy; menuselect 4; menuselect 6; buy; menuselect 6; buyequip;

menuselect 2""

// Buy AWM, bullets and body armor

alias preset2 ""buy; menuselect 3; menuselect 1; buy; menuselect 6; buyequip;

menuselect 1; ""

// Buy MP5, bullets and body armor

alias preset3 ""buy; menuselect 2; menuselect 1; buy; menuselect 1;

menuselect 5; buy; menuselect 6; buy; menuselect 7; buyequip; Menuselect 2""

// Buy M3,beretta, bullets and bulletproof vest with helmet

alias preset4 ""buy; menuselect 1; menuselect 3; buy; Menuselect 7""

// Buy grenades and bullets

alias preset5 ""developer 1; echo Preset not set! ; Developer ""

// shows that the key combination is undefined in the upper left corner of the screen ----Preset not set!

Note: the meaning of the echo command is to display the information you defined in the upper left corner of the screen

alias preset6 ""developer 1; echo Preset not set! ; developer ""

alias preset7 ""developer 1; echo Preset not set! ; developer ""

alias preset8 ""developer 1; echo Preset not set! ; developer ""

alias preset9 ""developer 1; echo Preset not set! ; developer ""

alias preset1 ""developer 1; echo Preset not set! ; Developer ""

// same as above

alias +toggle ""bind 1 preset1; bind 2 preset2; bind 3 preset3; bind 4

preset4; bind 5 preset5; bind 6 preset6; bind 7 preset7; bind 8 preset8;

bind 9 preset9; bind preset1""

alias -toggle ""bind 1 slot1; bind 2 slot2; bind 3 slot3; bind 4 slot4; bind

5 slot5; bind 6 slot6; bind 7 slot7; bind 8 slot8; bind 9 slot9; Bind

slot ""

Bindalt ""+Toggle ""

The last three lines of this script are the key points, which means that when alt and a numeric key are pressed, the gun purchase instruction set defined in the first half of the script is executed, while when Alt is released, the numeric key is restored to its original function, that is, switching guns, which is the meaning of Meta

binds.

its function is also obvious: it can save a lot of keys and define more instruction sets on common keys.

Toggles

Toggles (switches) are the most typical examples of switching searchlights and night vision devices. Let's make a Toggle of netgraph (status display, such as FPS) to get familiar with and study

Example:

alias Ngon ""Developer 1; echo Net Graph on; developer ; net_graph 3; bind n

ngoff""

alias ngoff ""developer 1; echo Net Graph off; developer ; net_graph ; Bind

n ngon ""

bind n ""ngon ""

The function of this script is to switch netgraph with the N key, and pay attention to the characteristics of Toggle, which actually forms a kind of cycling, but this script is obviously not satisfactory, because it cannot be added to the keyboard setting menu. The key was bind twice. How to solve this problem? Just make a slight change.

Toggles(complex)

is the improved Toggles, which has the advantage that only one key position needs to be set, and the netgraph switch is still taken as an example

example:

alias ngon ""developer1; echo Net Graph on; developer ; net_graph 3; alias

ng ngoff""

alias ngoff ""developer 1; echo Net Graph off; developer ; net_graph ;

alias ng ngon ""

alias ng ""ngon ""

bind n ""ng ""

As you can see, the tails of the two macros are changed from the original bind to alias, and the keys are defined separately in the third line, which is very clever, isn't it? Hoho~~

Now we can directly define the key in the keyboard settings bar. More importantly, after understanding this skill, we can go to the next lesson-Cycle aliases

The toggle in front is only a choice of two situations, that is, on and off. What should we do when we are faced with more choices? This requires Cycle

aliases, or look at the example of netgraph, but this time, we need to use the N key to select different display forms of netgraph.

Example:

alias NG1 ""Developer 1; echo Net Graph on, setting 1; developer ; net_graph

1; alias ng ng2""

alias ng2 ""developer 1; echo Net Graph on, setting 2; developer ; net_graph

2; alias ng ng3""

alias ng3 ""developer 1; echo Net Graph on, setting 3; developer ; net_graph

3; alias ng ng4""

alias ng4 ""developer 1; echo Net Graph off; developer ; net_graph ; Alias

ng ng1 ""

alias ng ""ng1 ""

bind n ""ng ""

We can see that the key is defined to the next macro at the end of each line. This forms a cycle.

Make your own key setting menu

In the previous chapter, we mentioned adding your own options to the key setting menu

This is what we will explain in detail in the last section

Open the gfx folder in your half-lifecstrike directory and open the kb_act.lst file in it with WordPad. You can see something like this:

""Buy Ammo 1 """Buy Primary Ammo (optional)" "

" "Buy Ammo 2" ""Buy Secondary Ammo (optional) ""

""Buy Equipment """.