Game Modding | Call of Duty: Black Ops 3 | Scripting
Abnormal202:
ABNORMAL202 SCRIPTING TUTORIAL 1: FUNCTIONS
See ALL Tutorials
DESCRIPTION
I'm lean, mean, and ready to code! but where exactly can I do that?
The bulk of all code is contained with functions. The only time you will be scripting outside of a function in a .gsc is when you're loading things in the preamble of the script. This is the place where you can see all the #using's, #insert's, #precache's to name a few, which I will get to later.
So how do I make a function?
FUNCTION RULES
You can create a function by typing:
function my_function_name_here()
{
}
notice the parts:
#using scripts\codescripts\struct;
#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 =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&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);
}
//*****************************************************************************
// MAIN
//*****************************************************************************
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&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()
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}
********************************************************************************
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();
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&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();
level waittill("all_players_connected");
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&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);
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = [];
level.zone_manager_init_func =&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");
}