Sie sind auf Seite 1von 3

Here's a quick tutorial on how to do some scripting for CoD. If it would be bett er as a video, I can do that as well.

Note: you need to have some programming kn owledge to understand most of this! Intro CoDScript is basically a scaled-down version of C. If you know C/C++/Java/PHP yo u'll be able to learn this language. It's very simple. There are some major diff erences between these languages and CoDScript though! Variables For variables, you don't have to initialize them. Ever. Take this code for examp le: [C] int variable = 1; printf( "%d", variable ); [GSC] variable = 1; iPrintLn( variable ); Because you don't have to initialize the variable and define what type it's goin g to be, you can have variables that can change types all the time. [C] // would cause compiler errors int variable = 1; variable = "a string"; variable = 1.46899; // works variable variable variable just fine = 1; = "a string"; = 1.46899;

Never having to initialize variables is nice in a way, but also can be bad if yo u have a variable that is SUPPOSED to be an int, but really is a string.

There are MANY types of variables in CoDScript. All the standard C ones apply, w ith the addition of CoD-specific variables. [C] int float double char

1 3.14159 1.22 'c'

[GSC] bool string localized string entity struct vector

true/false "text" &"text" players, models structures of data like in C, except as types (1, 2, 3) x,y,z

Unlike C, you don't have to create functions with return types. [C] int main(); void coolFunction(); float getMahFloat(); [GSC] main(); coolFunction(); getMahFloat(); As with variables, you don't have to specify types in the parameters either. [C] char* getName( entity_t ent ) { // code } [GSC] getName( ent ) { // code }

[b]Other notes[/b] CoDScript does [b]NOT[/b] support any pre-processor directives (those that start with #)! So, you cannot include any files or really make any 'C'-style global d efines. Instead, you would do things like this: [C] // including function/calling it #include <stdio.h> printf( "Cool stuff!" ); [GSC] // calling a function in another file - file is _coolfile.gsc in the maps\ folde r maps\_coolfile::printf( "this" ); [[ variable ]]( "this" );

To set global variables, you can use the 'level' variable. [C] // old C-Style #define VAR 1 // CoD level.var = 1; In the same way, you can actually make 'level' variables contain links to functi ons in other files! level.coolFunction = maps\_utility::loadThisAndThat; // somewhere else in another file [[ level.coolFunction ]]();

Closing So now you know a bit more about how to script for CoD! Check out the [url=http: //www.zeroy.com/Script]script reference[/url] to see all the built-in functions available (this is a CoD4 reference, although most of the functions work in CoD1 ). Stay tuned for some more tutorials on CoDScripting.[/quote]

Das könnte Ihnen auch gefallen