Call of duty script
If(variable1 != variable2) //If variable1 is not equal to variable2 If(variable1 = variable2) //If variable1 is equal to variable2 Here are some examples.notice the lack of semicolons at the end of the statements. Ok, now that we have some operators, lets get started on the statement.Īn 'if' statement, requires a minimum of one arguement and usually one operator. To understand this section, you must first know the operators used to compare data:
#Call of duty script how to
This section will go into a little more detail of how to use 'if' statements and loops.Īn 'if' statement is used to verify whether some data satisfies certain conditions, and then to execute code depending on the outcome. There are also some more little-known operators such as. There are several operators that can be used in maths.
#Call of duty script plus
VarAnswer will be equal to the value of var1 plus the value of var2. Maths is used throughout scripting to get many different values, be it the distance between two objects or to calculate an equation.įor example, a variable can be given data from an equation.Īlthough the above example is pretty pointless, as it adds one constant to another to make a constant, and you can just calculate it yourself and use the answer i.e.īut variables can be calculated using other variables, for example. Or they can be assigned to entities individuallyįor things like player.health (integer, already built-in, but can be modified) and level.teamBased (boolean). Variables can be global (which can be used in all threads without needing to be called) by using the This variable can be used in the current function and any function that passes it as an argument, or is called on it (so it'd be used as 'self'). Variables come in different forms: integers, floats, entities, strings, arrays and booleans, there are also several different ways variables can be stored.Ī simple variable is simply declared using Variables can be used in several ways, but in all cases they are used to store some data for the duration of the game. Self: If you call a function on an entity e.g 'unnamedent thread dostuff()', then within the function dostuff(), you can refer to unnamedent as 'self'. Thread function() //this will start function() and carry on to execute 'ent moveZ' Examples.įunction() //the script will stop at this line and carry out function() before going down to. If a function is threaded, then that function is performed while the script continues, whereas if a function is called sequentially, the script waits until the function is completed before it continues. Functions can be threaded or called sequentially. Then moveZ is called on the entities.Ĭalling/Threading: these are used with functions. An example of this in use.Īs you can see, function() is called on both 'ent' and 'thing', and the two arguments '320' and '5' are passed to the new function as 'distance' and 'time'. The function is asking for two arguements to be sent to the function. The function that was passed the arguments can then reference them. There is also another function, moveY, which is a built-in function inside COD4, and moves an entity on the Y axis.Īrguements: These are key piece of information that are passed along to functions, and can be any type of object (entity, string, boolean etc).
The main function in the above code is funcMove(), and it will perform the actions inside the curly braces when it runs. They can be referenced using their their targetname or classname that has been set within the map.įunctions: an action or procedure that can be called or threaded and can return a value. Entities include players, dropped guns, objectives, script_models, etc. The variables are declared on the left, and assigned a value such as an integer (whole number), a float (a number containing a decimal), a string (text and symbols) or a boolean (true/false).Įntities: These are objects that are used in maps, and can be referenced in the script. Stringthing = "Text and symbols 1234567890" īooleanthing = true //another thing, almost every line must have a at the end or the script won't work. Integerthing = 1 //by the way, comments like this can be made using //, and are ignored by the game. Variables: variables are data storage locations which are assigned a name. It is recommended you use a simple but effective editor for programming, such programs include Crimson Editor, Programmers Notepad and Editplus.Ī few things you need to know before reading any further are a few common words used within scripting.
#Call of duty script series
The file format used for scripts within the Call of Duty series is 'GSC' (.gsc). This section will include several things you need to know before you start scripting.Īll scripts are contained within simple text files that contain no formatting, so programs such as Word are not to be used.