atrX

Owner
  • Content count

    448
  • Joined

  • Last visited

  • Days Won

    385

Everything posted by atrX

  1. Or you can just rig it yourself?
  2. I'll get these sorted out later. Docs aren't meant to be mobile optimised otherwise I would've made them with that in mind, you really don't have any use for them on mobile.
  3. Fixed. Can you next time please indicate which part of the screenshot you're referring to so I don't have to guess if I missed anything? Thank you.
  4. All issues mentioned have been fixed.
  5. Also just realised I didn't change the spoilers' styling either. I'll get these things sorted tonight.
  6. What's wrong in the second screenshot?
  7. Get me the xanims and I'll get you emotes.
  8. I'm not exactly contributing much myself right now, BO3 mod tools got me hooked. Once Promod goes up we'll see if that brings in some players. Other than that, I'm clueless. I was mostly expecting some people to join and then tell their friends and get the server populated that way, didn't really work out it seems. We had a good first 2 months and then it died out. Some YouTube publicity would be ideal I suppose but it'd probably be hard to get the server full enough to have anyone record a proper video.
  9. Your application is now available to be voted on. PS: I'm just stating this here so I have some place that I can say I officially said this: This is the last app I'm giving a pass for having less than 50 hours played on the new servers as it complicates things for us.
  10. Everything starts with the basic requirements, so does scripting. In this tutorial we will go over the basics you'll need to start scripting. Picking an Editor Unless you're nuts and want to use Notepad, you'll need a good editor which doesn't make your eyes bleed after using it for 15 minutes. My personal pick for the best editor goes out to Visual Studio Code. It has a built-in extension and theming system with a database of several thousand extensions and hundreds of themes to pick from that can all be installed from within your editor. There are of course alternatives. The king of speed is still Sublime Text 3, Atom is insanely modular and even good old Notepad++ isn't completely terrible (I hate you if you actually use this for any sort of programming work). You can use whatever suits your needs. None of these editors were purpose built for GSC though (if anyone knows any that are, link me so I can chuckle), so we'll have to rely on extensions/plugins/whatever your editor calls it to support our lovely little language. This tutorial does assume you'll be using Visual Studio Code throughout and any extensions linked are only compatible with this specific editor. Installing Extensions I'm not going to spend my time explaining this when there's plenty of useful resources that have already done so much better than I possibly could, so I'll just link you this article from Microsoft: https://code.visualstudio.com/docs/editor/extension-gallery Syntax Highlighting Let's get the big one out of the way first. Syntax highlighting is a MUST if you're going to be staring at code all day (unless you really like white, for some reason). The best available syntax highlighting for GSC available for VSCode right now is https://marketplace.visualstudio.com/items?itemName=atrX.vscode-codscript, so go ahead and install it. It should automatically start associating any .gsc file opened in VS Code with the GSC syntax provided by the extension. I'll update this tutorial if I ever get off my lazy ass and make my own fork of this extension with proper function name casing and other improvements. Themes If you are like me, you might want to change the way VS Code looks by installing a theme. You can find many great themes by browsing the VS Code Marketplace or by Googling for a top-X list. My current favourite is one I actually made myself: Zephyr. It was originally purpose made for Web Development (HTML, CSS, JavaScript being the main focus languages) but it works quite well with GSC as well. Some other great themes include One Dark Pro, Material Theme, Darcula, Monokai (there's like a billion different versions so if you want that go find one you like). Additionally, you can also install an icon pack like Material Icon Theme. Extensions I've also installed a bunch of additional extensions (though, most weren't for CoD) which help me work faster and more efficiently. Here's the ones I'd recommend if you're going to be using this solely for CoD: Rainbow CSV: Because editing CSV files is a pain in the ass. TODO Highlight: Highlights TODOs and FIXMEs in your comments. Todo Tree: View a list of all your TODOs and FIXMEs spread across your project. EditorConfig for VS Code: If you're going to be working with a team and want consistency in the way you format code.
  11. Getting Started Prerequisites Scripting Basics Syntax Data Types Arithmetic Operators Relational & Logic Operators Variable Scope Arrays Threading Arguments Selection (If-Else) Selection (Switch Statement) While Loop, For Loop and Infinite Loops Break, Continue and Return Notify, Waittill and Endon "Self" General Scripting Triggers Dvars Moving Entities Rotating Entities Effects HUD Elements Useful Resources Raid Gaming Scripting API (Stock CoD4/WaW functions, CoD4U + Surf Mod functions) Personal note: I brought these back since people were asking for them. They're mostly an exact copy of a 2015 tutorial series I did. There may be some wrong information and there's definitely a lot of missing information but I feel like these are still your best place to start when it comes to tutorials (though, my preferred method is still studying source code). I updated the Prerequisites one mainly due to the fact that for some reason I love talking about editors, other than that, yeah, I probably won't update these any time soon.
  12. Basic Movement Functions These are the basic functions used to move an entity often used: <entity> moveX(<point>, <time>, <acceleration time>, <deceleration time>); <entity> moveY(<point>, <time>, <acceleration time>, <deceleration time>); <entity> moveZ(<point>, <time>, <acceleration time>, <deceleration time>); /* point: The amount of units to move the entity time: Time to move the entity in seconds acceleration time: Time spent accelerating in seconds deceleration time: Time spent decelerating in seconds */ // Examples: ent moveX(256, 5); ent moveY(64, 1, .2, .2); ent moveZ(128, 3, .5); What does X, Y and Z stand for? X, Y and Z correspond with the axises in Radiant, meaning: X is the horizontal axis (left to right increases X-value, right to left decreases X-value). Y is the vertical axis (bottom to top increases Y-value, top to bottom decreases Y-value). Z is the height (low to high increases Z-value, high to low decreases Z-value). More? There's 2 more handy functions to move entities, one of which is not really common (moveGravity()) but still good to know about: <entity> moveGravity(<initial velocity>, <time>); /* initial velocity: Initial velocity to fling the entity at time: Time to move the entity in seconds */ // Example: ent moveGravity((0, 60, 90), 5); <entity> moveTo(<point>, <time>, <acceleration time>, <deceleration time>); /* point: Coördinates to move the entity to time: Time taken to move the entity in seconds acceleration time: Time spent accelerating in seconds deceleration time: Time spent decelerating in seconds */ // Example: place = getEnt("move_ent_here", "targetname"); ent moveTo(place.origin, 10, .5, .5); Waiting for movement to finish When an entity finishes moving a notify is sent named "movedone", this can be used to make a function wait for movement to finish. ent moveTo((0, 0, 0), 10); ent waittill("movedone"); // Function will now wait untill "ent" receives the notify "movedone" // Continue code after notify has been received More on notify and waittill:
  13. Basic Rotation Functions These are the basic functions to rotate an entity often used: <entity> rotatePitch(<pitch angle>, <time>, <acceleration time>, <deceleration time>); <entity> rotateRoll(<roll angle>, <time>, <acceleration time>, <deceleration time>); <entity> rotateYaw(<yaw angle>, <time>, <acceleration time>, <deceleration time>); /* angle: amount of degrees to rotate the entity time: amount of time in seconds it takes for the rotation to complete acceleration time: time spent accelerating in seconds (optional) deceleration time: time spent decelerating in seconds (optional) */ // Examples: ent rotatePitch(360, 1, .5, .5); ent rotateRoll(180, 5); ent rotateYaw(360, 3, .5); Bear in mind that when working with rotations pitch, roll and yaw depend on the entity's orientation on the x, y and z axis. Here's a picture that will help you in finding the function you'll need: More? There's 2 more handy functions to rotate entities but they're not as common as the ones previously mentioned: <entity> rotateTo(<angles>, <time>, <acceleration time>, <deceleration time>); /* angles: new world angle to rotate to time: amount of time in seconds it takes for the rotation to complete acceleration time: time spent accelerating in seconds (optional) deceleration time: time spent decelerating in seconds (optional) */ // Example: ent rotateTo(getEnt("angles_origin", "targetname").angles, 5); // Note: rotateTo() always rotates to the angles defined in the fastest way possible. <entity> rotateVelocity(<rotate velocity>, <time>, <acceleration time>, <deceleration time>); /* velocity: rotational velocity to rotate (vector3, meaning x, y, z) time: amount of time in seconds it takes for the rotation to complete acceleration time: time spent accelerating in seconds (optional) deceleration time: time spent decelerating in seconds (optional) */ // Example: ent rotateVelocity((0, 180, 270), 2, .5, .5); Waiting for a rotation to finish When an entity finishes rotating a notify is sent named "rotatedone", this can be used to make a function wait for a rotation to finish. ent rotateYaw(360, 1); ent waittill("rotatedone"); More on notify and waittill:
  14. Creating a HUD element hud = newClientHudElem(client); // Create a HUD element for 1 client (player) hud = newHudElem(); // Create a global HUD element (seen by all players) Destroying a HUD element hud destroy(); Resetting a HUD element to its default state hud reset(); Modifying a HUD element // Positioning hud.x = x; // Set the X coördinate of the HUD element on the screen hud.y = y; // Set the Y coördinate of the HUD element on the screen hud.alignX = "left"; // Align the HUD element along the X coördinate (left, center, right) hud.alignY = "middle"; // Align the HUD element along the Y coördinate (top, middle, bottom) hud.horzAlign = "center"; // Align the HUD element horizontally (left, center, right) hud.vertAlign = "middle"; // Align the HUD element vertically (top, middle, bottom) // Visibility hud.foreground = true; // Set the HUD element to be on the foreground hud.hidewheninmenu = false; // Hide the HUD element when in a menu hud.sort = 1; // Arrange HUD element // Font hud.font = "objective"; // Set the font of the HUD element hud.fontScale = 1.3; // Scale the font of the HUD element hud.alpha = 1; // Set the opacity of the HUD element, ranges from 0 to 1 (0 = transparent, 1 = visible) hud.color = (r, g, b, a); // Change the colour of the HUD element (r: red, g: green, b: blue, a: alpha) // Functions hud setText(<string>); // Make the HUD element display text hud setTimer(<time>); // Make the HUD element count down (time = float) hud setTimerUp(<time>); // Make the HUD element count up (time = float) hud setShader(<materialname>, <width>, <height>); // Make the HUD element display a shader (width and height are optional) hud setValue(<value>); // Set the value of a HUD element (value = string) If that's not enough for you, then here's the FULL list of every HUD element attribute with their respective data type (some appear to be missing from this list, but they've been mentionned before, also, some may not work in CoD4 and WaW): // List courtesy of: http://codresearch.com/index.php/Hud_Elements float x float y float z int targetEntNum float fontScale float fromFontScale float fontScaleStartTime float fontScaleTime int font int alignOrg int alignScreen hudelem_color_t color hudelem_color_t fromColor int fadeStartTime int fadeTime int label int width int height int materialIndex int offscreenMaterialIdx int fromWidth int fromHeight int scaleStartTime int scaleTime float fromX float fromY int fromAlignOrg int fromAlignScreen int moveStartTime int moveTime int time int duration float value int text float sort hudelem_color_t glowColor int fxBirthTime int fxLetterTime int fxDecayStartTime int fxDecayDuration int soundID int flags /* hudelem_color_t attribute declaration: (r,g,b,a) r: red g: green b: blue a: alpha */ Additional HUD functions There's a couple functions I've not covered here, got to any scripting reference for CoD and you'll find all functions available (eg: http://zeroy.com/script/).
  15. Loading/Precaching FX Fx have to be precached before you're able to use them, precaching is done using the following function: loadFx(<filename>); // filename = path to .efx file (without extension) starting in raw/fx // Example: explFx = loadFx("explosions/large_vehicle_explosion"); Playing an Effect playFx When to use? General playing of an effect. playFx(<effect id>, <position of effect>, <forward vector>, <up vector>); /* effect id: effect id returned by loadFx() position of effect: world position of the effect forward vector: forward vector of the effect (optional) up vector: up vector of the effect (optional) */ // Example: fx = loadFx("explosions/large_vehicle_explosion"); org = getEnt("play_fx_here", "targetname"); playFx(fx, org.origin); playFxOnTag When to use? Playing an effect on tags of an entity, moving effects, deleting effects, ... playFxOnTag(<effect id>, <entity>, <tag name>); /* effect id: effect id returned by loadFx() entity: entity to attach the effect to tag name: name of the tag to attach the effect to */ // Example: fx = loadFx("explosions/large_vehicle_explosion"); ent = getEnt("play_fx_here", "targetname"); tag = spawn("script_model", ent.origin); tag setModel("tag_origin"); tag linkTo(ent); playFxOnTag(fx, ent, "tag_origin"); playLoopedFx When to use? Playing a one-shot effect in a loop. playLoopedFx(<effect id>, <repeat delay>, <position>, <cull distance>, <forward>, <up>); /* effect id: effect id returned by loadFx() repeat delay: the delay between each loop position of effect: world position of the effect cull distance: the culling distance of the effect, 0 means the effect won't be culled (optional) forward: forward vector of the effect (optional) up: up vector of the effect (optional) */ // Example: fx = loadFx("explosions/large_vehicle_explosion"); org = getEnt("play_fx_here", "targetname"); playLoopedFx(fx, 1, org.origin);
  16. Server Dvars Server dvars (or host dvars) are a kind of variable accessible through console (though, cheat protected). You can both modify and request the value of a server dvar through script. Saved Dvars Saved dvars are saved in the save game and are reset to default on level change. Saved dvar functions only work on dvars that have the 'SAVED' parameter set. Client Dvars Client dvars are, as the name suggest, client side dvars. Using GSC, these can only be adjusted, not retrieved. There is however a few workarounds which I might cover in later tutorials. Client dvars are always accessible through CSC (clientscript), which, again, might be covered later on in another tutorial. Functions getDvar( <dvar> ); Usage: Get the value of a dvar as a string. This can only fetch server/host dvars, not client dvars. Client dvars can be fetched through clientscript using getDvar(). Arguments: <dvar>: The dvar name as a string. Example: if (getDvar("debug_skipintro" == "on")) { // Code } setDvar( <dvar>, <value> ); Usage: Set the value of a dvar. If the 'development' dvar is set then any dvar can be set, otherwise only external dvars (dvars that are not set through code) can be set. This will only work for server dvars. Arguments: <dvar>: The dvar name as a string. <value>: The new dvar value. Example: setDvar("r_eyesAdjust", "1"); getDvarInt( <dvar> ); Usage: Gets the value of a dvar as an integer. Arguments: <dvar>: The dvar name as a string. Example: level.fogtype = getDvarInt("scr_fog_type"); getDvarFloat( <dvar> ); Usage: Gets the value of a dvar as a float. Arguments: <dvar>: The dvar name as a string. Example: oldDelay = getDvarFloat("effect_delay"); setSavedDvar( <dvar>, <value> ); Usage: Sets the value of a dvar. Saved dvars are saved in the save game and are reset to default on level change. Only works on dvars that have the 'SAVED' parameter set. Arguments: <dvar>: The dvar name as a string. <value>: The new dvar value. Example: setSavedDvar("r_eyesAdjust", "1"); setClientDvar( <dvar>, <value> ); Usage: Sets the value of a client dvar. Arguments: <dvar>: The dvar name as a string. <value>: The new dvar value. Example: self setClientDvar("cg_drawhud", "0"); setClientDvars( <dvar>, <value>, <dvar>, <value>, ... ); Usage: Sets the value of a list of client dvars. Arguments: <dvar>: The dvar name as a string. <value>: The new dvar value. Note: You can have as many of these as you'd like. Example: self setClientDvars("cg_drawhud", "0", "cg_draw2d", "0");
  17. Types of triggers There's a couple different types of triggers: trigger_use: Activates when a player presses the "use" button on it. trigger_use_touch: Activates when a player presses the "use" button when touching it. trigger_radius: Activates when a player (and/or AI, depending on how it's set up) is in its radius. trigger_multiple: Activates when a player (and/or AI, depending on how it's set up) is touching it. trigger_damage: Activates when it gets damaged. trigger_hurt: Activates when a player (and/or AI, depending on how it's set up) is touching it, will deal trigger_hurt.dmg amount of damage to the entity touching it. trigger_lookat: Activates when a player is looking at it. There's some more trigger types which you most likely will never use and I will therefore not mention them. Basic trigger setup trigger = getEnt("trigger", "targetname"); trigger setCursorHint("HINT_NOICON"); // Disables the "hand" icon trigger setHintString("Press &&1 to be cool"); // Sets a hintstring for the trigger // Makes the function wait for the notify "trigger" to be sent // "player" is an optional argument incase you need to put the activator of the trigger in a variable trigger waittill("trigger", player); trigger delete(); // Delete the trigger player iPrintln("You're cool!"); // Utilises the "player" variable set by trigger waittill( "trigger", player ); Trigger more than once This can be done with a simple loop: trigger = getEnt("trigger", player); trigger setCursorHint("HINT_NOICON"); trigger setHintString("Press &&1 to be cool"); for (;;) { trigger waittill("trigger"); iPrintlnBold("triggered"); } Enabling/disabling triggers These functions differ for solo and multiplayer, they're also included in different utility scripts. Solo: Includes required: #include common_scripts\utility; Implementation: trigger trigger_off(); // Disable trigger trigger trigger_on(); // Enable trigger trigger_off("trigger", "targetname"); // Disable all triggers with the targetname trigger trigger_on("trigger", "targetname"); // Enable all triggers with the targetname trigger Multiplayer: Includes required: #include maps\mp\_utility; Implementation: trigger triggerOff(); // Disables trigger trigger triggerOn(); // Enables trigger Spawning triggers in manually spawnTrigger() { location = getEnt("trigger_location", "targetname"); // spawn(<classname>, <origin>, <flags>, <radius>, <height>); trigger = spawn("trigger_radius", location.origin, 60, 60, 60); trigger = setHintString("Press &&1 for M40A3"); while (isDefined(trigger)) { players = getEntArray("player", "classname"); for (i = 0; i < players.size; i++) { if (players[i] useButtonPressed() && players[i] isTouching(trig)) { players[i] giveWeapon("m40a3_mp"); players[i] giveMaxAmmo("m40a3_mp"); players[i] switchToWeapon("m40a3_mp"); trigger delete(); } } wait .05; } }
  18. Data Types Unlike most programming languages, CoDScript does not require you to specify a data type for a variable, it is however helpful to know what each data type used by CoDScript is: String: Sequence of characters Integer (int): Whole number (ex: -2, -1, 0, 1, 2, ...) Floating point number (float): Rational number (ex: 3.14, 1.337, ...) Boolean (bool): True or false Array: Collection of variables, new elements can be inserted at any given time Vector3: Can be compared to an array with a size of 3, in GSC it acts basically identically to an array except that you shouldn't insert new values, only edit the 3 existing ones
  19. What is "self"? The "self" you keep seeing in scripts refers to the entity the function is called on, let's have a look at an example: main() { trigger = getEnt("trigger", "targetname"); trigger thread doStuffWithTrigger(); } doStuffWithTrigger() { self setCursorHint("HINT_NOICON"); self setHintString("Press &&1 for something to happen"); self waittill("trigger", player); self delete(); player Suicide(); } And how is this utilised for "level"? I've gotten a question about what calling a function on "level" does, well, it does the exact same as it does with any other entity you call a function on: main() { level thread doStuff(); } doStuff() { for (self.var = 0; ; self.var++) { iPrintln(self.var + " seconds passed"); self notify("second_passed"); // Just some example stuff, would be a pointless notify to have wait 1; } } What is the difference between "self" and "player"? There's actually an extremely big difference between them, "self" is used to refer to the entity a function is called on. "Player", however, is a variable defined in your script: function() { trig = getEnt("trigger", "targetname"); trig waittill("trigger", player); // "player" is now defined as the player entity that hit the trigger player thread doStuff(); // calling doStuff() on "player" } doStuff() { // "player" is refered to as "self" from now on self iPrintlnBold("Haha"); self suicide(); }
  20. Notify, waittill and endon, what exactly does it do? Waittill is a function used to make the script wait for a notification (sent by notify), waittill can be called on entities and the level. Notify sends a notification to either an entity or the level. Endon will end a function as soon as it recieves a notification specified in the endon function. How to use notify, waittill and endon? Let's take a look at this example: function() { trig = getEnt("trigger", "targetname"); trig setCursorHint("HINT_NOICON"); trig setHintString("Press &&1 to send a notify"); trig waittill("trigger", player); // The function will pause untill the entity "trig" recieves the notify "trigger" player thread doStuff(); player thread onDeath(); player waittill("death"); player notify("example"); } doStuff() { self endon("death"); // Function will end when the player dies self endon("disconnect"); // Function will end when the player disconnects for (; ; wait( .05 )) self iPrintlnBold("Player has not yet died or disconnected"); } onDeath() { self waittill("example"); // Function will wait until the player recieves the notify "example" self iPrintlnBold("You died..."); }
  21. Arguments Arguments are variables initialised by passing data to a function like this: main() { myFunction(1); } myFunction(argument) { iPrintln(argument); // This will print out "1" } You can also pass variables as an argument: main() { var = 1; myFunction(var); } myFunction(argument) { // At this point argument is equal to the value passed to it iPrintln(argument); // This will print out "1" } You can have as many arguments as you want, just bear in mind to give them a decent name, so not like this: function(arg1, arg2, arg3, arg4, arg5) { // Now what did these arguments stand for again? Hmm... } Naming arguments is incredibly important in maintaining structure in your scripts as these are the names you'll be using throughout your scripts!
  22. What is a variable scope? The scope of a variable is essentially the part of your code in which this variable is accessible. If a variable is used outside of its scope an error will be thrown by the game: "Uninitialized variable VARNAME". Let's have a look at this basic example: function() { // Code var = true; // START OF SCOPE FOR VARIABLE "var" if (var) { // Do something } // Code // END OF SCOPE FOR VARIABLE "var" } Global or level variables A global (also known as level) variable can be accessed in any function and in any gsc file from the moment it is initialised: function() { // Code level.var = true; // START OF SCOPE FOR LEVEL VARIABLE "var" if (level.var) { // Do something } // Code // SCOPE OF LEVEL VARIABLE "var" DOES NOT END HERE } Entity variables You can also declare a variable for an entity, the scope for an entity variable is essentially the same as a level variable, except that it is only accessible by that specific entity it is assigned to: function() { trigger = getEnt("trigger", "targetname"); trigger.activated = false; // START OF SCOPE FOR ENTITY VARIABLE "activated" trigger setCursorHint("HINT_NOICON"); trigger setHintString("Press &&1 for candy"); trigger waittill("trigger", player); trigger.activated = true; // SCOPE OF ENTITY VARIABLE "activated" DOES NOT END HERE } Scope of the for loop's declaration/initialisation As seen in the tutorial about for loops, you can declare and initialize a variable in the first part of it. The scope of a variable initialized in a for loop's initialization ends from the moment the for loop ends: function() { // Code for (var = 0; var < 100; var++) { // Do something } // END OF SCOPE FOR VARIABLE "var" // Code }
  23. Break Break is used to exit the current statement, you'll see this often used in loops and switch statements. Here's an example: for (; ; wait(1)) { if (stopLoop == true) break; // Do something } As soon as stopLoop is set to true the loop will stop and the function will start executing the code after the loop. Continue Continue is used to exit the current instance of a loop, let's have a look at an example: for (; ; wait(1)) { if (doContinue == true) continue; // This code will NOT be executed if doContinue is true } If doContinue is true, the current instance of this infinite loop will end and it'll start a new one from the top. Return Return is used to exit the current function and optionally return a value. main() { var = function(); // Waits for function() to finish and will set "var" to the returned value of function() } function() { // Code return 0; // "var" will be set to 0 and the game will exit the function function() }
  24. What is a Switch Statement? A switch statement selects a switch section to execute from a list of candidates (cases). Here's a simple example of a switch statement with 3 switch sections: var = 1; switch (var) { case 1: iPrintln("1"); break; case 2: iPrintln("2"); break; default: iPrintln("Default"); } In this example, 1 will be printed on the screen. Note that there is no break in the default switch section, it is not required to add a break to the default switch statement. But why is it required to have a break in the other switch sections then? Because the default switch section will ALWAYS be executed UNLESS you break the switch statement, and we don't want "Default" popping up on our screen if var is equal to 1. Multiple conditions per candidate Let's have a look at an example first: switch (var) { case 1: case 2: iPrintln("1 or 2"); case 3: case 4: iPrintln("3 or 4"); } There's a couple things about this switch statement that are different compared to our first example. One of these differences is that there are multiple conditions per candidate, it's pretty straight forward how this works, I don't think any further explanation is needed. But you said breaking a switch statement was required? Yes, I did, but breaking a switch statement is only required if you have a default case, in the above example there is none, meaning we don't have to worry about that being executed.
  25. What is an if-else selection? The if-else statement identifies which statement to run based on a boolean expression. In the following example, var will be set to 1 as condition is set to true: condition = true; if (condition) { var = 1; } else { var = 0; } If ladders You can string tons of if statements together to make an if ladder: var = randomInt(10); if (var < 2) { // Do something } else if (var < 5) { // Do something } else if (var < 8) { // Do something } else { // Do something }