Login Issues
Forgot password?Activate Issues
Account activation email not received? Wrong account activation email used?Other Problems?
Contact Support - Help Center Get help on the UGX Discord. Join it now!watermelons = [];and then adding the respective elements to the arrays like this:
melon_0 = GetEnt("watelon","targetname");OR
watermelons[0] = melon_0;
melon_phrases = array( "green & red, big as my head","round and plump, give me some","hard yet soft, let me crunch");
watermelon_triggers = GetEntArray("melon_trigger","targetname");Don't worry about understanding all of the above just yet; just wanted to show how there are multiple correct ways to create an array and you may encounter all of these.
melon = GetEnt("watermelon", "targetname");Now I have that one model stored in the variable I called "melon". But what if I wanted to grab more than one watermelon with that targetname? GetEnt() will not work if more than one entity has the targetname it's looking for, because it doesn't know which ent you want.
melons = GetEntArray("watermelon", "targetname");this will find all entities with the targetname "watermelon" and store them in an array, which is stored in the variable "melons". Notice how I pluralized this variable as opposed to just calling it melon like the above. This is because I want to think of it as multiple entities instead of one.
melon_0 = melons[0];notice:
melon_1 = melons[1];
melon_2 = melons[2];
melons MoveZ(50, 2);but this will:
melons[0] MoveZ(50, 2);A very handy thing to know: Arrays always have a property stored on them called size, that is how big it is, or how many entities are stored inside it. You can access it like this:
amount_of_melons = melons.size;this is very neat because the size of the current array will always be what the next index value would be if another entity were to be added to it. In our example with the 3 melons, the size of the array would be 3, and the already used indexes are 0,1, and 2 - so the next value of the index would be 3, same as our size.
for(i=0; i<10; i++)Notice:
{
}
for(i=0; i<melons.size; i++)Notice:
{
melons MoveZ(50, 2);
}
melon_0 = GetEnt("watermelon_0", "targetname");
melon_0 MoveZ( 50, 2);
melon_1 = GetEnt("watermelon_1", "targetname");
melon_1 MoveZ( 50, 2);
melon_2 = GetEnt("watermelon_2", "targetname");
melon_2 MoveZ( 50, 2);
foreach(melon in melons)Notice:
{
melon MoveZ( 50, 2);
}
for(i=0; i<melons.size; i++)Because there is no variable "i" we can check with foreach loops.
{
if(i == 1)
{
IPrintLnBold("I'm a special Melon, who must be higher than the others");
melons MoveZ(70, 2);
}
else
{
melons MoveZ(50, 2);
}
}
ArrayInsert(, , );
ArrayRemoveIndex(,,[preserve_keys]);Note that using ArrayRemoveValue() will remove any of the value you put that is in the array, no matter the index, meaning it can remove more than one item from the array at once if they are the same value.
ArrayRemoveValue(,,[preserve_keys]);
melon_phrases = array( "green & red, big as my head","round and plump, give me some","hard yet soft, let me crunch");note that this will preserve the order the strings were put in, so the "green & red" phrase will be at index 0, the "round and plump" phrase will be at index 1, and the "hard yet soft" phrase will be at index 2.
foreach(phrase in melon_phrases)If I wanted to randomize the order however, I could use a handy function from array_shared.gsc (#namespace array) called randomize():
{
IPrintLnBold(phrase);
wait(4);
}
randomized_array = array::randomize( original_array );Speaking of random, what if I wanted to just use one random value from an array, instead of all of them in a random order? Since indexes are always integers, I can use:
integer = RandomInt();like this:
random_integer = RandomInt(melon_phrases.size);While RandomInt() definitely has uses outside of arrays, I feel it is important to point out as I commonly use it with arrays. It will always return a value from 0 to the number you put in minus 1, so it feels designed for putting an array's size in there, because as I have mentioned before an array's size will always be 1 more than the last used index in the array.
IPrintLnBold(melon_phrases[random_integer]);
while(condition)notice:
{
IPrintLnBold("Hello");
wait(0.05);
}
while(1)In this example, the line "Are we there yet?" will be printed to the screen every 2 seconds once this while loop is initiated, and will never stop. Just like those damn children.
{
IPrintLnBold("Are we there yet?");
wait(2);
}
times = 0;In the above case the code will run 10 times before it stops, and the code below it can begin. It should be noted that this specific example could probably be better done using a for loop, but we'll talk about that later.
while(times < 10)
{
if(times == 1)
{
IPrintLnBold(times + " minute has passed"); //account for pluralization
}
else
{
IPrintLnBold(times + " minutes have passed");
}
times ++;
wait(60);
}
steve notify("stop_eating_my_sandwich");assuming steve is an already defined variable.
door = GetEnt("specific_magical_door","targetname");notice how you can also use that level variable on notifies, waittills, and endons.
level notify("magic_door_opened", door, (0,0,50));
level notify( "end_of_round" ); //used when round endsThere are definitely more Treyarch notifies than these that you can use, you'll just have to look for them.
level notify( "start_of_round" ); //used when next round starts
level notify( "all_players_connected" ); //used when all players have connected into the game
player notify( "bled_out" ); //used when a player bleeds out, on a specific player
player notify( "player_revived" ); //used when a player is revived, on the revived player
entity notify("death"); //used when some character, such as a player or zombie, dies
entity notify("movedone"); //used when an entity is done moving after being give some sort of move command
player notify("weapon_fired", weapon); //used when a player fires a weapon. also passes the weapon entity
entity notify( "damage", amount, attacker, direction_vec, point, type, tagName, ModelName, Partname, weapon ); //used when an entity takes damage. Passes a whole bunch of useful arguments. Note that you can use this on more than just players/zombies, so long as you use the function SetCanDamage() on the entity first.
trigger notify("trigger", player); //used when a player activates a trigger. Also passes the player who activated it as an argument. VERY USEFUL
steve waittill("stop_eating_my_sandwich");waittills can also accept those useful arguments you may have passed in the notify:
IPrintLnBold("oh, sorry");
level waittill("magic_door_opened", entity, vector);but perhaps one of the most used waittills is for waiting until a use_trigger is triggered:
entity MoveTo(entity.origin + vector, 5);
trig = GetEnt("button_trig","targetname");The code above is a good example of how while loops and waittills can work together, in this case in what is known as a purchase loop.
trig SetHintString( "Press and Hold ^3[{+activate}]^7 to Press Button [Cost: 500 ]");
trig.activated = false;
while(trig.activated == false)
{
trig waittill("trigger", player);
if(player.score >= 500)
{
player zm_score::minus_to_player_score( 500 );
trig.activated = true;
}
else
{
IPrintLnBold("You need some more cash");
}
}
IPrintLnBold("Button Activated");
level endon("intermission");In the example above, I have two different endons, placed above my while loop. for the first one, the while loop will break when game ends, and the level variable is given the "intermission" notify. For the second one, if the player is given the notify "death" (which should automatically happen when a player dies), the while loop will also break.
player endon("death");
while(1)
{
if(player IsTouching(trigger))
{
player zm_score::add_to_player_score( 10 );
wait(0.95);
}
wait(0.05);
}
andrew = GetEnt("andrew","targetname");In the above example, I made a variable andrew (with some ent in radiant stored in it), and then gave it the property of "gender", which I defined as "male".
andrew.gender = "male";
andrew.clip = GetEnt("andrew_clip","targetname");We can do all the same things we can do with variables with properties. For example using in functions:
andrew.clip Delete();It's important to note if this code was executed, the entity in radiant with targetname: "andrew_clip" would be deleted, not the entity with targetname: "andrew", because the property is being sent to the Delete() function, not the actual andrew variable.
if(isdefined(andrew.gender) && andrew.gender == "male")Really the sky is limit. You can even make properties of properties:
{
IPrintLnBold("By golly, you're a man!");
}
andrew = GetEnt("andrew","targetname");It should be noted that passing a variable that has properties on it will retain all properties on it in the function it is being passed to.
andrew.clothing = "on";
andrew.clothing.top = "t_shirt";
andrew.clothing.top.color = "red";
andrew = GetEnt("andrew","targetname");
andrew.clothing = "on";
andrew.clothing.top = "t_shirt";
andrew.clothing.top.color = "red";
andrew thread clothing_appraisal();
}
function clothing_appraisal()
{
if(isdefined(self.clothing) && self.clothing == "on")
{
if(isdefined(self.clothing.top) && self.clothing.top == "t_shirt")
{
if(isdefined(self.clothing.top.color) && self.clothing.top.color == "red")
{
IPrintLnBold("I think red looks rather nice on you");
}
}
}
}
function joseph()there are other keys that also work with GetEnt, such as script_noteworthy, target, classname, or script_string. Not all keys work with GetEnt() however. But that doesn't mean we can't use our custom keys in script.
{
my_main_man = GetEnt("joseph","targetname");
}
my_main_man.gender = male;this is great for If Statements. We could use it like this:
my_main_man = GetEnt("joseph","targetname");or another common usage, storing vectors:
if(my_main_man.gender == "male")
{
IPrintLnBold("Joseph... is a man");
}
my_main_man = GetEnt("joseph","targetname");
my_main_man MoveTo( my_main_man.origin + my_main_man.script_vector, 5);
moveto(,,[acceleration time],[deceleration time]);
rotateto(,,[acceleration time],[deceleration time]);which are very commonly used.
headless_soldier = GetEnt("dead_soldier","targetname");notice I only typed in one actual targetname, "dead_soldier". The other targetname was gathered through using the target of the other entity.
joseph = GetEnt(headless_soldier.target,"targetname");
trig = GetEnt("my_trigger","targetname");See ALL Tutorials
trig waittill("trigger");
IPrintLnBold("TRIGGERD");
im_a_good_student = true;and make an if statement checking if that is indeed true:
if(im_a_good_student)notice:
{
IPrintLnBold("Good for you. What, you want a cookie or something?");
}
weapon = GetWeapon("smg_fastfire");we can take the shortcut:
this_is_a_weapon = IsWeapon(weapon);
if(this_is_a_weapon)
{
IPrintLnBold("that's a weapon alright");
}
weapon = GetWeapon("smg_fastfire");
if(IsWeapon(weapon))
{
IPrintLnBold("that's a weapon alright");
}
if(im_a_good_student)notice:
{
IPrintLnBold("Good for you. What, you want a cookie or something?");
}
else
{
IPrintLnBold("I expected better from you");
}
if(im_a_good_student)in this case first it will check if im_a_good_student is true. if it is, it will execute the code inside the first if statement, and nothing else.
{
IPrintLnBold("Good for you. What, you want a cookie or something?");
}
else if(math_is_hard)
{
IPrintLnBold("okay I'll give you that. But that's no excuse");
}
else
{
IPrintLnBold("I expected better from you");
}
if(im_a_good_student)
{
IPrintLnBold("Good for you. What, you want a cookie or something?");
}
else if(math_is_hard)
{
IPrintLnBold("okay I'll give you that. But that's no excuse");
}
else if(life_is_hard)
{
IPrintLnBold("let me play the world's tiniest violin for you");
}
else if(im_a_victim_of_circumstance)
{
IPrintLnBold("uh huh...");
}
else
{
IPrintLnBold("I expected better from you");
}
if(the_month_is_may && the_day_is_the_twenty_ninth)
{
IPrintLnBold("HAPPY BIRTHDAY!!!!");
}
if(the_month_is_may || the_day_is_the_twenty_ninth)in the above case, the first code with the and in the if statement will only get activated once a year.
{
IPrintLnBold("what? I'm not celebrating your birthday. it's 3 months away...");
}
if(you_brought_the_cake && I_brought_the_balloons && she_brought_the_drinks)
{
IPrintLnBold("what a fun party...");
}
if(you_provide_gas || you_provide_grass || you_provide_ass )See ALL Tutorials
{
IPrintLnBold("come on in");
}
my_variable = WHAT_IM_SETTING_IT_TO;and in this tutorial I'm gonna go over the various things we can set it to and how we can manipulate the variables
jblundell_quote = "fog rolling in";now because we've stored the string inside that variable, we can use that variable in place of where we would normally use a string. for example in the IPrintLnBold() function:
jblundell_quote = "fog rolling in";note this is the same as:
IPrintLnBold(jblundell_quote);
IPrintLnBold("fog rolling in");
push_ups_performed = 0;if we want to do math operations on a variable, we can do it like this:
push_ups_performed = push_ups_performed += 3; //adds 3notice we have to type it twice, because we want to define it as itself (whatever it used to be) plus the 3, not just as 3.
push_ups_performed = push_ups_performed -= 3; //subtracts 3
push_ups_performed = push_ups_performed * 3; //multiplies by 3
push_ups_performed = push_ups_performed / 3; //divides by 3
push_ups_performed ++; //adds 1POP QUIZ: What number will this print to the screen?
push_ups_performed --; //subtracts 1
push_ups_performed = 5;if you said
push_ups_performed --;
push_ups_performed = push_ups_performed * 4;
push_ups_performed = push_ups_performed - 7;
push_ups_performed = push_ups_performed / 3;
push_ups_performed ++;
IPrintLnBold(push_ups_performed);
entity GetEnt(,,[ignore spawners])notice how when we look up the engine functions in the Modme ScriptDocs, the word entity appears before it. This means that using this function will return us an entity, which we can store in a variable. So using this function would look like this:
watermelon_model = GetEnt("watermelon","targetname");assuming that in radiant we have a script_model with the KVP of targetname: watermelon. And preferably it looks like a watermelon.
ur_gay = true;please note that true and false do not go inside quotation marks "", or else you would be setting it equal to a string that simply is the word "true".
entity GetEnt(,,[ignore spawners])the first parameter is required and it is the name you gave the key of the entity in radiant. The second is also required and it is the key you are using of the entity in radiant.
value = "watermelon";notice that I don't have to give the arguments the same exact names as the parameters being asked for.
key = "targetname";
include_spawners = false;
watermelon_model = GetEnt( value, key, include_spawners);
function calculate_bmi( weight, height )In this example the function is asking for two parameters: a weight, and a height.
{
bmi = weight / height / height;
IPrintLnBold("your BMI is " + bmi);
}
calculate_bmi( 70, 1.8 ); //weight is in kg and height is in m
watermelon_model thread fly_away();provided we've already defined the watermelon model above, most likely using GetEnt() as I talked about before.
function fly_away()this will make the watermelon fly upward by 1000 units in 10 seconds.
{
self MoveZ(1000, 10, 5);
}
function calculate_bmi( weight, height )it's as simple as putting the word return before the value we want to return. Now when calling this function, in order to receive the bmi value we must set a variable for it to be stored in:
{
bmi = weight / height / height;
return bmi;
}
my_bmi = calculate_bmi( 60, 1.5);now we can use the variable my_bmi which should have stored in it the calculated value using the data 60 for the weight and 1.5 for the height.
>class,zm_mod_levelTo parse our script, we add the line:
>group,modtools
xmodel,skybox_default_day
material,luts_t7_default
// BSP
col_map,maps/zm/zm_yourmapname.d3dbsp
gfx_map,maps/zm/zm_yourmapname.d3dbsp
// Audio
sound,zm_yourmapname
scriptparsetree,scripts/zm/zm_yourmapname.gsc
scriptparsetree,scripts/zm/zm_yourmapname.csc
scriptparsetree,scripts/zm/my_external_script.gscto the bottom.
function my_cool_print_function()this can be it for our external script. Now let's find a way to call it.
{
IPrintLnBold("Your Mom looks like a Turtle");
}
function main()Since we also want this function to be called after all players have connected, and then 10 seconds after that, we should call it below the wait(10); line.
{
zm_usermap::main();
level._zombie_custom_add_weapons =&amp;custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&amp;usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
level waittill("all_players_connected");
wait(10);
thread my_awesome_function();
}
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}
my_external_script::my_cool_print_function();notice:
thread my_external_script::my_cool_print_function();So, let's show it all in place:
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&amp;custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&amp;usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
level waittill("all_players_connected");
wait(10);
thread my_awesome_function();
thread my_external_script::my_cool_print_function();
}
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}
********************************************************************************this is because anytime you call a function from an external .gsc file, you must include that file in the #using's at the stop of the script that's calling it.
UNRECOVERABLE ERROR:
^1SCRIPT ERROR: No generated data for 'scripts/zm/zm_yourmapname.gsc'
ERR(6E) scripts/zm/zm_yourmapname.gsc (93,0) : Compiler Internal Error : Unresolved external 'my_external_script::my_cool_print_function'
Linker will now terminate.
********************************************************************************
#using scripts\zm\my_external_script;notice:
#using scripts\codescripts\struct;Now in-game you should notice both the print function inside yourmapname.gsc and the print function in the my_external_script.gsc being called, at pretty much the same exact time.
#using scripts\shared\array_shared;
#using scripts\shared\callbacks_shared;
#using scripts\shared\clientfield_shared;
#using scripts\shared\compass;
#using scripts\shared\exploder_shared;
#using scripts\shared\flag_shared;
#using scripts\shared\laststand_shared;
#using scripts\shared\math_shared;
#using scripts\shared\scene_shared;
#using scripts\shared\util_shared;
#insert scripts\shared\shared.gsh;
#insert scripts\shared\version.gsh;
#insert scripts\zm\_zm_utility.gsh;
#using scripts\zm\_load;
#using scripts\zm\_zm;
#using scripts\zm\_zm_audio;
#using scripts\zm\_zm_powerups;
#using scripts\zm\_zm_utility;
#using scripts\zm\_zm_weapons;
#using scripts\zm\_zm_zonemgr;
#using scripts\shared\ai\zombie_utility;
//Perks
#using scripts\zm\_zm_pack_a_punch;
#using scripts\zm\_zm_pack_a_punch_util;
#using scripts\zm\_zm_perk_additionalprimaryweapon;
#using scripts\zm\_zm_perk_doubletap2;
#using scripts\zm\_zm_perk_deadshot;
#using scripts\zm\_zm_perk_juggernaut;
#using scripts\zm\_zm_perk_quick_revive;
#using scripts\zm\_zm_perk_sleight_of_hand;
#using scripts\zm\_zm_perk_staminup;
//Powerups
#using scripts\zm\_zm_powerup_double_points;
#using scripts\zm\_zm_powerup_carpenter;
#using scripts\zm\_zm_powerup_fire_sale;
#using scripts\zm\_zm_powerup_free_perk;
#using scripts\zm\_zm_powerup_full_ammo;
#using scripts\zm\_zm_powerup_insta_kill;
#using scripts\zm\_zm_powerup_nuke;
//#using scripts\zm\_zm_powerup_weapon_minigun;
//Traps
#using scripts\zm\_zm_trap_electric;
#using scripts\zm\zm_usermap;
#using scripts\zm\my_external_script;
//*****************************************************************************
// MAIN
//*****************************************************************************
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&amp;custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&amp;usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
level waittill("all_players_connected");
wait(10);
thread my_awesome_function();
thread my_external_script::my_cool_print_function();
}
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}
function usermap_test_zone_init()
{
level flag::init( "always_on" );
level flag::set( "always_on" );
}
function custom_add_weapons()
{
zm_weapons::load_weapon_spec_from_table("gamedata/weapons/zm/zm_levelcommon_weapons.csv", 1);
}
#namespace zombie_utility;it's as simple as putting #namespace followed by the name you want to give the script.
zom = zombie_utility::spawn_zombie( spawner, target_name, location, round_number );I just have to remember to have the #using for the script at the top of my script:
#using scripts\shared\ai\zombie_utility;and remember to make sure I'm calling the function by whatever #namespace Treyarch gave that script, not necessarily the filename (though in this case they are the same)
function my_function_name_here()notice the parts:
{
}
#using scripts\codescripts\struct;You should see:
#using scripts\shared\array_shared;
#using scripts\shared\callbacks_shared;
#using scripts\shared\clientfield_shared;
#using scripts\shared\compass;
#using scripts\shared\exploder_shared;
#using scripts\shared\flag_shared;
#using scripts\shared\laststand_shared;
#using scripts\shared\math_shared;
#using scripts\shared\scene_shared;
#using scripts\shared\util_shared;
#insert scripts\shared\shared.gsh;
#insert scripts\shared\version.gsh;
#insert scripts\zm\_zm_utility.gsh;
#using scripts\zm\_load;
#using scripts\zm\_zm;
#using scripts\zm\_zm_audio;
#using scripts\zm\_zm_powerups;
#using scripts\zm\_zm_utility;
#using scripts\zm\_zm_weapons;
#using scripts\zm\_zm_zonemgr;
#using scripts\shared\ai\zombie_utility;
//Perks
#using scripts\zm\_zm_pack_a_punch;
#using scripts\zm\_zm_pack_a_punch_util;
#using scripts\zm\_zm_perk_additionalprimaryweapon;
#using scripts\zm\_zm_perk_doubletap2;
#using scripts\zm\_zm_perk_deadshot;
#using scripts\zm\_zm_perk_juggernaut;
#using scripts\zm\_zm_perk_quick_revive;
#using scripts\zm\_zm_perk_sleight_of_hand;
#using scripts\zm\_zm_perk_staminup;
//Powerups
#using scripts\zm\_zm_powerup_double_points;
#using scripts\zm\_zm_powerup_carpenter;
#using scripts\zm\_zm_powerup_fire_sale;
#using scripts\zm\_zm_powerup_free_perk;
#using scripts\zm\_zm_powerup_full_ammo;
#using scripts\zm\_zm_powerup_insta_kill;
#using scripts\zm\_zm_powerup_nuke;
//#using scripts\zm\_zm_powerup_weapon_minigun;
//Traps
#using scripts\zm\_zm_trap_electric;
#using scripts\zm\zm_usermap;
//*****************************************************************************
// MAIN
//*****************************************************************************
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&amp;custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&amp;usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
}
function usermap_test_zone_init()
{
level flag::init( "always_on" );
level flag::set( "always_on" );
}
function custom_add_weapons()
{
zm_weapons::load_weapon_spec_from_table("gamedata/weapons/zm/zm_levelcommon_weapons.csv", 1);
}
//*****************************************************************************Before we even get to calling it, let's give it something simple it can actually do, since currently it does nothing. Let's use a very common Engine Function which we can call from anywhere. The engine function I'm talking about is IPrintLnBold():
// MAIN
//*****************************************************************************
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&amp;custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&amp;usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
}
function my_awesome_function()
{
}
function usermap_test_zone_init()
{
level flag::init( "always_on" );
level flag::set( "always_on" );
}
function custom_add_weapons()
{
zm_weapons::load_weapon_spec_from_table("gamedata/weapons/zm/zm_levelcommon_weapons.csv", 1);
}
void IPrintLnBold()You can find all the Engine functions in the Modme ScriptDocs. These can be used anywhere. The IPrintLnBold() is simple. It takes one argument: a string of text, and when the line is read by the computer it will print that text to the screen in-game. This is very useful for testing scripts, as it let's us see where the computer is reading lines and where it isn't.
function my_awesome_function()notice:
{
IPrintLnBold("Hello Everybody");
}
********************************************************************************You see, when computers read .gsc code, they ignore spaces and newlines. That way I can have as many spaces and newlines to make myself comfortable. However this means we must manually define where the line ends using a ; or launcher will keep reading everything as one line and get confused.
UNRECOVERABLE ERROR:
^1SCRIPT ERROR: No generated data for 'scripts/zm/zm_yourmapname.gsc'
ERR(0) scripts/zm/zm_yourmapname.gsc (76,1) in "my_awesome_function()" : syntax error, unexpected TOKEN_RIGHT_CURLY : }
Linker will now terminate.
********************************************************************************
my_awesome_function();if we place this line inside a function that we know will be run before the start of the game, we can effectively call it:
function main()There's another way to call a function though, and that's called threading. Bascially if we do the same thing except type the word thread before it, we can thread the function:
{
zm_usermap::main();
level._zombie_custom_add_weapons =&amp;custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&amp;usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
my_awesome_function();
}
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}
thread my_awesome_function();but what does it mean to thread? This can be a difficult concept to understand immediately. Basically when we thread, we split the computer up into two instances: one which will jump to and start reading the function we threaded; and the other which will keep on reading the lines below it as normal. if we don't thread however, then the computer will see the function call, jump to the function, finish reading that function, then jump back to where it was it the other function it was in and keep reading as normal.
level waittill("all_players_connected");notice:
function main()We're almost ready to run the code and see the results. One more thing though.
{
zm_usermap::main();
level._zombie_custom_add_weapons =&amp;custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&amp;usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
level waittill("all_players_connected");
thread my_awesome_function();
}
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}
wait(10);notice:
function main()Now if we save, link in launcher, and run the map, we should see our line print to the screen shortly after starting the game!
{
zm_usermap::main();
level._zombie_custom_add_weapons =&amp;custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&amp;usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
level waittill("all_players_connected");
wait(10);
thread my_awesome_function();
}
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}
can I put in waw? the archive is for bo3 i need to put in world at war pls the scripts of bo3 cant use in waw