Close



Keep me logged in.

Forgot your password? | Register Now

Results 1 to 7 of 7
  1. Original Post
    So 1337
    NextGenUpdate Elite Member
    Panda-monium's Avatar

    Default Cod 5 (W@W) : Scripting Basics! Part 1.




    Ok NgU,
    this is my own guide for scripting, it is incomplete and lacks a lot of formatting (I will try and get round to that soon). It was written in 2.5 hours and contains a lot of basic and slightly advanced guides on several base topics. Some areas contain more detail than others depending on relevance and difficulty.
    When I get more time, I will add to this guide. Once I have pretty much finished the majority of the guide I will provide several new scripts using several advanced functions.
    This guide should be used as a small starting guide for people new to scripting, and reference for those who know some scripting. This will provide an insight into how script can improve the fun of maps, and hopefully will help answer questions for those who are stuck.
    If you find any problems (be it wrong syntax, spelling or etc) then post. If you want to request/criticise/compliment or whatever, again post.

    Getting Started

    All scripts are contained within simple text files that contain no formatting, so programs such as Word are not to be used. The file format used for scripts within the Call of Duty series is 'GSC' (.gsc). It is recommended you use a simple but effective editor for programming, such programs include Crimson Editor, Programmers Notepad and Editplus.
    A few things you need to know before reading any further are a few common words used within scripting.
    Variables: variables are data storage locations which are assigned a name. For example...

    Code:
    integerthing = 1; //by the way, comments like this can be made using //, and are ignored by the game.
     floatthing = 0.5; 
     stringthing = "Text and symbols 1234567890";
     booleanthing = true; //another thing, almost every line must have a ; at the end or the script won't work. More on that later.
    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).
    Entities: These are objects that are used in maps, and can be referenced in the script. Entities include players, dropped guns, objectives, script_models, etc.
    They can be referenced using their their targetname or classname that has been set within the map.
    Functions: an action or procedure that can be called or threaded and can return a value. For example...:

    Code:
    funcMove()
     {
       self moveY(320, 3);
     }
    The main function in the above code is funcMove(), and it will perform the actions inside the curly braces when it runs. There is also another function, moveY, which is a built-in function inside COD4, and moves an entity on the Y axis.
    Arguements: These are key piece of information that are passed along to functions, and can be any type of object (entity, string, boolean etc). The function that was passed the arguments can then reference them.
    For example, if a function is shown as:

    Code:
     function(arg1, arg2);
    The function is asking for two arguements to be sent to the function. An example of this in use...

    Code:
    someotherstuff()
     {
       ent function(320, 5);
       thing function(320, 5);
     }
    
     function(distance, time)
     {
       ent moveZ(distance, time);
     }
    As 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'. Then moveZ is called on the entities.
    Calling/Threading: these are used with functions. Functions can be threaded or called sequentially.
    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. Examples...

    Code:
    function(); //the script will stop at this line and carry out function() before going down to...
     thread function(); //this will start function() and carry on to execute 'ent moveZ'
     ent moveZ(350, 5);
    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'.
    For example...

    Code:
    something()
     {
      ent = getent("ent","targetname");
      ent function();
     }
    
     function()
     {
      self moveZ(150, 5);
     }
    Ok , i hope you enjoy this tutorial, this is the 1st part , in the next part i will teach the Variables.


    Thankz,
    VerifyerModderz.
    Register or log in to view signatures.

  2. The Following User Says Thank You to Panda-monium For This Useful Post:

    Team Six (04-05-2012)

  3. #2
    Banned
    COD5-MAN-'s Avatar

    Default


    0 Not allowed! Not allowed!
    This will help alot of people nice one 5 star
    Register or log in to view signatures.

  4. #3
    So 1337
    NextGenUpdate Elite Member
    Panda-monium's Avatar

    Default


    0 Not allowed! Not allowed!
    Quote Originally Posted by COD5-MAN- View Post
    This will help alot of people nice one 5 star
    Thankz bro !
    Register or log in to view signatures.

  5. #4
    Former Gaming Squad Member
    IVI40A3Fusionz's Avatar

    Default


    0 Not allowed! Not allowed!
    Quote Originally Posted by Bloodfocus View Post
    Ok NgU,
    this is my own guide for scripting, it is incomplete and lacks a lot of formatting (I will try and get round to that soon). It was written in 2.5 hours and contains a lot of basic and slightly advanced guides on several base topics. Some areas contain more detail than others depending on relevance and difficulty.
    When I get more time, I will add to this guide. Once I have pretty much finished the majority of the guide I will provide several new scripts using several advanced functions.
    This guide should be used as a small starting guide for people new to scripting, and reference for those who know some scripting. This will provide an insight into how script can improve the fun of maps, and hopefully will help answer questions for those who are stuck.
    If you find any problems (be it wrong syntax, spelling or etc) then post. If you want to request/criticise/compliment or whatever, again post.

    Getting Started

    All scripts are contained within simple text files that contain no formatting, so programs such as Word are not to be used. The file format used for scripts within the Call of Duty series is 'GSC' (.gsc). It is recommended you use a simple but effective editor for programming, such programs include Crimson Editor, Programmers Notepad and Editplus.
    A few things you need to know before reading any further are a few common words used within scripting.
    Variables: variables are data storage locations which are assigned a name. For example...

    Code:
    integerthing = 1; //by the way, comments like this can be made using //, and are ignored by the game.
     floatthing = 0.5; 
     stringthing = "Text and symbols 1234567890";
     booleanthing = true; //another thing, almost every line must have a ; at the end or the script won't work. More on that later.
    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).
    Entities: These are objects that are used in maps, and can be referenced in the script. Entities include players, dropped guns, objectives, script_models, etc.
    They can be referenced using their their targetname or classname that has been set within the map.
    Functions: an action or procedure that can be called or threaded and can return a value. For example...:

    Code:
    funcMove()
     {
       self moveY(320, 3);
     }
    The main function in the above code is funcMove(), and it will perform the actions inside the curly braces when it runs. There is also another function, moveY, which is a built-in function inside COD4, and moves an entity on the Y axis.
    Arguements: These are key piece of information that are passed along to functions, and can be any type of object (entity, string, boolean etc). The function that was passed the arguments can then reference them.
    For example, if a function is shown as:

    Code:
     function(arg1, arg2);
    The function is asking for two arguements to be sent to the function. An example of this in use...

    Code:
    someotherstuff()
     {
       ent function(320, 5);
       thing function(320, 5);
     }
    
     function(distance, time)
     {
       ent moveZ(distance, time);
     }
    As 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'. Then moveZ is called on the entities.
    Calling/Threading: these are used with functions. Functions can be threaded or called sequentially.
    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. Examples...

    Code:
    function(); //the script will stop at this line and carry out function() before going down to...
     thread function(); //this will start function() and carry on to execute 'ent moveZ'
     ent moveZ(350, 5);
    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'.
    For example...

    Code:
    something()
     {
      ent = getent("ent","targetname");
      ent function();
     }
    
     function()
     {
      self moveZ(150, 5);
     }
    Ok , i hope you enjoy this tutorial, this is the 1st part , in the next part i will teach the Variables.


    Thankz,
    VerifyerModderz.
    Some of this can be written more umm how could i put it, self explanatory . Good job on the basic though , you may want to considers saying how the game works and the functions, e.g Each .gsc goes starts with init() then goes to onPlayerConnect, then goes to onPlayerSpawned. Aka Program Flow.

    EDIT: For an update might want to consider mentioning the statements and loops interchanges within logic statements such as,

    Code:
    == //Means Equal To.
    > //Greater Than.
    < //Less Than.
    != //Not Equal To.
    && //And This... Used In Statements.
    || //Or This... Used In Statements.
    ++ //Up 1.
    -- //Down 1.
    There's so many more .

    And give examples and explain how each one works, e.g.

    Code:
    for(i=0;i<level.player.size;i++)
    {
    }
    This means i will start at 0 and will continue to loop using 'i++' until 'level.players.size' and has been reached...
    Last edited by IVI40A3Fusionz; 04-05-2012 at 06:21 PM.
    Register or log in to view signatures.

  6. #5
    So 1337
    NextGenUpdate Elite Member
    Panda-monium's Avatar

    Default


    0 Not allowed! Not allowed!
    thankz for that
    Register or log in to view signatures.

  7. #6
    Banned

    Default


    0 Not allowed! Not allowed!
    Thanks bro
    Register or log in to view signatures.

  8. #7
    So 1337
    NextGenUpdate Elite Member
    Panda-monium's Avatar

    Default


    0 Not allowed! Not allowed!
    You are welcome i !!!1
    Register or log in to view signatures.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •