UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Cxwh

So options in the players menu won't show up. It confuses me and makes my head hurt since it theres no reason why this shouldn't work.

I know this is a wall of script, but you'd just have to focus on menu util (addOption & addMenu) and where I add the options

add player menu: line 167
add submenu: line 200
add options to submenu: 201 (they for some reason dont show up)

source:
Code Snippet
Plaintext
#using scripts\codescripts\struct;
#using scripts\shared\system_shared;
#using scripts\shared\callbacks_shared;
#using scripts\shared\hud_util_shared;

#insert scripts\shared\shared.gsh;

#namespace clientids;

REGISTER_SYSTEM( "clientids", &__init__, undefined )

function __init__()
{
    callback::on_start_gametype( &init );
    callback::on_connect( &onPlayerConnect );
callback::on_disconnect( &onPlayerDisconnected );
}

function init()
{
level.clientid = 0;
level.occult = [];

level.occult["info"] = [];
level.occult["info"]["name"] = "Occult";
level.occult["info"]["version"] = "shits got no version";
level.occult["info"]["creator"] = "Cxwh";
level.occult["info"]["credits"] = array("Fallen", "Cabcon", "SeriousHD", "Shark");

level.occult["settings"] = [];
setting("set", "lastIndex", 14);
setting("set", "style", "Surge"); //todo
setting("set", "sudo", true); //todo

level.occult["colors"] = [];
color("set", "black", (0, 0, 0));
color("set", "white", (1, 1, 1));
color("set", "red", (1, 0, 0));
color("set", "yellow", (1, 1, 0));
color("set", "green", (0, 1, 0));
color("set", "blue", (0,0, 1));
color("set", "purple", (1, 0, 1));
color("set", "cyan", (0, 1, 1));
color("set", "gray", (0.5, 0.5, 0.5));
color("set", "orange", (0.95, 0.52, 0.0285));

level.occult["themes"] = [];
theme("add", "Surge", "orange", "black");
theme("add", "Cherry", "red", "white");
theme("add", "Poison", "green", "black");
theme("add", "Death Star", "cyan", "black");
theme("add", "Obsidian", "purple", "black");
theme("add", "NextGenUpdate", "cyan", "gray");
theme("add", "Se7enSins", "green", "gray");

level.occult["menu"] = [];

main = "Main Menu";
level addMenu(undefined, main);

menu = "SubMenu 1";
level addMenu(main, menu);
level addOption(menu, "Option 1", &test);
level addOption(menu, "Option 2", &test);
level addOption(menu, "Option 3", &test);
level addOption(menu, "Option 4", &test);
level addOption(menu, "Option 5", &test);
level addOption(menu, "Option 6", &test);
level addOption(menu, "Option 7", &test);
level addOption(menu, "Option 8", &test);
level addOption(menu, "Option 9", &test);

level addOption(menu, "Option 10", &test);
level addOption(menu, "Option 11", &test);
level addOption(menu, "Option 12", &test);
level addOption(menu, "Option 13", &test);
level addOption(menu, "Option 14", &test);
level addOption(menu, "Option 15", &test);
level addOption(menu, "Option 16", &test);
level addOption(menu, "Option 17", &test);

menu = "SubMenu 2";
level addMenu(main, menu);
level addOption(menu, "Option 1", &test);
level addOption(menu, "Option 2", &test);
level addOption(menu, "Option 3", &test);
level addOption(menu, "Option 4", &test);
level addOption(menu, "Option 5", &test);
level addOption(menu, "Option 6", &test);
level addOption(menu, "Option 7", &test);
level addOption(menu, "Option 8", &test);
level addOption(menu, "Option 9", &test);

level addOption(menu, "Option 10", &test);
level addOption(menu, "Option 11", &test);
level addOption(menu, "Option 12", &test);
level addOption(menu, "Option 13", &test);
level addOption(menu, "Option 14", &test);
level addOption(menu, "Option 15", &test);
level addOption(menu, "Option 16", &test);
level addOption(menu, "Option 17", &test);

menu = "SubMenu 3";
level addMenu(main, menu);
level addOption(menu, "Option 1", &test);
level addOption(menu, "Option 2", &test);
level addOption(menu, "Option 3", &test);
level addOption(menu, "Option 4", &test);
level addOption(menu, "Option 5", &test);
level addOption(menu, "Option 6", &test);
level addOption(menu, "Option 7", &test);
level addOption(menu, "Option 8", &test);
level addOption(menu, "Option 9", &test);

level addOption(menu, "Option 10", &test);
level addOption(menu, "Option 11", &test);
level addOption(menu, "Option 12", &test);
level addOption(menu, "Option 13", &test);
level addOption(menu, "Option 14", &test);
level addOption(menu, "Option 15", &test);
level addOption(menu, "Option 16", &test);
level addOption(menu, "Option 17", &test);

menu = "SubMenu 4";
level addMenu(main, menu);
level addOption(menu, "Option 1", &test);
level addOption(menu, "Option 2", &test);
level addOption(menu, "Option 3", &test);
level addOption(menu, "Option 4", &test);
level addOption(menu, "Option 5", &test);
level addOption(menu, "Option 6", &test);
level addOption(menu, "Option 7", &test);
level addOption(menu, "Option 8", &test);
level addOption(menu, "Option 9", &test);

level addOption(menu, "Option 10", &test);
level addOption(menu, "Option 11", &test);
level addOption(menu, "Option 12", &test);
level addOption(menu, "Option 13", &test);
level addOption(menu, "Option 14", &test);
level addOption(menu, "Option 15", &test);
level addOption(menu, "Option 16", &test);
level addOption(menu, "Option 17", &test);

menu = "SubMenu 5";
level addMenu(main, menu);
level addOption(menu, "Option 1", &test);
level addOption(menu, "Option 2", &test);
level addOption(menu, "Option 3", &test);
level addOption(menu, "Option 4", &test);
level addOption(menu, "Option 5", &test);
level addOption(menu, "Option 6", &test);
level addOption(menu, "Option 7", &test);
level addOption(menu, "Option 8", &test);
level addOption(menu, "Option 9", &test);

level addOption(menu, "Option 10", &test);
level addOption(menu, "Option 11", &test);
level addOption(menu, "Option 12", &test);
level addOption(menu, "Option 13", &test);
level addOption(menu, "Option 14", &test);
level addOption(menu, "Option 15", &test);
level addOption(menu, "Option 16", &test);
level addOption(menu, "Option 17", &test);

menu = "Players";
level addMenu(main, menu);

level.occult["data"] = [];
level.occult["data"]["user"] = [];
level.occult["data"]["dvar"] = GetDvarString("occult");

level thread onGameEnded();

//autoverify
autoverify = level.occult["data"]["dvar"];
if(isDefined(autoverify) && autoverify != "")
{
autoverify = StrTok(autoverify, ",");
for(i = 0; i < autoverify.size; i++)
{
token = StrTok(autoverify[i], "_");
foreach(player in level.players)
{
if(player.name == token[0])
player permission("set", token[1]);
}
}
}
}

function onPlayerConnect()
{
self endon("disconnect");

//setup vars etc.
level addUser(self);

//add an option to the players menu
level addMenu("Players", self.name);
level addOption(self.name, "Option 1", &test);
level addOption(self.name, "Option 2", &test);
level addOption(self.name, "Option 3", &test);

//homefront
self waittill("spawned_player");

//we're not really using perms yet
self thread createHud();
self thread monitorKeys();

//level.script[0] == "m" -> if its mp or zm and if its nuketown
if(level.script == "mp_nuketown_x" || level.script[0] == "m")
return;

//skybarrier
hurt_triggers = getentarray("trigger_hurt", "classname");
foreach(barrier in hurt_triggers)
barrier.origin += (0, 0, 9999999);

level.player_out_of_playable_area_monitor = false;

while(isAlive(self))
{
self variable("set", "menu_locked", true);
self SetClientUIVisibilityFlag("hud_visible", 0);
self EnableInvulnerability();
self FreezeControls(true);
self DisableWeapons();
self Hide();

zoomHeight = 5000;
zoomBack = 4000;
yaw = 55;

origin = self.origin;
self.origin = origin + vector_scale(AnglesToForward(self.angles + (0, -180, 0)), zoomBack) + (0, 0, zoomHeight);

ent = spawn("script_model", (0 ,0, 0));
ent.angles = self.angles + (yaw, 0, 0);
ent.origin = self.origin;
ent SetModel("tag_origin");

self PlayerLinkToAbsolute(ent);
ent MoveTo (origin + (0, 0, 0), 4, 2, 2);
wait 1;

ent RotateTo((ent.angles[0] - yaw, ent.angles[1], 0), 3, 1, 1);
wait 0.5;

self PlayLocalSound("ui_camera_whoosh_in");
wait 2.5;

self Unlink();
wait 0.2;

ent Delete();
self EnableWeapons();
self Show();
self FreezeControls(false);
wait .4;

self DisableInvulnerability();
self SetClientUIVisibilityFlag("hud_visible", 1);
break;
}

//skybarrier
foreach(barrier in hurt_triggers)
barrier.origin -= (0, 0, 9999999);

level.player_out_of_playable_area_monitor = true;

//unlock menu
self variable("set", "menu_locked", false);
}

function onPlayerDisconnected()
{
//remove client data
ArrayRemoveIndex(level.occult["data"]["user"], self.name, true);

//remove option from the players menu
menu = level.occult["menu"]["Players"];
ArrayRemoveIndex(menu["options"], self.name);

//everyone in "your" menu will enter parent menu due to you leaving
foreach(player in level.players)
{
if(player isAllowed())
{
if(player getParent() == "Players" && player getCurrentMenu() == self.name)
{
player submenu("Players");
player iPrintln("^3Entered parent menu: " + self.name + " left the game");
}
}
}
self notify("#end");
}

function onGameEnded()
{
level waittill("game_ended");
wait 0.25;

//close everyones menu
foreach(player in level.players)
{
if(isAllowed(player))
{
player exitMenu();
player variable("set", "menu_locked", true);
}
player notify("#end");
}

//autoverify for next game
string = "";
for(i = 0; i < level.players.size; i++)
{
if(isAllowed(player))
{
if(i == level.players.size - 1)
string += level.players[i].name + "_" +  level.players[i] permission("get");
else
string += level.players[i].name + "_" +  level.players[i] permission("get") + ",";
}
}
SetDvar("occult", string);
}

function addUser(user)
{
index = user.name;
level.occult["data"]["user"][index] = [];
level.occult["data"]["user"][index]["hud"] = [];
level.occult["data"]["user"][index]["menu"] = [];

level.occult["data"]["user"][index]["variables"] = [];
level.occult["data"]["user"][index]["variables"]["controls"] = []; //actual button config

level.occult["data"]["user"][index]["variables"]["toggles"] = [];
level.occult["data"]["user"][index]["variables"]["toggles"]["reset"] = []; //the ones we want to reset upon death

level.occult["data"]["user"][index]["preferences"] = [];
level.occult["data"]["user"][index]["preferences"]["colors"] = [];

level.occult["data"]["user"][index]["preferences"]["controls"] = [];
level.occult["data"]["user"][index]["preferences"]["controls"]["default"] = [];
level.occult["data"]["user"][index]["preferences"]["controls"]["default"]["open"] = "[{+actionslot 1}]";
level.occult["data"]["user"][index]["preferences"]["controls"]["default"]["back"] = "[{+usereload}]";
level.occult["data"]["user"][index]["preferences"]["controls"]["default"]["exit"] = "[{+actionslot 2}]";
level.occult["data"]["user"][index]["preferences"]["controls"]["default"]["up"] = "[{+attack}]";
level.occult["data"]["user"][index]["preferences"]["controls"]["default"]["down"] = "[{+speed_throw}]";
level.occult["data"]["user"][index]["preferences"]["controls"]["default"]["select"] = "[{+gostand}]";
level.occult["data"]["user"][index]["preferences"]["controls"]["default"]["debug"] = "[{+actionslot 4}]";

//set colors for menu hud
user setColor("panel", "black");
user setColor("glow", "orange");
user setColor("title", "orange");
user setColor("options", "white");
user setColor("scrollbar", "orange");
user setColor("background", "black");

//needed for unlimited scrolling
foreach(menu in level.occult["menu"])
{
label = menu["label"];
level.occult["data"]["user"][index]["menu"][label] = [];
level.occult["data"]["user"][index]["menu"][label]["o_index"] = 0;
level.occult["data"]["user"][index]["menu"][label]["s_index"] = 0;
level.occult["data"]["user"][index]["menu"][label]["l_index"] = menu["l_index"];
}

//default controls & Main Menu as current menu
user variable("set", "current_menu", "Main Menu");
user controls("set", "default");

user preference("set", "controls", "default");
user preference("set", "instructions", true);

if(user isHost())
level.occult["data"]["user"][index]["perm"] = 3;
else
level.occult["data"]["user"][index]["perm"] = 0;

user variable("set", "menu_locked", false);
user variable("set", "menu_active", false);
user variable("set", "menu_closing", false);
}

//button monitoring
function monitorKeys()
{
self endon("#end");

in_menu_help = [];
in_menu_help["time"] = 0;
in_menu_help["resetTime"] = 10;
in_menu_help["index"] = 0;

//not english ik
out_menu_help = [];
out_menu_help["time"] = 0;
out_menu_help["resetTime"] = 15;
out_menu_help["index"] = 0;

button = variable("get", "controls");

in_menu_help["instructions"] = array("Press " + button["exit"] + " to exit menu", "Press " + button["back"] + " to go back", "Press " + button["up"] + " to scroll up\nPress " + button["down"] + " to scroll down", "Press " + button["back"] + " to go back", "Press " + button["select"] + " to select");
out_menu_help["instructions"] = array("Press " + button["open"] + " to open menu", "Press " + button["debug"] + " to exit level");

for(;;)
{
while(isAlive(self))
{
//check if menu is locked
if(!variable("get", "menu_locked"))
{
//check if menu is active
if(!variable("get", "menu_active"))
{
//open menu
if(self isButtonPressed(button["open"]))
self loadMenu();

//exit level (for testing)
if(self isButtonPressed(button["debug"]))
ExitLevel();

//check if instructions are on
if(preference("get", "instructions"))
{
if(out_menu_help["time"] < 0)
{
index = out_menu_help["index"];
self iPrintln(out_menu_help["instructions"][index]);

out_menu_help["index"]++;
if(out_menu_help["index"] == out_menu_help["instructions"].size)
out_menu_help["index"] = 0;

out_menu_help["time"] = out_menu_help["resetTime"];
}
out_menu_help["time"] -= 0.05;
}
}

//check if menu is active and if menu is closing (-> fixed problems with the hud)
else if(variable("get", "menu_active") && !variable("get", "menu_closing"))
{
//back
if(self isButtonPressed(button["back"]))
{
if(!isEmpty(self getParent()))
self submenu(self getParent());
else
self exitMenu();
wait 0.2;
}

//exit menu
if(self isButtonPressed(button["exit"]))
{
self exitMenu();
wait 0.2;
}

//scroll
if(self isButtonPressed(button["up"]) || self isButtonPressed(button["down"]))
{
menu = self getCurrentMenu();
user = self.name;

//scroll up
if(self isButtonPressed(button["up"]))
{
level.occult["data"]["user"][user]["menu"][menu]["o_index"]--;
if(level.occult["data"]["user"][user]["menu"][menu]["o_index"] < 0)
{
level.occult["data"]["user"][user]["menu"][menu]["o_index"] = level.occult["menu"][menu]["options"].size - 1;
level.occult["data"]["user"][user]["menu"][menu]["s_index"] = level.occult["data"]["user"][user]["menu"][menu]["l_index"];

index = 0;
last_index = level.occult["data"]["user"][user]["menu"][menu]["l_index"];
for(i = level.occult["data"]["user"][user]["menu"][menu]["o_index"] - last_index; i < level.occult["menu"][menu]["options"].size; i++)
{
level.occult["data"]["user"][user]["hud"]["options"][index] setText(level.occult["menu"][menu]["options"][i]["label"]);
index++;
}
level.occult["data"]["user"][user]["hud"]["scrollbar"] elemMoveY(0.15, level.occult["data"]["user"][user]["hud"]["options"][level.occult["data"]["user"][user]["menu"][menu]["s_index"]].y + 1);
}
else
{
if(level.occult["data"]["user"][user]["menu"][menu]["s_index"] == 0)
{
index = 0;
last_index = level.occult["data"]["user"][user]["menu"][menu]["l_index"];
for(i = level.occult["data"]["user"][user]["menu"][menu]["o_index"]; i < level.occult["data"]["user"][user]["menu"][menu]["o_index"] + last_index + 1; i++)
{
level.occult["data"]["user"][user]["hud"]["options"][index] setText(level.occult["menu"][menu]["options"][i]["label"]);
index++;
}
}
else
{
level.occult["data"]["user"][user]["menu"][menu]["s_index"]--;
level.occult["data"]["user"][user]["hud"]["scrollbar"] elemMoveY(0.15, level.occult["data"]["user"][user]["hud"]["options"][level.occult["data"]["user"][user]["menu"][menu]["s_index"]].y + 1);
}
}
}

//scroll down
else
{
level.occult["data"]["user"][user]["menu"][menu]["o_index"]++;
if(level.occult["data"]["user"][user]["menu"][menu]["o_index"] > level.occult["menu"][menu]["options"].size - 1)
{
level.occult["data"]["user"][user]["menu"][menu]["o_index"] = 0;
level.occult["data"]["user"][user]["menu"][menu]["s_index"] = 0;

for(i = 0; i < level.occult["data"]["user"][user]["menu"][menu]["l_index"] + 1; i++)
level.occult["data"]["user"][user]["hud"]["options"][i] setText(level.occult["menu"][menu]["options"][i]["label"]);
level.occult["data"]["user"][user]["hud"]["scrollbar"] elemMoveY(0.15, level.occult["data"]["user"][user]["hud"]["options"][level.occult["data"]["user"][user]["menu"][menu]["s_index"]].y + 1);
}
else
{
if(level.occult["data"]["user"][user]["menu"][menu]["s_index"] == level.occult["data"]["user"][user]["menu"][menu]["l_index"])
{
index = 0;
last_index = level.occult["data"]["user"][user]["menu"][menu]["l_index"];
for(i = level.occult["data"]["user"][user]["menu"][menu]["o_index"] - last_index; i < level.occult["data"]["user"][user]["menu"][menu]["o_index"] + 1; i++)
{
level.occult["data"]["user"][user]["hud"]["options"][index] setText(level.occult["menu"][menu]["options"][i]["label"]);
index++;
}
}
else
{
level.occult["data"]["user"][user]["menu"][menu]["s_index"]++;
level.occult["data"]["user"][user]["hud"]["scrollbar"] elemMoveY(0.15, level.occult["data"]["user"][user]["hud"]["options"][level.occult["data"]["user"][user]["menu"][menu]["s_index"]].y + 1);
}
}
}
self thread scrollbarEffect();
wait 0.2;
}

//select
if(self isButtonPressed(button["select"]))
{
selected = self getMenu()["options"][self getPosition()];

//thread function
if(selected["type"] == "thread")
{
if(isEmpty(selected["input"]))
self thread [[selected["func"]]]();
else if(isArray(selected["input"]))
{
if(selected["input"].size == 0)
self iprintln("^1ERROR: ^3Cannot call function: no arguments passed");

else if(selected["input"].size == 1)
self thread [[selected["func"]]](selected["input"][0]);

else if(selected["input"].size == 2)
self thread [[selected["func"]]](selected["input"][0], selected["input"][1]);

else if(selected["input"].size == 3)
self thread [[selected["func"]]](selected["input"][0], selected["input"][1], selected["input"][2]);

else if(selected["input"].size == 4)
self thread [[selected["func"]]](selected["input"][0], selected["input"][1], selected["input"][2], selected["input"][3]);

else if(selected["input"].size == 5)
self thread [[selected["func"]]](selected["input"][0], selected["input"][1], selected["input"][2], selected["input"][3], selected["input"][4]);

else
self iPrintln("^1ERROR: ^3Cannot call function: too many arguments passed");
}
else
self thread [[selected["func"]]](selected["input"]);
}

//dont thread it
else if(selected["type"] == "immediate")
{
if(isEmpty(selected["input"]))
self [[selected["func"]]]();

else if(isArray(selected["input"]))
self [[selected["func"]]](selected["input"][0], selected["input"][1], selected["input"][2], selected["input"][3], selected["input"][4]);

else
self [[selected["func"]]](selected["input"]);
}

//will prevent the text from moving if the option is "submenu"
if(selected["func"] != &submenu || ( selected["func"] == &submenu && isEmpty(level.occult["menu"][selected["input"]]) ))
{
elem = level.occult["data"]["user"][self.name]["hud"]["options"][self getPosition("s_index")];
elem elemMoveX(0.07, elem.x - 5);

wait 0.25;
elem thread elemMoveX(0.07, -10);
}
wait 0.2;
}

//check if instructions are on or off
if(self preference("get", "instructions"))
{
if(in_menu_help["time"] < 0)
{
index = in_menu_help["index"];
self iPrintln(in_menu_help["instructions"][index]);

in_menu_help["index"]++;
if(in_menu_help["index"] == in_menu_help["instructions"].size)
in_menu_help["index"] = 0;

in_menu_help["time"] = in_menu_help["resetTime"];
}
in_menu_help["time"] -= 0.05;
}
}
}
wait 0.05;
}

//since we're dead we can reset variables/toggles here
foreach(toggle, state in level.occult["data"]["user"][index]["variables"]["toggles"]["reset"])
setVar(toggle, !state);

//empty the array
level.occult["data"]["user"][index]["variables"]["toggles"]["reset"] = [];

//wait for us to spawn
self waittill("spawned_player");
self iPrintLn("^2Reset Toggles");
}
}

//menu util
function addMenu(parent, menu)
{
level.occult["menu"][menu] = [];
level.occult["menu"][menu]["options"] = [];

level.occult["menu"][menu]["label"] = menu;
level.occult["menu"][menu]["parent"] = parent;
level.occult["menu"][menu]["permission"] = 0;

//only here for addUser
level.occult["menu"][menu]["l_index"] = 0;

if(!isEmpty(parent))
level addOption(parent, menu, &submenu, menu);
}

function addOption(menu, label, func, input, type = "thread")
{
index = level.occult["menu"][menu]["options"].size;
level.occult["menu"][menu]["options"][index] = [];

level.occult["menu"][menu]["options"][index]["label"] = label;
level.occult["menu"][menu]["options"][index]["func"] = func;

level.occult["menu"][menu]["options"][index]["input"] = input;
level.occult["menu"][menu]["options"][index]["type"] = type;

//only here for addUser
lastIndex = level.occult["settings"]["lastIndex"];
if(index < lastIndex)
level.occult["menu"][menu]["l_index"] = index;
else
level.occult["menu"][menu]["l_index"] = lastIndex;
}

function loadMenu()
{
self FreezeControls(false);
self EnableInvulnerability();
self SetClientUIVisibilityFlag("hud_visible", 0);

self showHud();
self variable("set", "menu_active", true);
}

function exitMenu()
{
self variable("set", "menu_closing", true);
self hideHud();

self variable("set", "menu_closing", false);
wait 0.15;

self SetClientUIVisibilityFlag("hud_visible", 1);
self variable("set", "menu_active", false);

if(!self variable("get", "god"))
self DisableInvulnerability();
}

function submenu(input)
{
if(variable("get", "menu_active") && !variable("get", "menu_closing"))
{
if(isDefined(level.occult["menu"][input]))
{
if(isAllowed(self, getPermission(input)))
{
userIndex = self.name;
self menuTransitionOut();
wait 0.25;

for(i = 0; i < level.occult["data"]["user"][userIndex]["hud"]["options"].size + 1; i++)
level.occult["data"]["user"][userIndex]["hud"]["options"][i] destroy();

self variable("set", "current_menu", input);
self updateText(input);

level.occult["data"]["user"][userIndex]["hud"]["glow"] notify("pulse_end");
level.occult["data"]["user"][userIndex]["hud"]["glow"] thread pulseEffect(0.4, 0.5, 2);

level.occult["data"]["user"][userIndex]["hud"]["scrollbar"] elemMoveY(0.1, level.occult["data"]["user"][self.name]["hud"]["options"][self getPosition("s_index")].y + 1);
level.occult["data"]["user"][userIndex]["hud"]["scrollbar"] scaleOverTime(0.25, 5, 25);
}
else
self iPrintln("^1You do not have permission to enter this menu");
}
else
self iPrintln("^1ERROR: ^3Cannot enter submenu: menu does not exist");
}
else
self iPrintln("^1ERROR: ^3Cannot enter submenu: menu is closing");
}

//hud
function updateText(input)
{
top = 50;
margin = 25;

userIndex = self.name;
color = level.occult["data"]["user"][userIndex]["preferences"]["colors"];

self variable("set", "current_menu", input);
level.occult["data"]["user"][userIndex]["hud"]["title"] destroy();
level.occult["data"]["user"][userIndex]["hud"]["title"] = self createText("RIGHT", "TOP", 0, top, "bigfixed", 1, 7, color["title"], 0, input);
level.occult["data"]["user"][userIndex]["hud"]["title"] elemFade(0.25, 1);
level.occult["data"]["user"][userIndex]["hud"]["title"] thread elemMoveX(0.25, -10);

level.occult["data"]["user"][userIndex]["hud"]["options"] = [];
f_index = level.occult["data"]["user"][userIndex]["menu"][input]["o_index"] - (level.occult["data"]["user"][userIndex]["menu"][input]["l_index"] - (level.occult["data"]["user"][userIndex]["menu"][input]["l_index"] - level.occult["data"]["user"][userIndex]["menu"][input]["s_index"]));
l_index = level.occult["data"]["user"][userIndex]["menu"][input]["o_index"] + level.occult["data"]["user"][userIndex]["menu"][input]["l_index"] - level.occult["data"]["user"][userIndex]["menu"][input]["s_index"];

index = 0;
for(i = f_index; i < l_index + 1; i++)
{
level.occult["data"]["user"][userIndex]["hud"]["options"][index] = self createText("RIGHT", "TOP", -540, top + (2 * margin) + (margin * index), "objective", 1.4, 7, color["options"], 0, level.occult["menu"][input]["options"][i]["label"]);
level.occult["data"]["user"][userIndex]["hud"]["options"][index] thread elemMoveX(0.25, -10);
level.occult["data"]["user"][userIndex]["hud"]["options"][index] elemFade(0.25, 0.5);
index++;
}
self thread scrollbarEffect();
}

function scrollbarEffect()
{
index = self.name;
for(i = 0; i < level.occult["data"]["user"][index]["hud"]["options"].size; i++)
{
if(i == self getPosition("s_index"))
level.occult["data"]["user"][index]["hud"]["options"][i] elemFade(0.25, 1);
else
level.occult["data"]["user"][index]["hud"]["options"][i] elemFade(0.25, 0.5);
}
}

function createHud()
{
top = 50;
margin = 25;

userIndex = self.name;
color = level.occult["data"]["user"][userIndex]["preferences"]["colors"];

level.occult["data"]["user"][userIndex]["hud"]["background"] = self createRectangle("LEFT", "CENTER", 0, 0, 0, 500, 2,  color["background"], 0, "white");
level.occult["data"]["user"][userIndex]["hud"]["scrollbar"] = self createRectangle("RIGHT", "TOP", 0, top + (2 * margin), 6, margin, 9, color["scrollbar"], 0, "white");
level.occult["data"]["user"][userIndex]["hud"]["shadow"] = self createRectangle("RIGHT", "CENTER", 0, 0, 5, 500, 3,  color["panel"], 0, "white");
level.occult["data"]["user"][userIndex]["hud"]["header"] = self createRectangle("RIGHT", "TOP", -5, top, 500, 40, 5,  color["panel"], 0, "white");
level.occult["data"]["user"][userIndex]["hud"]["panel"] = self createRectangle("RIGHT", "CENTER", 0, 0, 0, 500, 2, color["panel"], 0, "white");
level.occult["data"]["user"][userIndex]["hud"]["glow"] = self createRectangle("RIGHT", "CENTER", 0, 0, 0, 500, 1,  color["glow"], 0, "white");
}

function showHud()
{
userIndex = self.name;
level.occult["data"]["user"][userIndex]["hud"]["header"] elemFade(0.1, 0.65);
level.occult["data"]["user"][userIndex]["hud"]["title"] elemFade(0.1, 1);

level.occult["data"]["user"][userIndex]["hud"]["panel"] elemFade(0.1, 0.5);
level.occult["data"]["user"][userIndex]["hud"]["panel"] scaleOverTime(0.25, 540, 500);
level.occult["data"]["user"][userIndex]["hud"]["background"] elemFade(0.1, 0.5);
level.occult["data"]["user"][userIndex]["hud"]["background"] scaleOverTime(0.25, 540, 500);
level.occult["data"]["user"][userIndex]["hud"]["shadow"] elemFade(0.25, 0.5);

level.occult["data"]["user"][userIndex]["hud"]["glow"] elemFade(0.1, 0.5);
level.occult["data"]["user"][userIndex]["hud"]["glow"] scaleOverTime(0.25, 1000, 500);
level.occult["data"]["user"][userIndex]["hud"]["glow"] thread pulseEffect(0.4, 0.5, 2);

self updateText(self getCurrentMenu());
level.occult["data"]["user"][userIndex]["hud"]["scrollbar"] elemMoveY(0.15, self.occult["hud"]["text"]["options"][self getPosition("s_index")].y + 1);
level.occult["data"]["user"][userIndex]["hud"]["scrollbar"] elemFade(0.25, 1);
}

function hideHud()
{
userIndex = self.name;
level.occult["data"]["user"][userIndex]["hud"]["header"] elemFade(0.1, 0);
level.occult["data"]["user"][userIndex]["hud"]["title"] elemFade(0.1, 0);

for(i = 0; i < level.occult["data"]["user"][userIndex]["hud"]["options"].size; i++)
{
level.occult["data"]["user"][userIndex]["hud"]["options"][i] thread elemMoveX(0.25, 0);
level.occult["data"]["user"][userIndex]["hud"]["options"][i] elemFade(0.25, 0);
level.occult["data"]["user"][userIndex]["hud"]["options"][i] destroy();
}

level.occult["data"]["user"][userIndex]["hud"]["glow"] notify("pulse_end");
level.occult["data"]["user"][userIndex]["hud"]["glow"] elemFade(0.4, 0);
level.occult["data"]["user"][userIndex]["hud"]["glow"] scaleOverTime(0.25, 1, 500);
level.occult["data"]["user"][userIndex]["hud"]["shadow"] elemFade(0.4, 0);
level.occult["data"]["user"][userIndex]["hud"]["background"] elemFade(0.4, 0);
level.occult["data"]["user"][userIndex]["hud"]["background"] scaleOverTime(0.25, 1, 500);
level.occult["data"]["user"][userIndex]["hud"]["panel"] elemFade(0.4, 0);
level.occult["data"]["user"][userIndex]["hud"]["panel"] scaleOverTime(0.25, 1, 500);
level.occult["data"]["user"][userIndex]["hud"]["scrollbar"].alpha = 0;
}

function menuTransitionOut()
{
userIndex = self.name;
for(i = 0; i < level.occult["data"]["user"][userIndex]["hud"]["options"].size; i++)
{
level.occult["data"]["user"][userIndex]["hud"]["options"][i] elemFade(0.25, 0);
level.occult["data"]["user"][userIndex]["hud"]["options"][i] thread elemMoveX(0.25, 0);
}

level.occult["data"]["user"][userIndex]["hud"]["scrollbar"] scaleOverTime(0.25, 540, 25);
level.occult["data"]["user"][userIndex]["hud"]["title"] elemFade(0.25, 0);
level.occult["data"]["user"][userIndex]["hud"]["title"] thread elemMoveX(0.25, 0);
}

//hud util
function createRectangle(align, relative, x, y, width, height, sort, color, alpha, shader)
{
shaderElem = newClientHudElem(self);
shaderElem.elemType = "bar";
shaderElem.sort = sort;
shaderElem.color = color;
shaderElem.alpha = alpha;
shaderElem hud::setParent(level.uiParent);
shaderElem setShader(shader, width, height);
shaderElem.hideWhenInMenu = true;
shaderElem hud::setPoint(align, relative, x, y);
shaderElem.type = "shader";
return shaderElem;
}

function createText(align, relative, x, y, font, fontscale, sort, color, alpha, text)
{
textElem = self hud::CreateFontString(font, fontscale);
textElem hud::setPoint(align, relative, x, y);
textElem.sort = sort;
textElem.alpha = alpha;
textElem.hideWhenInMenu = true;
textElem setText(text);
textElem.type = "text";
textElem.color = color;
return textElem;
}

function elemMoveX(time, x)
{
self MoveOverTime(time);
self.x = x;
}

function elemMoveY(time, y)
{
self MoveOverTime(time);
self.y = y;
}

function elemFade(time, alpha)
{
self FadeOverTime(time);
self.alpha = alpha;
}

function pulse(state)
{
if(state == true)
self thread pulseEffect(0.5, 1, 0.5);
else
self notify("pulse_end");

self.pulsing = state;
}

function pulseEffect(min, max, time)
{
self endon("pulse_end");

for(;;)
{
self elemFade(time, max);
wait time;
self elemFade(time, min);
wait time;
}
}

//misc
function getCurrentMenu(index = self.name)
{
return level.occult["data"]["user"][index]["variables"]["current_menu"];
}

function getParent(menu = self getCurrentMenu())
{
return level.occult["menu"][menu]["parent"];
}

function getMenu(menu = self getCurrentMenu())
{
return level.occult["menu"][menu];
}

function getPermission(menu = self getCurrentMenu())
{
return level.occult["menu"][menu]["permission"];
}

function getPosition(type = "o_index", menu = self getCurrentMenu()) //type -> type of index
{
if(type == "s_index")
return level.occult["data"]["user"][self.name]["menu"][menu]["s_index"];
return level.occult["data"]["user"][self.name]["menu"][menu]["o_index"];
}

function controls(action, buttons)
{
if(action == "set")
{
if(isString(buttons))
level.occult["data"]["user"][self.name]["variables"]["controls"] = level.occult["data"]["user"][self.name]["preferences"]["controls"][buttons];
else
level.occult["data"]["user"][self.name]["variables"]["controls"] = buttons;
}
else
return level.occult["data"]["user"][self.name]["variables"]["controls"];
}

function setting(action, name, value)
{
if(action == "get")
return level.occult["settings"][name];
level.occult["settings"][name] = value;
}

function preference(action, name, value)
{
if(action == "get")
return level.occult["data"]["user"][self.name]["preferences"][name];
level.occult["data"]["user"][self.name]["preferences"][name] = value;
}

function variable(action, name, value)
{
if(action == "get")
return level.occult["data"]["user"][self.name]["variables"][name];
level.occult["data"]["user"][self.name]["variables"][name] = value;
}

function color(action, name, value)
{
if(action == "get")
return level.occult["colors"][name];
level.occult["colors"][name] = value;
}

function permission(action, value)
{
if(action == "get")
return level.occult["data"]["user"][self.name]["perm"];
level.occult["data"]["user"][self.name]["perm"] = value;
}

function theme(action, name, primaryColor, secondaryColor)
{
if(action == "add")
{
level.occult["themes"][name] = [];
level.occult["themes"]["label"] = name;
level.occult["themes"]["primary"] = primaryColor;
level.occult["themes"]["secondary"] = secondaryColor;
}
else
{
if(isDefined(level.occult["themes"][name]))
{
theme = level.occult["themes"][name];

setColor("panel", theme["secondary"]);
setColor("background", theme["secondary"]);

setColor("glow", theme["primary"]);
setColor("title", theme["primary"]);
setColor("scrollbar", theme["primary"]);

self iPrintln("Changed theme to: " + theme["label"]);
}
else
self iPrintln("^1ERROR: ^3Cannot set theme: theme does not exist");
}
}

function setColor(elem, name)
{
level.occult["data"]["user"][self.name]["preferences"]["colors"][elem] = level.occult["colors"][name];
}

//SeriousHD
function isButtonPressed(button)
{
if(button == "[{+actionslot 1}]")
return self actionslotonebuttonpressed();

if(button == "[{+actionslot 2}]")
return self actionslottwobuttonpressed();

if(button == "[{+actionslot 3}]")
return self actionslotthreebuttonpressed();

if(button == "[{+actionslot 4}]")
return self actionslotfourbuttonpressed();

if(button == "[{+gostand}]")
return self jumpbuttonpressed();

if(button == "[{+melee}]")
return self meleebuttonpressed();

if(button == "[{+attack}]")
return self attackbuttonpressed();

if(button == "[{+speed_throw}]")
return self adsbuttonpressed();

if(button == "[{+smoke}]")
return self secondaryoffhandbuttonpressed();

if(button == "[{+frag}]")
return self fragbuttonpressed();

if(button == "[{+usereload}]")
return self usebuttonpressed();

if(button == "[{+weapnext_inventory}]")
return self changeseatbuttonpressed();

if(button == "[{+stance}]")
return self stancebuttonpressed();

return false;
}

function isAllowed(user, n = 1)
{
return level.occult["data"]["user"][user.name]["perm"] >= n;
}

function getName(player)
{
if(player == level)
return "level";

playerName = getSubStr(player.name, 0, player.name.size);
for(i = 0; i < playerName.size; i++)
{
if(playerName[i] == "]")
break;
}
if(playerName.size != i)
playerName = getSubStr(playerName, i + 1, playerName.size);

return playerName;
}

function isEmpty(x)
{
if(!isDefined(x) || x == "")
return 1;
return 0;
}

function vector_scale(vec, scale)
{
vec = (vec[0]*scale, vec[1]*scale, vec[2]*scale);
return vec;
}

function setVar(name, value)
{
level.occult["data"]["user"][self.name]["variables"]["toggles"][name] = value;
}

function getVar(name)
{
return level.occult["data"]["user"][self.name]["variables"]["toggles"][name];
}

function resetUponDeath(x)
{
toggles = GetArrayKeys(level.occult["data"]["user"][self.name]["variables"]["toggles"]["reset"]);
if(isInArray(toggles, x))
ArrayRemoveIndex(level.occult["data"]["user"][self.name]["variables"]["toggles"]["reset"], x, true);
else
level.occult["data"]["user"][self.name]["variables"]["toggles"]["reset"][x] = getVar(x);
}

//toggles & functions
function toggle(x, reset, state)
{
if(isEmpty(state))
setVar(x, !getVar(x));
else
setVar(x, state);

if(getVar(x) == true)
status = "^2Enabled";
else
status = "^1Disabled";

if(reset == true)
resetUponDeath(x);

if(x == "god")
{
self iPrintln("God Mode: " + status);

if(getVar(x) == true)
self EnableInvulnerability();
else
{
//Only disable if not in menu; else will be disabled upon menu exit
if(self variable("get", "menu_active") == false)
self DisableInvulnerability();
}
}
else if(x == "ammo")
{
self iPrintln("Infinite Ammo: " + status);

if(getVar(x) == true)
{
self notify("stop_" + x);
self thread infiniteAmmo();
}
else
self notify("stop_" + x);
}
else if(x == "boost")
{
self iPrintln("Infinite Boost: " + status);

if(getVar(x) == true)
{
self notify("stop_" + x);
self thread infiniteBoost();
}
else
self notify("stop_" + x);
}
}

function infiniteAmmo()
{
self endon("stop_ammo");
for(;;)
{
if(self getcurrentweapon() != "none")
{
self setweaponammostock( self getcurrentweapon(), 1337);
self setweaponammoclip( self getcurrentweapon(), 1337);
}
wait .1;
}
}

function infiniteBoost()
{
self endon("stop_boost");

//will endon death
while(isAlive(self))
{
self SetDoubleJumpEnergy(100);
wait 0.15;
}
}

function test()
{
self iPrintLn("Menu: " + self getCurrentMenu());
self iPrintLn("Option: " + self getMenu()["options"][self getPosition()]["label"]);

self iPrintLn("Option Index: " + self getPosition());
self iPrintLn("Scrollbar Index: " + self getPosition("s_index"));
}
7 years ago
I really don't know what's wrong with it but it just keeps closing my bo3 after some time. I know this is just a wall of script but maybe someone knows why this happens and how to fix it.

Code Snippet
Plaintext
#using scripts\codescripts\struct;
#using scripts\shared\system_shared;
#using scripts\shared\callbacks_shared;
#using scripts\shared\hud_util_shared;
#using scripts\shared\bots\_bot;

#insert scripts\shared\shared.gsh;

#namespace clientids;

REGISTER_SYSTEM( "clientids", &__init__, undefined )

function __init__()
{
    callback::on_start_gametype( &init );
    callback::on_connect( &onPlayerConnect );
callback::on_spawned( &onPlayerSpawned );
callback::on_player_killed( &onPlayerKilled );
callback::on_disconnect( &onPlayerDisconnected );
}

function init()
{
thread on_game_ended();
level.clientid = 0;
level.vars = [];
}

function onPlayerConnect()
{
if(!self isHost())
self.perm = "No Access";
else
{
self.perm = "Access Level 4";
self thread homefront();
thread autoverify();
}

self.init = false;
self setClientId();

level.vars[self.name] = [];
level notify("updatePlayersMenu");
}

function onPlayerSpawned()
{
self welcomeMessage();
if(self isAllowed(1) && !self.init)
{
self.init = true;
self thread MenuInit();
}
}

function drawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort)
{
hud = self hud::createFontString(font, fontScale);
hud setText(text);
hud.x = x;
hud.y = y;
hud.color = color;
hud.alpha = alpha;
hud.glowColor = glowColor;
hud.glowAlpha = glowAlpha;
hud.sort = sort;
hud.alpha = alpha;
return hud;
}

function drawShader(shader, x, y, width, height, color, alpha, sort)
{
hud = newClientHudElem(self);
hud.elemtype = "icon";
hud.color = color;
hud.alpha = alpha;
hud.sort = sort;
hud.children = [];
hud hud::setParent(level.uiParent);
hud setShader(shader, width, height);
hud.x = x;
hud.y = y;
return hud;
}

function verToNum(n)
{
switch(n)
{
case "Access Level 4":
return 4;

case "Access Level 3":
return 3;

case "Access Level 2":
return 2;

case "Access Level 1":
return 1;

default:
return 0;
}
}

function welcomeMessage()
{
self iPrintln("^2welcome mois");
if(!isEmpty(level.autoverify))
self iPrintln(level.autoverify);
}

function CreateMenu()
{
self endon("unverified");
self endon("disconnect");
level endon("game_ended");

self addMenu(undefined, "Main Menu", "Unverified");

n = "SubMenu1";
self addMenu("Main Menu", n);
self addOption(n, "GodMode", &toggle, "god");
self addOption(n, "Option 1", &test);
self addOption(n, "Option 3", &test);
self addOption(n, "Option 4", &test);
self addOption(n, "Option 5", &test);
self addOption(n, "Option 6", &test);
self addOption(n, "Option 7", &test);
self addOption(n, "Option 8", &test);
self addOption(n, "Option 9", &test);
self addOption(n, "Option 10", &test);
self addOption(n, "Option 11", &test);
self addOption(n, "Option 12", &test);
self addOption(n, "Option 13", &test);
self addOption(n, "Option 14", &test);
self addOption(n, "Option 15", &test);
self addOption(n, "Option 16", &test);
self addOption(n, "Option 17", &test);
self addOption(n, "Option 18", &test);
self addOption(n, "Option 19", &test);
self addOption(n, "Option 20", &test);
self addOption(n, "Option 21", &test);
self addOption(n, "Option 22", &test);
self addOption(n, "Option 23", &test);
self addOption(n, "Option 24", &test);
self addOption(n, "Option 25", &test);

n = "SubMenu2";
self addMenu("Main Menu", n);
self addOption(n, "Option 1", &test);
self addOption(n, "Option 2", &test);
self addOption(n, "Option 3", &test);
self addOption(n, "Option 4", &test);
self addOption(n, "Option 5", &test);
self addOption(n, "Option 6", &test);
self addOption(n, "Option 7", &test);
self addOption(n, "Option 8", &test);
self addOption(n, "Option 9", &test);
self addOption(n, "Option 10", &test);
self addOption(n, "Option 11", &test);
self addOption(n, "Option 12", &test);
self addOption(n, "Option 13", &test);
self addOption(n, "Option 14", &test);
self addOption(n, "Option 15", &test);
self addOption(n, "Option 16", &test);
self addOption(n, "Option 17", &test);
self addOption(n, "Option 18", &test);
self addOption(n, "Option 19", &test);
self addOption(n, "Option 20", &test);
self addOption(n, "Option 21", &test);
self addOption(n, "Option 22", &test);
self addOption(n, "Option 23", &test);
self addOption(n, "Option 24", &test);
self addOption(n, "Option 25", &test);

n = "SubMenu3";
self addMenu("Main Menu", n);
self addOption(n, "Option 1", &test);
self addOption(n, "Option 2", &test);
self addOption(n, "Option 3", &test);
self addOption(n, "Option 4", &test);
self addOption(n, "Option 5", &test);
self addOption(n, "Option 6", &test);
self addOption(n, "Option 7", &test);
self addOption(n, "Option 8", &test);
self addOption(n, "Option 9", &test);
self addOption(n, "Option 10", &test);
self addOption(n, "Option 11", &test);
self addOption(n, "Option 12", &test);
self addOption(n, "Option 13", &test);
self addOption(n, "Option 14", &test);
self addOption(n, "Option 15", &test);
self addOption(n, "Option 16", &test);
self addOption(n, "Option 17", &test);
self addOption(n, "Option 18", &test);
self addOption(n, "Option 19", &test);
self addOption(n, "Option 20", &test);
self addOption(n, "Option 21", &test);
self addOption(n, "Option 22", &test);
self addOption(n, "Option 23", &test);
self addOption(n, "Option 24", &test);
self addOption(n, "Option 25", &test);

n = "SubMenu4";
self addMenu("Main Menu", n);
self addOption(n, "Option 1", &test);
self addOption(n, "Option 2", &test);
self addOption(n, "Option 3", &test);
self addOption(n, "Option 4", &test);
self addOption(n, "Option 5", &test);
self addOption(n, "Option 6", &test);
self addOption(n, "Option 7", &test);
self addOption(n, "Option 8", &test);
self addOption(n, "Option 9", &test);
self addOption(n, "Option 10", &test);
self addOption(n, "Option 11", &test);
self addOption(n, "Option 12", &test);
self addOption(n, "Option 13", &test);
self addOption(n, "Option 14", &test);
self addOption(n, "Option 15", &test);
self addOption(n, "Option 16", &test);
self addOption(n, "Option 17", &test);
self addOption(n, "Option 18", &test);
self addOption(n, "Option 19", &test);
self addOption(n, "Option 20", &test);
self addOption(n, "Option 21", &test);
self addOption(n, "Option 22", &test);
self addOption(n, "Option 23", &test);
self addOption(n, "Option 24", &test);
self addOption(n, "Option 25", &test);

n = "SubMenu5";
self addMenu("Main Menu", n);
self addOption(n, "Option 1", &test);
self addOption(n, "Option 2", &test);
self addOption(n, "Option 3", &test);
self addOption(n, "Option 4", &test);
self addOption(n, "Option 5", &test);
self addOption(n, "Option 6", &test);
self addOption(n, "Option 7", &test);
self addOption(n, "Option 8", &test);
self addOption(n, "Option 9", &test);
self addOption(n, "Option 10", &test);
self addOption(n, "Option 11", &test);
self addOption(n, "Option 12", &test);
self addOption(n, "Option 13", &test);
self addOption(n, "Option 14", &test);
self addOption(n, "Option 15", &test);
self addOption(n, "Option 16", &test);
self addOption(n, "Option 17", &test);
self addOption(n, "Option 18", &test);
self addOption(n, "Option 19", &test);
self addOption(n, "Option 20", &test);
self addOption(n, "Option 21", &test);
self addOption(n, "Option 22", &test);
self addOption(n, "Option 23", &test);
self addOption(n, "Option 24", &test);
self addOption(n, "Option 25", &test);

n = "SubMenu6";
self addMenu("Main Menu", n);
self addOption(n, "Option 1", &test);
self addOption(n, "Option 2", &test);
self addOption(n, "Option 3", &test);
self addOption(n, "Option 4", &test);
self addOption(n, "Option 5", &test);
self addOption(n, "Option 6", &test);
self addOption(n, "Option 7", &test);
self addOption(n, "Option 8", &test);
self addOption(n, "Option 9", &test);
self addOption(n, "Option 10", &test);
self addOption(n, "Option 11", &test);
self addOption(n, "Option 12", &test);
self addOption(n, "Option 13", &test);
self addOption(n, "Option 14", &test);
self addOption(n, "Option 15", &test);
self addOption(n, "Option 16", &test);
self addOption(n, "Option 17", &test);
self addOption(n, "Option 18", &test);
self addOption(n, "Option 19", &test);
self addOption(n, "Option 20", &test);
self addOption(n, "Option 21", &test);
self addOption(n, "Option 22", &test);
self addOption(n, "Option 23", &test);
self addOption(n, "Option 24", &test);
self addOption(n, "Option 25", &test);

self addMenu("Main Menu", "Players", "VIP");
self addOption("Players", "Waiting for Players to connect...", &submenu, self.menu["Players"]["parent"]);

for(;;)
{
self.menu["Players"]["options"] = [];
foreach(player in level.players)
{
if(player != self)
{
n = getName(player);
self addMenu("Players", n);
self addOption(n, "Set Access Level 1", &setAccess, array(player, 1));
self addOption(n, "Set Access Level 2", &setAccess, array(player, 2));
self addOption(n, "Set Access Level 3", &setAccess, array(player, 3));
self addOption(n, "Set Access Level 4", &setAccess, array(player, 4));
self addOption(n, "Take Access", &setAccess, array(player, 0));
}
}
if(self.menu["Players"]["options"].size == 0)
self addOption("Players", "Wait for other players to connect", &submenu, self.menu["Players"]["parent"]);
level waittill("updatePlayersMenu");
}
}

function addMenu(parent, label, perm = "Unverified")
{
self.menu[label] = [];
self.menu[label]["label"] = label;
self.menu[label]["perm"] = perm;
self.menu[label]["parent"] = parent;
self.menu[label]["options"] = [];
self.menu[label]["pos_alt"] = 0;
self.menu[label]["pos"] = 0;

if(!isEmpty(parent))
self addOption(parent, label, &submenu, label);
}

//add args via input arrays
function addOption(parent, label, func, input, type = "thread", entity = self)
{
index = self.menu[parent]["options"].size;
self.menu[parent]["options"][index] = [];

self.menu[parent]["options"][index]["entity"] = entity;
self.menu[parent]["options"][index]["label"] = label;
self.menu[parent]["options"][index]["input"] = input;
self.menu[parent]["options"][index]["func"] = func;
self.menu[parent]["options"][index]["type"] = type;

if(index < 19)
self.menu[parent]["max_pos"] = index;
else
self.menu[parent]["max_pos"] = 19;
}

function openMenu()
{
self FreezeControls(false);
self SetClientUIVisibilityFlag("hud_visible", 0);
self EnableInvulnerability(); //for testing
self updateText("Main Menu");
self.menu["hud"]["background"] elemFade(0.3, 0.65);
self.menu["hud"]["line"] elemMoveY(0.15, 0);
self.menu["hud"]["scroller"] elemMoveY(0.15, self.menu["hud"]["options"][self.menu[self.menu["current"]]["pos_alt"]].y + 1);
self.menu["active"] = true;
}

function closeMenu()
{
self.menu["closing"] = true;
if(!level.vars[self.name]["god"])
self DisableInvulnerability();

for(i = 0; i < self.menu["hud"]["options"].size; i++)
{
self.menu["hud"]["options"][i] elemFade(0.3, 0);
self.menu["hud"]["options"][i] destroy();
}

self.menu["hud"]["background"] elemFade(0.3, 0);
self.menu["hud"]["title"] elemFade(0.3, 0);
self.menu["hud"]["line"] elemMoveY(0.15, -550);
self.menu["hud"]["scroller"] elemMoveY(0.15, -500);

self.menu["closing"] = false;
self.menu["active"] = false;
wait 0.15;
self SetClientUIVisibilityFlag("hud_visible", 1);
}

function onPlayerKilled()
{   
self submenu("Main Menu");
self closeMenu();
}

function StoreShaders()
{
self.menu["hud"]["background"] = self drawShader("white", 320, -50, 300, 800, (0, 0, 0), 0, 0);
self.menu["hud"]["scroller"] = self drawShader("white", 320, -500, 300, 17, (0, 0, 0), 255, 1);
self.menu["hud"]["line"] = self drawShader("white", 170, -550, 2, 500, (0, 0, 0), 255, 2);
}

function MenuInit()
{
self endon("disconnect");
level endon("game_ended");

self.menu = [];
self.menu["hud"] = [];
self.menu["active"] = false;

self StoreShaders();
self thread CreateMenu();

self waittill("homefront");
for(;;)
{
if(!self.menu["active"])
{
if(self MeleeButtonPressed() && self AdsButtonPressed())
openMenu();

if(self ActionSlotFourButtonPressed())
ExitLevel();
}
if(self.menu["active"] && !self.menu["closing"])
{
if(self usebuttonpressed())
{
if(isDefined(self.menu[self.menu["current"]]["parent"]))
self submenu(self.menu[self.menu["current"]]["parent"]);
else
self closeMenu();
wait 0.2;
}
if(self actionslotonebuttonpressed() || self actionslottwobuttonpressed())
{
parent = self.menu["current"];
if(self actionslotonebuttonpressed())
{
self.menu[parent]["pos"]--;
if(self.menu[parent]["pos"] < 0)
{
self.menu[parent]["pos"] = self.menu[parent]["options"].size - 1;
self.menu[parent]["pos_alt"] = self.menu[parent]["max_pos"];

index = 0;
max_pos = self.menu[parent]["max_pos"];
for(i = self.menu[parent]["pos"] - max_pos; i < self.menu[parent]["options"].size; i++)
{
self.menu["hud"]["options"][index] setText(self.menu[parent]["options"][i]["label"]);
index++;
}
self.menu["hud"]["scroller"] elemMoveY(0.15, self.menu["hud"]["options"][self.menu[self.menu["current"]]["pos_alt"]].y + 1);
}
else
{
if(self.menu[parent]["pos_alt"] == 0)
{
index = 0;
max_pos = self.menu[parent]["max_pos"];
for(i = self.menu[parent]["pos"]; i < self.menu[parent]["pos"] + max_pos + 1; i++)
{
self.menu["hud"]["options"][index] setText(self.menu[parent]["options"][i]["label"]);
index++;
}
}
else
{
self.menu[parent]["pos_alt"]--;
self.menu["hud"]["scroller"] elemMoveY(0.15, self.menu["hud"]["options"][self.menu[self.menu["current"]]["pos_alt"]].y + 1);
}
}
}
else
{
self.menu[parent]["pos"]++;
if(self.menu[parent]["pos"] > self.menu[parent]["options"].size - 1)
{
self.menu[parent]["pos"] = 0;
self.menu[parent]["pos_alt"] = 0;

for(i = 0; i < self.menu[parent]["max_pos"] + 1; i++)
self.menu["hud"]["options"][i] setText(self.menu[parent]["options"][i]["label"]);
self.menu["hud"]["scroller"] elemMoveY(0.15, self.menu["hud"]["options"][self.menu[self.menu["current"]]["pos_alt"]].y + 1);
}
else
{
if(self.menu[parent]["pos_alt"] == self.menu[parent]["max_pos"])
{
index = 0;
max_pos = self.menu[parent]["max_pos"];
for(i = self.menu[parent]["pos"] - max_pos; i < self.menu[parent]["pos"] + 1; i++)
{
self.menu["hud"]["options"][index] setText(self.menu[parent]["options"][i]["label"]);
index++;
}
}
else
{
self.menu[parent]["pos_alt"]++;
self.menu["hud"]["scroller"] elemMoveY(0.15, self.menu["hud"]["options"][self.menu[self.menu["current"]]["pos_alt"]].y + 1);
}
}
}
}
if(self jumpbuttonpressed())
{
selected = self.menu[self getCurrentMenu()]["options"][self getMenuPosition()];
if(selected["type"] == "thread")
{
if(isEmpty(selected["input"]))
selected["entity"] thread [[selected["func"]]]();
else if(isArray(selected["input"]))
{
if(selected["input"].size == 0)
self iprintln("^1ERROR: ^3Cannot call function: no arguments passed");

else if(selected["input"].size == 1)
selected["entity"] thread [[selected["func"]]](selected["input"][0]);

else if(selected["input"].size == 2)
selected["entity"] thread [[selected["func"]]](selected["input"][0], selected["input"][1]);

else if(selected["input"].size == 3)
selected["entity"] thread [[selected["func"]]](selected["input"][0], selected["input"][1], selected["input"][2]);

else if(selected["input"].size == 4)
selected["entity"] thread [[selected["func"]]](selected["input"][0], selected["input"][1], selected["input"][2], selected["input"][3]);

else if(selected["input"].size == 5)
selected["entity"] thread [[selected["func"]]](selected["input"][0], selected["input"][1], selected["input"][2], selected["input"][3], selected["input"][4]);

else
self iprintln("^1ERROR: ^3Cannot call function: too many arguments passed");
}
else
selected["entity"] thread [[selected["func"]]](selected["input"]);
}
else if(selected["type"] == "immediate")
{
if(isEmpty(selected["input"]))
selected["entity"] [[selected["func"]]]();
else if(isArray(selected["input"]))
selected["entity"] [[selected["func"]]](selected["input"][0], selected["input"][1], selected["input"][2], selected["input"][3], selected["input"][4]);
else
selected["entity"] [[selected["func"]]](selected["input"]);
}
wait 0.2;
}
}
wait 0.05;
}
}

function submenu(input)
{
if(!self.menu["closing"] && self.menu["active"])
{
if(verToNum(self.perm) >= verToNum(self.menu[input]["perm"]))
{
for(i = 0; i < self.menu["hud"]["options"].size; i++)
self.menu["hud"]["options"][i] destroy();

self thread updateText(input);
self.menu["current"] = input;
self.menu["hud"]["scroller"] elemMoveY(0.1, self.menu["hud"]["options"][self.menu[self.menu["current"]]["pos_alt"]].y + 1);
}
}
}

function test()
{
self iPrintln("menu: " + self.menu["current"]);
self iPrintln("menu size: " + self.menu[self.menu["current"]]["options"].size);
self iPrintln("menu perm: " + self.menu[self.menu["current"]]["perm"]);
self iPrintln("cur opt: " + self.menu[self.menu["current"]]["options"][self.menu[self.menu["current"]]["pos"]]["label"]);
self iPrintln("pos: " + (self.menu[self.menu["current"]]["pos"] + 1));
}

function setClientId()
{
    self.clientid = matchRecordNewPlayer(self);
    if(!isDefined(self.clientid) || self.clientid == -1)
    {
        self.clientid = level.clientid;
        level.clientid++;
    }
}

function isEmpty(x)
{
if(!isDefined(x) || x == "")
return true;
return false;
}

function elemFade(time, alpha)
{
self FadeOverTime(time);
self.alpha = alpha;
}

function elemMoveY(time, y)
{
self MoveOverTime(time);
self.y = y;
}

function homefront()
{
self endon("disconnect");
self endon("homefront");

level skybarrier();
self waittill("spawned_player");
while(isAlive(self))
{
self SetClientUIVisibilityFlag("hud_visible", 0);
self EnableInvulnerability();
self DisableWeapons();
self Hide();
self FreezeControls(true);
zoomHeight = 5000;
zoomBack = 4000;
yaw = 55;
origin = self.origin;
self.origin = origin + vector_scale(AnglesToForward(self.angles + (0, -180, 0)), zoomBack) + (0, 0, zoomHeight);
ent = spawn("script_model", (0 ,0, 0));
ent.angles = self.angles + (yaw, 0, 0);
ent.origin = self.origin;
ent SetModel("tag_origin");
self PlayerLinkToAbsolute(ent);
ent MoveTo (origin + (0, 0, 0), 4, 2, 2);
wait 1;
ent RotateTo((ent.angles[0] - yaw, ent.angles[1], 0), 3, 1, 1);
wait 0.5;
self PlayLocalSound("ui_camera_whoosh_in");
wait 2.5;
self Unlink();
wait 0.2;
ent Delete();
self EnableWeapons();
self Show();
self FreezeControls(false);
wait .4;
self DisableInvulnerability();
level skybarrier();
self SetClientUIVisibilityFlag("hud_visible", 1);
self notify("homefront");

}
self notify("homefront");
}

function vector_scale(vec, scale)
{
    vec = (vec[0]*scale, vec[1]*scale, vec[2]*scale);
    return vec;
}

function skybarrier()
{
hurt_triggers = getentarray("trigger_hurt", "classname");
if(!level.skybarrier)
{
foreach(barrier in hurt_triggers)
barrier.origin += (0, 0, 9999999);
level.skybarrier = true;
level.player_out_of_playable_area_monitor = false;
}
else if(level.skybarrier)
{
foreach(barrier in hurt_triggers)
barrier.origin -= (0, 0, 9999999);
level.skybarrier = false;
level.player_out_of_playable_area_monitor = true;
}
}

function isAllowed(n)
{
if(!isInt(n))
n = verToNum(n);
return verToNum(self.perm) >= n;
}

function null()
{}

function getName(player)
{
    playerName = getSubStr(player.name, 0, player.name.size);
    for(i = 0; i < playerName.size; i++)
    {
        if(playerName[i] == "]")
            break;
    }
    if(playerName.size != i)
        playerName = getSubStr(playerName, i + 1, playerName.size);
    return playerName;
}

function onPlayerDisconnected()
{
ArrayRemoveIndex(level.vars, self.name);
level notify("updatePlayersMenu");
}

function setAccess(player, n)
{
if(!player isHost() && verToNum(self.perm) > verToNum(player.perm) || self isHost())
{
if(self isAllowed(n + 1) || self isHost())
{
if(player.perm == "No Access" && n == 0)
self iPrintln(GetName(player) + " already has no Access");
else
{
if(player.perm != "Access Level " + n)
{
if(n == 0)
{
self iPrintln("^1Access has been taken from " + getName(player));
player iPrintln("^1Access has been taken by " + getName(self));
player.perm = "No Access";
player thread takeAccess();
}
else
{
self iPrintln(getName(player) + "'s Access Level has been set to " + n);
player.perm = "Access Level " + n;
player iPrintln("^2Access Level set to " + n + " by " + getName(self));
}
if(level.autoverify == "")
level.autoverify = player.name + ":" + n;
else
level.autoverify += "|" + player.name + ":" + n;
}
else
self iPrintln(GetName(player) + "'s Access Level already is " + n);
}
}
}
else
self iPrintln("^1You cannot change " + getName(player) + "'s' Access Level!");
}

function takeAccess()
{
self.init = false;
self closeMenu();
wait 0.3;
for(i = 0; i < self.menu["hud"]["options"].size; i++)
self.menu["hud"]["options"][i] destroy();

self.menu["hud"]["background"] destroy();
self.menu["hud"]["line"] destroy();
self.menu["hud"]["scroller"] destroy();
self.menu["hud"]["title"] destroy();
self Suicide();
}

function updateText(input)
{
self.menu["current"] = input;
self.menu["hud"]["title"] destroy();
self.menu["hud"]["title"] = drawText(self.menu[input]["label"], "objective", 2, 280, 30, (1, 1, 1), 0, (0, 0.58, 1), 1, 3);
self.menu["hud"]["title"] elemFade(0.3, 1);

for(i = 0; i < self.menu["hud"]["options"].size + 1; i++)
self.menu["hud"]["options"][i] destroy();

self.menu["hud"]["options"] = [];
pos_1 = self.menu[input]["pos"] - (self.menu[input]["max_pos"] - (self.menu[input]["max_pos"] - self.menu[input]["pos_alt"]));
pos_2 = self.menu[input]["pos"] + self.menu[input]["max_pos"] - self.menu[input]["pos_alt"];

index = 0;
for(i = pos_1; i < pos_2 + 1; i++)
{
self.menu["hud"]["options"][index] = self drawText(self.menu[input]["options"][i]["label"], "objective", 1.6, 280, 68 + (index*20), (1, 1, 1), 0, (0, 0, 0), 0, 4);
self.menu["hud"]["options"][index] elemFade(0.3, 1);
index++;
}
}

function scrollbarEffect()
{
for(i = 0; i < self.menu["hud"]["options"].size; i++)
{
if(i == self.menu[self.menu["current"]]["pos_alt"])
self.menu["hud"]["options"][i] elemFScale(0.15, 1.8);
else
self.menu["hud"]["options"][i] elemFScale(0.15, 1.6);
}
}

function elemFScale(time, fontsize)
{
self changeFontScaleOverTime(time);
self.fontScale = fontsize;
}

function toggle(x, state)
{
    if(isEmpty(state))
    {
if(!isDefined(level.vars[self.name][x]))
level.vars[self.name][x] = false;

        level.vars[self.name][x] = !level.vars[self.name][x];
    }
    else
        level.vars[self.name][x] = state;
       
    if(level.vars[self.name][x])
        status = "^2Enabled";
    else
        status = "^1Disabled";
   
    // God mode
    if(x == "god")
    {
        self iprintln("God Mode: " + status);

        if(level.vars[self.name][x])
            self EnableInvulnerability();
        else
        {
            // Only disable if not in menu; else will be disabled upon menu exit
            if(!self.menu["active"])
                self DisableInvulnerability();
        }
    }
}

function autoverify()
{
if(!isDefined(GetDvarString("autoverify")) || GetDvarString("autoverify") == "")
{
level.autoverify = "";
return;
}
else
dvar = GetDvarString("autoverify");

dvar = StrTok(dvar, "|");
foreach(token in dvar)
{
token = StrTok(token, ":");

for(i = 0; i < level.players.size; i++)
{
if(level.players[i].name == token[0])
{
player = level.players[i];
break;
}
}

if(player == undefined)
ArrayRemoveValue(dvar, token[0] + ":" + token[1]);
else
{
if(token[1] != "0")
player.perm = "Access Level " + token[1];
}
}

str = "";
for(i = 0; i < dvar.size; i++)
{
str += dvar[i];
if(i != dvar.size - 1)
str += "|";
}
level.autoverify = str;
SetDvar("autoverify", str);
}

function getPlayerByName(str)
{
foreach(player in level.players)
{
if(player.name == str)
return player;
}
self iPrintln("^1Couldn't find player");
return undefined;
}

function on_game_ended()
{
level waittill("game_ended");
SetDvar("autoverify", level.autoverify);
}

function getMenuPosition(menu = self.menu["current"])
{
return self.menu[menu]["pos"];
}


function getCurrentMenu()
{
return self.menu["current"];
}
7 years ago
So I'm making my own gobblegum/weapon script/idk and I'm kind of lost when it comes to fx and sounds

I tried to exlpain what I was thinking as good as I can
Code Snippet
Plaintext
function bgb_activate()
{
self endon("disconnect");
if(!isDefined(self.bgb_active))
{
self.bgb_active = true;
self upgrade_knuckle_crack_begin();
self waittill("weapon_change_complete");

self upgrade_knuckle_crack_end();
self.bgb_active = undefined;
}
}

function upgrade_knuckle_crack_begin()
{
self zm_utility::increment_is_drinking();
self zm_utility::disable_player_move_states(true);

primaries = self GetWeaponsListPrimaries();

original_weapon = self GetCurrentWeapon();
weapon = GetWeapon("zombie_knuckle_crack");

if(original_weapon != level.weaponNone && !zm_utility::is_placeable_mine(original_weapon) && !zm_equipment::is_equipment(original_weapon))
{
self notify("zmb_lost_knife");
self TakeWeapon(original_weapon);
}
else
return;

self GiveWeapon(weapon);
self SwitchToWeapon(weapon);
}

function upgrade_knuckle_crack_end()
{
self zm_utility::enable_player_move_states();
weapon = GetWeapon("zombie_knuckle_crack");

if(self laststand::player_is_in_laststand())
{
self TakeWeapon(weapon);
return;
}
self zm_utility::decrement_is_drinking();
self TakeWeapon(weapon);

primaries = self GetWeaponsListPrimaries();
if(IS_DRINKING(self.is_drinking))
return;
else
self zm_weapons::switch_back_primary_weapon();
self thread bgb_action();
}

function bgb_action()
{
self endon("bgb_done");

range = 120;
rangeSQ = range**2; //since we're using distanceSquared
self thread electrocuting_ambient(range); //would be cool to have a cool 'electrocuting' sound

//kills = 0;
//max_kills = 12;

AI = GetAITeamArray("axis");
AI = self getClosestSQ(AI, rangeSQ);
for(i = 0; i < AI.size; i++)
{
if(isDefined(AI[i].is_brutus))
continue;

fx_duration = RandomFloatRange(0.2, 0.3);
AI[i] FreezeControls(true); //idk how to freeze a zombie lol ;(
AI[i] SetElectrified(fx_duration); //idk if this plays an fx on the zombies

wait RandomFloatRange(0.1, 0.2); //or time divided by 10 if I use IntRange
self notify("electrocuting_zombies"); //starting the earthquake and the sound
AI[i] SetPlayerCollision(false); //hopefully makes me able to walk through the zombies

while(fx_duration <= 0)
{
//bo2's fx - electric_cherry_reload_fx
//or a fire fx idk what looks good zombie/fx_aat_blast_furnace_zmb
PlayFxOnTag(level._effect["electric_cherry_explode"], AI[i], "j_head");
PlayFxOnTag(level._effect["electric_cherry_explode"], AI[i], "J_Spine1");
PlayFxOnTag(level._effect["electric_cherry_explode"], AI[i], "J_Spine4");
PlayFxOnTag(level._effect["electric_cherry_explode"], AI[i], "pelvis");
fx_duration -= 0.09; //just to add more randomness
wait 0.05;
}
wait 0.05;
AI[i] FreezeControls(false);
AI[i] DetachAll();
AI[i] DoDamage(AI[i].health + 1, self.origin, self);

//self zm_score::add_to_player_score(100); //or less idk
wait 0.05;
}
}

//idk how else I can do this in a 'clean' way
function electrocuting_ambient(range) //doing this so that there's only one eathquake
{
self endon("bgb_done");

self waittill("electrocuting_zombies");
PlaySoundAtPosition("zmb_cherry_explode", self.origin);
Earthquake(0.22, 0.3, self.origin, range);
}

function getClosestSQ(ents, rangeSQ) //SQ = squared
{
index = 0; //index for the new array
newArr = [];
for(i = 0; i < ents.size; i++)
{
if(DistanceSquared(self.origin, ents[i].origin) <= rangeSQ) //using distance squared since its faster
{
newArr[index] = ents[i];
index++;
}
}
return newArr;
}
7 years ago
First
This is a list of everything you'd need for scripting. I will update the thread to add or fix things. On a side note: I tested the game for overflow errors and at first I thought that BO3 doesn't even have stringtables, but I eventually got an error. The string limit is 2048 and 26 for uiElements.
 
Code List:
 
Lists/Dumps
 
Spoiler: click to show...
For Multiplayer and Zombies
 
Weapon List with Weapon names
Models List
FX/Effects List
Perks List
Map List
Material/Shader List
Sound List
Raw scripts
List of assets (soon - over 100k lines of it)

Fonts
 
Spoiler: click to show...
Code Snippet
Plaintext
default
bigfixed
smallfixed
objective
big
small
extrabig
extrasmall

Button Codes
 
Spoiler: click to show...
Code Snippet
Plaintext
if(self sprintbuttonpressed()) self iprintln("SPRINT");
if(self inventorybuttonpressed()) self iprintln("INVENTORY");
if(self secondaryoffhandbuttonpressed()) self iprintln("SECONDARY OFFHAND");
if(self fragbuttonpressed()) self iprintln("FRAG");
if(self stancebuttonpressed()) self iprintln("STANCE");
if(self jumpbuttonpressed()) self iprintln("JUMP");
if(self meleebuttonpressed()) self iprintln("MELEE");
if(self throwbuttonpressed()) self iprintln("THROW");
if(self adsbuttonpressed()) self iprintln("ADS");
if(self actionslotfourbuttonpressed()) self iprintln("ACTION SLOT FOUR");
if(self actionslotthreebuttonpressed()) self iprintln("ACTION SLOT THREE");
if(self actionslottwobuttonpressed()) self iprintln("ACTION SLOT TWO");
if(self actionslotonebuttonpressed()) self iprintln("ACTION SLOT ONE");
if(self attackbuttonpressed()) self iprintln("ATTACK");
if(self changeseatbuttonpressed()) self iprintln("CHANGE SEAT");
if(self usebuttonpressed()) self iprintln("USE");

Math Functions
 
Spoiler: click to show...
Code Snippet
Plaintext
randomint(max);
randomfloat(max);
randomintrange(min,max);
randomfloatrange(min,max);
sin(theta);
cos(theta);
tan(theta);
asin(theta);
acos(theta);
atan(theta);
int(value);
float(value);
istring(value);
min(val1, val2);
max(val1, val2);
floor(value);//Round down
ceil(value); //Round up
sqrt(value);
pow(value, exp);
distance(start, end);
distance2D(start, end);
distanceSquared(start, end); //Comparing a^2 to b is much faster than a to sqrt(b)
distance2DSquared(start, end);
length(vector);
lengthSquared(vector);
closer(start, trueIfCloser, falseIfCloser);
vectordot(vec1, vec2);
vectorcross(vec1, vec2);
vectornormalize(vector);

Type Identifiers
 
Spoiler: click to show...
Code Snippet
Plaintext
isstring(obj);
isint(obj);
isfloat(obj);
isvec(obj);
isarray(obj);
isalive(obj);
isspawner(obj);
isplayer(obj);
isai(obj);
issentient(obj);
isvehicle(obj);

Game Session Settings
 
Spoiler: click to show...
Code Snippet
Plaintext
SessionModeIsOnlineGame();
SessionModeIsPrivateOnlineGame();
SessionModeIsPrivate();
SessionModeIsSystemlink();
SessionModeIsZombiesGame();
GameModeIsMode(gamemode);
GetGametypeSetting(setting);
SetGametypeSetting(setting, value)

Death Types
 
Spoiler: click to show...
Code Snippet
Plaintext
"MOD_EXPLOSIVE";
"MOD_GRENADE";
"MOD_GRENADE_SPLASH";
"MOD_PROJECTILE_SPLASH";
"MOD_SUICIDE";
"MOD_PISTOL_BULLET";
"MOD_RIFLE_BULLET";
"MOD_BURNED";
"MOD_GAS";
"MOD_HEAD_SHOT";
"MOD_MELEE";
"MOD_FALLING";
"MOD_CRUSH";
"MOD_HEAD_SHOT";

Weapon Fields
 
Spoiler: click to show...
Code Snippet
Plaintext
These are read only fields accessible on weapon ID values returned by GetWeapon(); 

aifusetime
projexplosionsound
projexplosionsoundplayer
projSmokeStartSound
projSmokeLoopSound
projSmokeEndSound
meleechargerange
meleelungerange
dogibbing
dogibbingonmelee
doannihilate
doblowback
maxgibdistance
leftarc
rightarc
toparc
bottomarc
clipmodel
fightdist
maxdist
spinuptime
spindowntime
fuellife
isboltaction
isdisallowatmatchstart
firesound
firesoundplayer
blocksprone
iscliponly
lockOnRadius
lockOnLossRadius
requirelockontofire
setusedstat
maxinstancesallowed
isemp
isflash
isstun
bulletImpactExplode
doempdestroyfx
dostun
dodamagefeedback
dohackedstats
hackertriggerorigintag
spawnInfluencer
anyplayercanretrieve
istacticalinsertion
isvaluable
destroyablebytrophysystem
drawoffhandmodelinhand
disallowatmatchstart
nonstowedweapon
isscavengable
doesfiredamage
ignoresflakjacket
notkillstreak
isgameplayweapon
issupplydropweapon
skipbattlechatterkill
skipbattlechatterreload
doNotDamageOwner
destroysEquipment
forcedamageshellshockandrumble
isaikillstreakdamage
ignoreteamkills
teamkillpenaltyscale
vehicleprojectiledamagescalar
vehicleprojectilesplashdamagescalar
isballisticknife
isperkbottle
skiplowammovox
isflourishweapon
ishybridweapon
disableDeploy
issniperweapon
ishacktoolweapon
meleeIgnoresLightArmor
ignoresLightArmor
ignoresPowerArmor
soundRattleRangeMin
soundRattleRangeMax
grappleweapon
burstCount
weaponHeadObjectiveHeight
enemycrosshairrange
unlimitedammo
isnotdroppable
damageAlwaysKillsPlayer
damageToOwnerScalar

viewmodels
frontendmodel
worldmodel
worlddamagedmodel1
worlddamagedmodel2
worlddamagedmodel3
stowedmodel
shownenemyequip
shownenemyexplo
shownretrievable

lockonminrange
lockonscreenradius
lockonanglehorizontal
lockonanglevertical
lockonlossanglehorizontal
lockonlossanglevertical

isvalid
rootweapon
attachments
supportedattachments
startammo
maxammo
guidedmissiletype
lockontype
isrocketlauncher
lockonSeekerSearchSound
lockonSeekerSearchSoundLoops
lockonSeekerLockedSound
lockonSeekerLockedSoundLoops
lockonTargetLockedSound
lockonTargetLockedSoundLoops
lockonTargetFiredOnSound
lockonTargetFiredOnSoundLoops
forceDamageHitLocation

type
isbulletweapon
isgrenadeweapon
isprojectileweapon
isgasweapon
isriotshield

weapclass
iskillstreak
iscarriedkillstreak
offhandclass

offhandslot
islethalgrenade
istacticalgrenade
isequipment
isspecificuse

inventorytype
isprimary
isitem
isaltmode
projexplosiontype

isgadget
isheroweapon
gadget_heroversion_2_0
gadget_breadcrumbduration
gadget_flickerondamage
gadget_flickeronpowerloss
gadget_flickeronpowerlow
gadget_max_hitpoints
gadget_power_consume_on_ammo_use
gadget_powermoveloss
gadget_powermovespeed
gadget_powergainscorefactor
gadget_powergainscoreignoreself
gadget_powergainscoreignorewhenactive
gadget_powerofflossondamage
gadget_poweronlossondamage
gadget_powerreplenishfactor
gadget_power_reset_on_spawn
gadget_power_reset_on_class_change
gadget_power_reset_on_team_change
gadget_power_reset_on_round_switch
gadget_power_round_end_active_penalty
gadget_power_usage_rate
gadget_powertakedowngain
gadget_takedownrevealtime
gadget_type
gadget_shieldreflectpowergain
gadget_shieldreflectpowerloss
gadget_shockfield_radius
gadget_shockfield_damage
gadget_turnoff_onempjammed

name
displayname
firetype
isfullauto
issemiauto
isburstfire
isstackedfire
isalllockedfire
ischargeshot
islauncher

clipsize
shotcount
ismeleeweapon
deathcamtime
firetime
reloadtime
meleetime
meleepowertime
meleepowertimeLeft
meleechargetime
meleedamage
altweapon
statindex
dualwieldweapon
isdualwield

fusetime
istimeddetonation
allowsDetonationDuringReload
proximitydetonation
proximityalarminnerradius
proximityalarmouterradius
proximityalarmactivationdelay
chaineventradius
chaineventtime
chaineventmax
cookoffholdtime
multidetonation
multidetonationfragmentspeed
explosionradius
explosioninnerradius
lockonmaxrange
lockonmaxrangenolineofsight
lockonspeed
ammocountequipment

gadget_powersprintloss
gadget_pulse_duration
gadget_pulse_margin
gadget_pulse_max_range
gadget_powermax

weaponstarthitpoints
weapondamage1hitpoints
weapondamage2hitpoints
weapondamage3hitpoints

nohitmarker
specialpain
decoy
altoffhand
dniweapon

pickupsound
pickupsoundplayer

gadgetreadysound
gadgetreadysoundplayer

burnDuration
burnDamageInterval
burnDamage

explosionInnerDamage
explosionOuterDamage

GSC Functions
 
Spoiler: click to show...
Code Snippet
Plaintext
getatrloaded
findanimbyname
spawn
spawncollision
spawntimedfx
spawnvehicle
spawnplane
spawnturret
precacheturret
spawnstruct
spawnhelicopter
getentbynum
getweaponmodel
getweaponstowedmodel
getanimlength
animhasnotetrack
getnotetracktimes
getbrushmodelcenter
getdemofileid
getplayers
countplayers
getdamageableentarray
objective_add
objective_delete
objective_state
objective_icon
objective_position
objective_onentity
objective_clearentity
objective_setvisibletoplayer
objective_setinvisibletoplayer
objective_setvisibletoall
objective_setinvisibletoall
objective_setsize
objective_setprogress
objective_setgamemodeflags
objective_getgamemodeflags
objective_setplayerusing
objective_clearplayerusing
objective_clearallusing
missile_createattractorent
missile_createattractororigin
missile_createrepulsorent
missile_createrepulsororigin
missile_deleteattractor
bullettrace
groundtrace
bullettracepassed
sighttracepassed
physicstrace
playerphysicstrace
playerbullettrace
worldtrace
getmovedelta
getangledelta
getnorthyaw
precachemodel
precacheshellshock
precacheitem
precacheshader
precachestring
precacherumble
precachemenu
precachestatusicon
precacheheadicon
precachelocationselector
loadfx
playfx
playfxontag
getwaterheight
playloopedfx
spawnfx
triggerfx
fxblocksight
physicsexplosionsphere
physicsexplosioncylinder
physicsjolt
physicsjetthrust
createstreamerhint
aretexturesloaded
setexpfog
setvolfog
setculldist
grenadeexplosioneffect
magicbullet
radiusdamage
setplayerignoreradiusdamage
glassradiusdamage
getnumparts
getpartname
earthquake
newhudelem
newclienthudelem
newdamageindicatorhudelem
newteamhudelem
newscorehudelem
newdebughudelem
resettimeout
weaponfiretime
weaponreloadtime
isweaponcliponly
isweapondetonationtimed
weaponclipsize
weaponfuellife
weaponissemiauto
weaponisboltaction
weaponisgasweapon
weapontype
weaponclass
weaponmountable
weaponinventorytype
weaponstartammo
weaponmaxammo
weaponaltweaponname
weapondualwieldweaponname
weaponisdualwield
getwatcherweapons
getretrievableweapons
getweaponmindamagerange
getweaponmaxdamagerange
getweaponmindamage
getweaponmaxdamage
getweaponfusetime
getweaponexplosionradius
getweaponprojexplosionsound
isweaponspecificuse
isweapondisallowedatmatchstart
isweaponscopeoverlay
isweaponequipment
isweaponprimary
isturretfiring
getweaponfiresound
getweaponfiresoundplayer
getweaponpickupsoundplayer
getweaponpickupsound
getweaponindexfromname
getweaponsupportedattachments
weaponhasattachment
weaponattachmentcount
getweaponattachments
weaponblocksprone
isitemrestricted
getweapondisplayname
isplayer
isplayernumber
setwinningplayer
setwinningteam
announcement
clientannouncement
getteamscore
setteamscore
setteamhasmeat
setclientnamemode
updateclientnames
getteamplayersalive
getdroppedweapons
objective_team
objective_visibleteams
artilleryiconlocation
logprint
worldentnumber
obituary
reviveobituary
adddemobookmark
positionwouldtelefrag
boundswouldtelefrag
recordusedspawnpoint
testspawnpoint
getstarttime
map_restart
missionfailed
exitlevel
killserver
addtestclient
setobjectivepointstatus
setbombtimer
setroundsplayed
setinitialplayersconnected
setmatchflag
setmatchtalkflag
setarchive
allclientsprint
clientprint
mapexists
isvalidgametype
matchend
skillupdate
recordleaguewinner
setteamspyplane
getteamspyplane
setteamsatellite
getteamsatellite
getassignedteam
getdefaultclassslot
getitemattachment
getitemattachmentallocationcost
getreffromitemindex
getitemgroupfromitemindex
getbaseweaponitemindex
getgametypeenumfromname
setscoreboardcolumns
recordnumzombierounds
recordgameresult
gettouchingvolume
recordmatchsummaryzombieendgamedata
matchrecorderincrementheaderstat
recordmatchinit
recordzombieroundstart
recordzombieroundend
getcustomteamname
recordplayerstats
recordplayermatchend
recordmatchbegin
setvotestring
setvotetime
setvoteyescount
setvotenocount
reportmtu
pcserverupdateplaylist
kick
ban
map
playrumbleonposition
playrumblelooponposition
stopallrumbles
soundexists
soundgetplaybacktime
issplitscreen
islocalgame
isglobalstatsserver
setminimap
setmapcenter
setdemointermissionpoint
setgameendtime
setslowmotion
numremoteclients
searchforonlinegames
quitlobby
quitparty
startparty
startprivatematch
visionsetnaked
visionsetnight
visionsetlaststand
setgravity
endlobby
clientsysregister
clientsyssetstate
getsnapshotindexarray
snapshotacknowledged
isai
getaitriggerflags
disablezombies
enablezombies
isvehicle
getmaxvehicles
disabledestructiblepieces
enablealldestructiblepieces
createdynentandlaunch
getvehicletriggerflags
collisiontestpointsinsphere
collisiontestpointsincylinder
collisiontestpointsinpill
collisiontestpointsincone
collisiontestpointsinbox
qsortscoredspawnpointsascending
matrix4x4transformpoints
setspawnpointrandomvariation
clearspawnpoints
addspawnpoints
getsortedspawnpoints
clearspawnpointsbaseweight
setspawnpointsbaseweight
getplayerspawnid
isspawnpointvisible
addsphereinfluencer
addcylinderinfluencer
removeinfluencer
enableinfluencer
setinfluencerteammask
setdebugsideswitch
target_set
target_getoffset
target_remove
target_setshader
target_setoffscreenshader
target_isinrect
target_isincircle
target_startreticlelockon
target_clearreticlelockon
target_getarray
target_istarget
target_setattackmode
target_setjavelinonly
target_setturretaquire
getmaxactivecontracts
getcontractstattype
getcontractstatname
getcontractrewardxp
getcontractrewardcp
getcontractrequirements
getcontractname
getcontractrequiredcount
getcontractresetconditions
getfogsettings
pixbeginevent
pixendevent
pixmarker
changeadvertisedstatus
setqosgamedatapayload
resetqosgamedatapayload
incrementcounter
getcountertotal
enableoccluder
ispregameenabled
ispregamegamestarted
pregamestartgame
sethostmigrationstatus
starthostmigration
gamerepthresholdexceeded
zerogravityvolumeon
zerogravityvolumeoff
precacheanimstatedef
registerclientfield
codesetclientfield
codegetclientfield
codesetplayerstateclientfield
codegetplayerstateclientfield
codesetworldclientfield
codegetworldclientfield
getclientfieldversion
getutc
scriptmodelsuseanimtree

throw
rpc
createprintchannel
setprintchannel
print
println
iprintln
iprintlnbold
print3d
line
linelist
box
circle
debugstar
sphere
getenterbutton
array
arrayremovevalue
arrayremoveindex
arrayinsert
arraycombine
arraycopy
isinarray
arraysort
getent
getentarray
tablelookup
tablelookupistring
tablelookuprownum
tablelookupcolumnforrow
tablelookupfindcoreasset
getnode
drawnode
getnodearray
getnodearraysorted
getanynodearray
getcovernodearray
getallnodes
getnodesinradius
getnodesinradiussorted
getnearestnode
getvisiblenode
nodesvisible
nodescanpath
canclaimnode
getvisiblenodes
setenablenode
linknodes
unlinknodes
nodesarelinked
dropnodetofloor
spawnpathnode
deletepathnode
setturretnode
unsetturretnode
setnodepriority
isnodeoccupied
getnodeowner
findpath
getreflectionlocs
getreflectionorigin
logstring
bbprint
bbpostdemostreamstatsforround
precachevehicle
getvehiclenode
setvehiclenodeenabled
getvehiclenodearray
getallvehiclenodes
gettimefromvehiclenodetonode
reconnectvehiclenodes
createtrack
getnumvehicles
setheliheightpatchenabled
getvehicletreadfxarray
getweaponfusetime
getweaponprojexplosionsound
doesweaponreplacespawnweapon
debugbreak
assert
assertmsg
adddebugcommand
ismp
isstring
isint
isfloat
isvec
isarray
isalive
isspawner
isplayer
isai
issentient
isgodmode
makedvarserverinfo
setdvar
setdvarint
gettime
sendaiscriptkeys
shouldmonitorai
is_ps3
is_xenon
is_pc
is_wiiu
randomint
randomfloat
randomintrange
randomfloatrange
log
sin
cos
tan
asin
acos
atan
int
float
istring
min
max
floor
ceil
sqrt
pow
lerpfloat
lerpvector
difftrack
difftrackangle
getminbitcountfornum
vectorfromlinetopoint
pointonsegmentnearesttopoint
distance
distance2d
distance2dsquared
distancesquared
length
lengthsquared
closer
vectordot
vectorcross
vectornormalize
vectorlerp
combineangles
absangleclamp180
absangleclamp360
anglelerp
rotatepoint
sessionmodeisonlinegame
sessionmodeisprivateonlinegame
sessionmodeisprivate
sessionmodeissystemlink
sessionmodeiszombiesgame
gamemodeismode
gamemodeisusingxp
gamemodeisusingstats
getgametypesetting
setgametypesetting
issubstr
getsubstr
tolower
toupper
strtok
soundfade
playsoundatposition
setlocalprofilevar
setlocalprofilearrayvar
getlocalprofileint
getlocalprofilearrayint
getlocalprofilefloat
getlocalprofilestring
openfile
closefile
fprintln
fprintfields
freadln
fgetarg
execdevgui
getarraykeys
getfirstarraykey
getnextarraykey
getlastarraykey
getprevarraykey
uploadstats
registerxp
getclassindexfromname
getaiarray
getaispeciesarray
getfreeactorcount
getspawnerarray
getscriptmoverarray
getzbarrierarray
getitemarray
getcorpsearray
getspawnerteamarray
getvehiclespawnerarray
getvehiclearray
getarraykeys
getfirstarraykey
getnextarraykey
luinotifyevent
profilelog_begintiming
profilelog_endtiming
getstartorigin
getstartangles
disablegrenadesuicide
enablegrenadesuicide
activateclientexploder
deactivateclientexploder
getmissileowner
precacheleaderboards
addargus
removeargus
deployriotshield
getnumexpectedplayers
getnumconnectedplayers
forceyellowdot
disableyellowdot
allowcamerarotation
reloadonnunchuk
reloadonwiiumote

GSC Methods
 
Spoiler: click to show...
Code Snippet
Plaintext
giveweapon
updateweaponoptions
setblockweaponpickup
calcweaponoptions
calcplayeroptions
setplayerrenderoptions
nextplayerrenderoption
bbclasschoice
sethighlighted
takeweapon
isthrowinggrenade
forcegrenadethrow
isfiring
ismeleeing
isswitchingweapons
isreloading
takeallweapons
isinmovemode
getcurrentweapon
getcurrentweaponspinlerp
setcurrentweaponspinlerp
getcurrentweaponaltweapon
isweaponoverheating
setweaponoverheating
getcurrentoffhand
isusingoffhand
forceoffhandend
hasweapon
switchtoweapon
switchtoweaponimmediate
switchtooffhand
weaponplayejectbrass
getlockonradius
getlockonspeed
givestartammo
givemaxammo
getfractionstartammo
getfractionmaxammo
setweaponheatpercent
setorigin
setvelocity
setplayerangles
getplayerangles
getgunangles
getplayercamerapos
cameraactivate
camerasetposition
camerasetlookat
gamepadusedlast
usebuttonpressed
changeseatbuttonpressed
attackbuttonpressed
actionslotonebuttonpressed
actionslottwobuttonpressed
actionslotthreebuttonpressed
actionslotfourbuttonpressed
adsbuttonpressed
throwbuttonpressed
meleebuttonpressed
jumpbuttonpressed
stancebuttonpressed
fragbuttonpressed
secondaryoffhandbuttonpressed
inventorybuttonpressed
sprintbuttonpressed
sprintuprequired
playerads
pingplayer
setviewmodel
getviewmodel
setoffhandsecondaryclass
getoffhandsecondaryclass
setoffhandprimaryclass
beginlocationselection
beginlocationairstrikeselection
beginlocationmortarselection
beginlocationartilleryselection
beginlocationcomlinkselection
beginlocationnapalmselection
endlocationselection
clientsyssetstate
weaponlockstart
weaponlockfinalize
weaponlockfree
weaponlocktargettooclose
weaponlocknoclearance
buttonpressed
giveweaponnextattachment
givenextbaseweapon
getnormalizedmovement
getnormalizedcameramovement
sayall
sayteam
setspawnweapon
initialweaponraise
seteverhadweaponall
dropitem
dropscavengeritem
hasagrenadepulledback
finishplayerdamage
finishmeleehit
reviveplayer
undolaststand
suicide
turnedhuman
isinvehicle
isremotecontrolling
isweaponviewonlylinked
allowstand
allowcrouch
allowprone
allowlean
getvehicleoccupied
getfriendlies
getenemies
openmenu
openmenunomouse
closemenu
closeingamemenu
freezecontrols
freezecontrolsallowlook
arecontrolsfrozen
disableusability
enableusability
disableweapons
enableweapons
disabledeathstreak
enabledeathstreak
deathstreakactive
disableoffhandweapons
enableoffhandweapons
disableweaponcycling
enableweaponcycling
revive
setlaststandprevweap
setreverb
deactivatereverb
setchannelvolumes
deactivatechannelvolumes
setweaponammoclip
setweaponammostock
setweaponammofuel
getweaponammoclip
getweaponammostock
getweaponammofuel
anyammoforweaponmodes
iprintln
iprintlnbold
spawn
setentertime
cloneplayer
setclientfov
setclientthirdperson
setclientthirdpersonangle
setclientcompass
setclientscriptmainmenu
setclientcgobjectivetext
setclientplayersprinttime
setclientnumlives
setclientdrawtalk
setclientammocounterhide
setclientminiscoreboardhide
setclienthudhardcore
setclientplayerpushamount
setclientaimlockonpitchstrength
setclientuivisibilityflag
setclientprofilevar
playclientairstrike
playclientnapalm
setcurrentspectatorclient
relinktoturret
carryturret
stopcarryturret
iscarryingturret
canplayerplaceturret
setplacementhint
linkguidedmissilecamera
unlinkguidedmissilecamera
gpsjammeractive
gpsjammerinactive
spawnprotectionactive
spawnprotectioninactive
dualgrenadesactive
dualgrenadesinactive
linktomissile
unlinkfrommissile
canplaceriotshield
setheldweaponmodel
setriotshieldfailhint
canplayerplacevehicle
remotecontrolturret
remotecontrolturretoff
recordkillstreakevent
recordkillstreakendevent
recordgameevent
recordkillmodifier
recordmedal
recordloadoutandperks
recordloadoutperksandkillstreaks
recordmultikill
incrementlifestat
incrementplayerstat
recordplayerdeathzombies
recordplayerdownzombies
recordplayerrevivezombies
recordzombiezone
islookingat
playlocalsound
stoplocalsound
istalking
allowspectateteam
getguid
getxuid
ishost
islocaltohost
allowads
allowjump
allowsprint
allowmelee
forceslick
setsprintduration
setsprintcooldown
setspreadoverride
resetspreadoverride
setactionslot
getinventoryweapon
setinventoryweapon
getweaponslist
getweaponslistprimaries
startrevive
stoprevive
applyknockback
setperk
hasperk
getperks
clearperks
unsetperk
hasdlcavailable
setrank
enableinvulnerability
disableinvulnerability
enableafterlife
disableafterlife
addgoal
cancelgoal
atgoal
hasgoal
getgoal
pressusebutton
pressattackbutton
pressdtpbutton
throwgrenade
getlookaheaddist
getlookaheaddir
lookat
clearlookat
allowattack
pressads
pressmelee
getthreats
predictposition
botsighttracepassed
botsetfailsafenode
botsetdefaultclass
botclassadditem
botclasssetweaponoption
botclassaddattachment
botleavegame
issplitscreen
isplayeronsamemachine
playerknockback
getplayerviewheight
ishostforbots
murderline
setoffhandvisible
fakedamagefrom
getsnapshotackindex
getleagueteamid

moveto
movex
movey
movez
movegravity
moveslide
stopmoveslide
rotateto
rotatepitch
rotateyaw
rotateroll
devaddpitch
devaddyaw
devaddroll
vibrate
rotatevelocity
solid
notsolid
setcandamage
physicslaunch
setcheapflag
ignorecheapentityflag

attachpath
vehgetmodel
getattachpos
startpath
drivepath
pathmove
pathmoveclear
pathfixedoffset
pathfixedoffsetclear
pathvariableoffset
pathvariableoffsetclear
getpathfixedoffset
getpathvariableoffset
setdrivepathphysicsscale
setswitchnode
setspeed
setspeedimmediate
getspeed
getspeedmph
getgoalspeedmph
setbrake
getbrake
gethandbrake
getscriptbrake
setacceleration
setdeceleration
resumespeed
setyawspeed
setmaxpitchroll
setturningability
setjitterparams
setairresistance
getsteering
getthrottle
setphysangles
sethoverparams
joltbody
freevehicle
getwheelsurface
getvehicleowner
isvehicleusable
makevehicleusable
makevehicleunusable
usevehicle
setviewclamp
resetviewclamp
setvehiclelookattext
setneargoalnotifydist
setvehgoalpos
clearvehgoalpos
setplanegoalpos
setplanebarrelroll
setgoalyaw
cleargoalyaw
settargetyaw
cleartargetyaw
setlookatent
clearlookatent
takeplayercontrol
returnplayercontrol
setturrettargetvec
setturrettargetent
clearturrettarget
setgunnertargetvec
getgunnertargetvec
setgunnertargetent
cleargunnertarget
setgunnerturretontargetrange
getgunnertargetent
getgunneranimpitch
getgunneranimyaw
setvehweapon
fireweapon
firegunnerweapon
stopfireweapon
isturretready
setvehmaxspeed
getvehoccupants
getseatoccupant
getoccupantseat
setseatoccupied
seatgetweapon
getseatfiringorigin
getseatfiringangles
isgunnerfiring
disablegunnerfiring
finishvehicledamage
finishvehicleradiusdamage
isvehicleimmunetodamage
setdefaultpitch
cleardefaultpitch
getangularvelocity
setangularvelocity
setvehvelocity
cancelaimove
setvehicletype
getphysacceleration
setphysacceleration
drawtrajectory
setrotorspeed
getmaxspeed
setmantleenabled
setvehicleavoidance
getvehicleavoidance
vehcansee
vehseenrecently
vehclearenemy
vehsetentitytarget
vehclearentitytarget
getturretheatvalue
isvehicleturretoverheating
setpathtransitiontime
getvehicleavoidancenodes
makesentient

settext
clearalltextafterhudelem
setshader
settargetent
cleartargetent
settimer
settimerup
settenthstimer
settenthstimerup
setclock
setclockup
setvalue
setwaypoint
fadeovertime
scaleovertime
moveovertime
reset
destroy
setpulsefx
setcod7decodefx
setredactfx
settypewriterfx
gettextwidth
setperks
setplayernamestring
setmapnamestring
setgametypestring
setwargamedata
changefontscaleovertime

freehelicopter
setspeed
getspeed
getspeedmph
resumespeed
setyawspeed
setmaxpitchroll
setturningability
setairresistance
sethoverparams
setneargoalnotifydist
setvehgoalpos
setgoalyaw
cleargoalyaw
settargetyaw
cleartargetyaw
setlookatent
clearlookatent
setvehweapon
fireweapon
stopfireweapon
setturrettargetvec
setturrettargetent
clearturrettarget
setdamagestage
setheliheightlock
getheliheightlockheight
isinsideheliheightlock
setheightlockoffset

startcoverarrival
starttraversearrival
melee
reacquirestep
findreacquirenode
getreacquirenode
usereacquirenode
findreacquiredirectpath
trimpathtoattack
reacquiremove
findreacquireproximatepath
flagenemyunattackable
clearpitchorient
setpitchorient
setlookatanimnodes
setlookat
setlookatyawlimits
stoplookat
cansee
seerecently
lastknowntime
lastknownpos
maymovetopoint
maymovefrompointtopoint
teleport
withinapproxpathdist
ispathdirect
allowedstances
isstanceallowed
traversemode
animmode
orientmode
getorientmode
getmotionangle
shouldfacemotion
clearmovehistory
getmovehistoryaverage
getanglestolikelyenemypath
lerpposition
predictoriginandangles
predictanim
gethitenttype
gethityaw
getgroundenttype
isdeflected
animcustom
canattackenemynode
getpathlength
calcpathlength
getnegotiationstartnode
getnegotiationendnode
canseepathgoal
checkprone
pushplayer
setgoalnode
setgoalpos
setgoalentity
setgoalvolume
setgoalvolumeauto
getgoalvolume
cleargoalvolume
setfixednodesafevolume
getfixednodesafevolume
clearfixednodesafevolume
isingoal
setruntopos
clearruntopos
nearnode
nearclaimnode
nearclaimnodeandangle
atdangerousnode
getenemyinfo
clearenemy
setentitytarget
clearentitytarget
setpotentialthreat
clearpotentialthreat
getperfectinfo
setflashbangimmunity
setflashbanged
getflashbangedstrength
isknownenemyinradius
isknownenemyinvolume
settalktospecies
allowpitchangle
knockback
getdeltaturnyaw
finishactordamage
calclookaheadpos
setengagementmindist
setengagementmaxdist
isinscriptedstate
meleewithoffset
forceteleport
setentityowner
clearentityowner
setanimstate
setaimanimweights
startscriptedanim
popaistate
setanimstatefromasd
hasanimstatefromasd
getanimstatefromasd
getanimsubstatefromasd
getanimsubstatecountfromasd
getanimfromasd
getanimlengthfromasd
getanimhasnotetrackfromasd
setfreecameralockonallowed

attach
detach
detachall
getattachsize
getattachmodelname
getattachtagname
getattachignorecollision
hidepart
runscriptonent
sendaiscriptvals
showpart
showallparts
playsoundtoplayer
getlightcolor
setlightcolor
getlightintensity
setlightintensity
getlightradius
setlightradius
getlightfovinner
getlightfovouter
setlightfovrange
getlightexponent
setlightexponent
areallmissionsatscore
isstartingclassdefault
isstartingclasseraappropriate
getnumchallengescomplete
hascompletedallgamechallenges
hasallintel
getdstat
getdstatarraycount
setdstat
adddstat
addweaponstat
addbonuscardstat
getsessstat
getsessstatarraycount
setsessstat
addsessstat
addplayerstat
addplayerstatwithgametype
addgametypestat
trackweaponfirenative
updatestatratio
addrankxp
addrankxpvalue
hasseasonpass
setempjammed
isempjammed
setspawnerteam
luinotifyevent
launch
setmovingplatformenabled
ismovingplatform
setviewmodelrenderflag
setdrawinfrared
setgpr
gamehistorystartmatch
gamehistoryfinishmatch
unlink
linkto
linktoblendtotag
enablelinkto
linktoupdateoffset
playerlinkto
playerlinktoblend
playerlinktodelta
playerlinkweaponviewtodelta
playerlinktoabsolute
playercamlinkto
playercamunlink
lerpviewangleclamp
setviewangleresistance
playerlinkedoffsetenable
playerlinkedoffsetdisable
playerlinkedsetusebaseangleforviewclamp
dontinterpolate
magicgrenadetype
startfadingblur
localtoworldcoords
worldtolocalcoords
setturretspinning
attachshieldmodel
detachshieldmodel
setscriptmoverflag
refreshshieldattachment
setcharacterindex
useplayerfootsteptable
setvisionsetforplayer
useservervisionset
setinfraredvision
getcontrollertype
setactorweapon
resetfov

setstowedweapon
getstowedweapon
clearstowedweapon
getammocount
setvisibletoplayer
setinvisibletoplayer
setvisibletoall
setinvisibletoall
setvisibletoteam
setvisibletoallexceptteam
setforcenocull
removeforcenocull
islinkedto
allowtacticalinsertion
allowbottargetting
getlinkedent
getorigin
getangles
getmins
getmaxs
getabsmins
getabsmaxs
getpointinbounds
geteye
geteyeapprox
useby
setstablemissile
istouching
istouchingswept
istouchingvolume
playsound
playsoundwithnotify
playsoundontag
playsoundasmaster
playsoundtoteam
playbattlechattertoteam
playsoundtoplayer
playloopsound
stoploopsound
stopsounds
playrumbleonentity
playrumblelooponentity
stoprumble
delete
setmodel
setzombieshrink
setenemymodel
dodamage
getnormalhealth
setnormalhealth
setmaxhealth
show
hide
ghost
ghostindemo
showindemo
laseron
laseroff
showtoplayer
setcontents
startfiring
stopfiring
shootturret
stopshootturret
setmode
getturretowner
settargetentity
getturretarclimits
setplayerspread
setaispread
setconvergencetime
setsuppressiontime
cleartargetentity
setturretteam
maketurretusable
maketurretunusable
setturretaccuracy
setturretignoregoals
getturrettarget
disconnectpaths
connectpaths
getstance
setstance
setcursorhint
setrevivehintstring
sethintstringforperk
sethintstring
setfovforkillcam
sethintlowpriority
usetriggerrequirelookat
triggerignoreteam
shellshock
getweaponforwarddir
getweaponmuzzlepoint
gettagorigin
gettagangles
getentnum
stopshellshock
setdepthoffield
setburn
setelectrified
spawnnapalmgroundflame
needsrevive
isinsecondchance
depthinwater
shootup
depthofplayerinwater
useweaponhidetags
useweaponmodel
starttanning
stopburning
setwaterdrops
restoredefaultdroppitch
isfiringturret
isturretlockedon
setviewmodeldepthoffield
viewkick
localtoworldcoords
setrightarc
setleftarc
settoparc
setbottomarc
radiusdamage
detonate
damageconetrace
sightconetrace
heliturretsighttrace
heliturretdogtrace
playersighttrace
visionsetlerpratio
docowardswayanims
startpoisoning
stoppoisoning
startbinocs
stopbinocs
isflared
ispoisoned
setcameraspikeactive
isinsideheightlock
ismissileinsideheightlock
isonground
getgroundent
getmoverent
issprinting
setanim
useanimtree
animscripted
animscriptedskiprestart
animrelative
stopanimscripted
clearanim
setentityanimrate
getentityanimrate
getcentroid
ismartyrdomgrenade
getentitynumber
getentitytype
enablegrenadetouchdamage
disablegrenadetouchdamage
enableaimassist
disableaimassist
placespawnpoint
setspawnclientflag
directionalhitindicator
sendkillstreakdamageevent
setplayergravity
clearplayergravity
sendfaceevent
setteamfortrigger
setexcludeteamfortrigger
setperkfortrigger
setignoreentfortrigger
clientclaimtrigger
clientreleasetrigger
releaseclaimedtrigger
isitemlocked
isitempurchased
uploadleaderboards
setnemesisxuid
getloadoutitem
isbonuscardactive
getloadoutitemref
getloadoutweapon
getloadoutperks
getloadoutallocation
setmovespeedscale
getmovespeedscale
logstring
missile_settarget
missile_dronesetvisible
isonladder
ismantling
isonslide
bloodimpact
startdoorbreach
stopdoorbreach
startragdoll
isragdoll
launchragdoll
launchvehicle
setblur
resetmissiledetonationtime
giveachievement
setzombiename
setentgravitytrajectory
setvehicleteam
setteam
getteam
setowner
setmissileowner
setentityweapon
setturretowner
setturrettype
getcorpseanim
itemweaponsetammo
setturretcarried
setturretminimapvisible
setmissilecoasting
setweapon
gib
setphysparams
setplayercollision
reportuser
setplayercurrentobjective
setplayercurrentstreak
getvelocity
spawnactor
getshootatpos
predictspawnpoint
setdefaultdroppitch
setscanningpitch
launchbomb
magicgrenade
makegrenadedud
setclientflag
getclientflag
clearclientflag
setscriptmoverflag
setmovingplatformenabled
fakefire
makeusable
makeunusable
predictgrenade
setdangerous
isdangerous
getindexforactivecontract
getactivecontractprogress
incrementactivecontractprogress
incrementactivecontracttime
isactivecontractcomplete
hasactivecontractexpired
getactivecontracttimepassed
resetactivecontractprogress
getpregameclass
getpregameteam
setpregameclass
setpregameteam
recordleaguepreloser
luinotifyeventtospectators
istestclient
setworldfogactivebank
iszbarrier
getnumzbarrierpieces
getzbarrierpiecestate
setzbarrierpiecestate
iszbarrieropen
iszbarrierclosed
hidezbarrierpiece
showzbarrierpiece
zbarrierpieceusedefaultmodel
zbarrierpieceusealternatemodel
zbarrierpieceuseupgradedmodel
zbarrierpieceuseboxriselogic
getupgradedpiecenumlives
getzbarrierpieceindicesinstate
getzbarrierpieceanimlengthforstate
getzbarrierpieceanimstate
getzbarrierpieceanimsubstate
zbarriersupportszombietaunts
zbarriersupportszombiereachthroughattacks
getzbarriertauntanimstate
getzbarrierreachthroughattackanimstate
getzbarriernumattackslots
getzbarrierattackslothorzoffset
setzbarriercolmodel
getweaponoptic

CSC Functions
 
Spoiler: click to show...
Code Snippet
Plaintext
print
print3d
assert
assertmsg
debugbreak
array
arrayremovevalue
arrayremoveindex
arrayinsert
arraycombine
arraycopy
isinarray
spawnstruct
println
iprintlnbold
line
box
debugstar
pixbeginevent
pixendevent
clienthassnapshot
getsystemtime
getservertime
getmapcenter
getarraykeys
getfirstarraykey
getnextarraykey
getlastarraykey
getprevarraykey
splitargs
bullettrace
tracepoint
setthirdperson
getlocalclientpos
getlocalclienteyepos
getlocalclientangles
getmaxlocalclients
getactivelocalclients
localclientactive
issplitscreenhost
issplitscreen
aimingatfriendly
randomint
randomfloat
randomintrange
randomfloatrange
sin
cos
tan
asin
acos
atan
int
float
istring
min
max
floor
ceil
sqrt
lerpfloat
lerpvector
getminbitcountfornum
isstring
isarray
vectorfromlinetopoint
pointonsegmentnearesttopoint
distance
distance2d
distancesquared
length
lengthsquared
closer
vectordot
vectorcross
vectornormalize
vectorlerp
combineangles
absangleclamp180
project2dto3d
forwardrotatearoundupbyangle
getsubstr
tolower
strtok
issubstr
makelocalizedstring
spawnfakeent
deletefakeent
setfakeentorg
spawn
spawnplane
getent
getentbynum
getentarray
getlocalplayers
getlocalplayer
getnonpredictedlocalplayer
isalive
getweaponammoclip
isthrowinggrenade
ismeleeing
isswitchingweapons
isonturret
usefootsteptable
usefootstepfxtable
scriptcallbackonfootstepevent
setdemolockonvalues
tablelookup
tablelookupistring
tablelookuprownum
tablelookupcolumnforrow
tablelookupfindcoreasset
getweaponmodel
loadfx
playfx
playloopedfx
stopfx
isfxplaying
bullettracer
disableimpactmarks
enableimpactmarks
triggerfx
visionsetnaked
visionsetnakedlerp
getvisionsetnaked
setripplewave
playloopsound
stoploopsound
playsound
soundplaying
deactivatereverb
setreverb
setsoundvolume
setsoundpitch
setsoundvolumerate
setsoundpitchrate
stopsound
getrealtime
getplaybacktime
getknownlength
setgroupsnapshot
setglobalfutz
setambientsnapshot
setambientsidechainduck
sethealthsnapshot
setlevelfadesnapshot
scalespeed
soundsetmusicstate
soundloopemitter
setsoundcontext
soundstoploopemitter
soundlineemitter
soundstoplineemitter
getsoundname
getsoundcount
issoundloop
stoplocalsound
soundtimescale
allocatesoundrandoms
createsoundrandom
allocatemixerlights
ismixerlightbehaviorhardcoded
ismixerbehaviorhardcoded
precacherumble
playrumbleonposition
getdebugdvar
getdebugdvarint
getdebugdvarfloat
setdvarbool
setdvarfloat
setdvarint
setdvar
setsaveddvar
ismaturecontentenabled
isstereoon
openfile
closefile
fprintln
fprintfields
freadln
fgetarg
ui3dsetwindow
playbink
stopbink
getbinklength
isbinkfinished
isinvehicle
sessionmodeisonlinegame
sessionmodeisprivateonlinegame
sessionmodeisprivate
sessionmodeissystemlink
sessionmodeiszombiesgame
gamemodeismode
gamemodeisusingxp
gamemodeisusingstats
isps3
ispc
isxenon
getsurfacestrings
findstaticmodelindex
hidestaticmodel
unhidestaticmodel
getfootstepstrings
footstepdonothing
footstepdoeverything
footstepdosound
footstepdofootstepfx
newmaterialelem
newtextelem
newradialmaterialelem
deleteelem
setcolorelem
moveelem
rotateelem
elemvirtualtophysical
elemphysicaltovirtual
argusgetui
argusgetorigin
argussetvisible
argussetstacked
argussetdistance
argussetbracket
argussetattach
argussetoffset
argussetfaderate
argusforcedrawbracket
luiload
luishow
luihide
luievent
luienable
luidisable
isluienabled
suienable
suidisable
setambientpackage
setambientroomcontextengine
forceambientroom
forceambientpackage
createqrcode
deleteqrcode
ropepulse
getcamposbylocalclientnum
getcamanglesbylocalclientnum
demoisanyfreemovecamera
demoismoviecamera
demoiseditcamera
demoisdollycamera

getgridfrompos
isdemoplaying
getgametypesetting
isspectating
playerbeingspectated
getlocalplayerteam
playfxontag
playviewmodelfx
spawnfx
deletefx
setrimintensity
setgenericscenevalue
getanimlength
animateui
showui
isads
getcurrentweapon
getcurrentweaponincludingmelee
hasweapon
gettotalammo
setlocalradarenabled
setlocalradarposition
setextracamentity
setextracamactive
getextracamstatic
setextracamstatic
setextracamorigin
setextracamangles
iscameraspiketoggled
setclientvolumetricfog
switchtoservervolumetricfog
switchtoclientvolumetricfog
setservervolumetricfogdensity
getservervolumetricfogdensity
isinhelicopter
getdynent
getdynentarray
spawndynent
launchdynent
createdynentandlaunch
setdynentenabled
loadgump
flushgump
sethidegumpalpha
precacheanimstatedef
scriptmodelsuseanimtree
setlutvolumeactivebank
setlutscriptindex
setworldfogactivebank
getworldfogscriptid
registerclientfield
codegetclientfield
codegetplayerstateclientfield
codegetworldclientfield
setupclientfieldcodecallbacks
getclientfieldversion
getserverhighestclientfieldversion
usealternatereviveicon
setteamreviveicon
resetzombieboxweapons
addzombieboxweapon
setmaplatlong
setblurbylocalclientnum
setburn
setelectrified
initclientobjectives
objective_add
objective_seticonsize
objective_setstencil
objective_onentity
objective_delete
objective_flipicon
objective_state
objective_seticon
ropegetposition
getrope

CSC Methods
 
Spoiler: click to show...
Code Snippet
Plaintext
print
delete
forcedelete
earthquake
playsound
playloopsound
stoploopsound
isplayingloopsound
setsoundentcontext
setloopstate
makelight
getlightcolor
setlightcolor
getlightintensity
setlightintensity
getlightradius
setlightradius
getlightfovinner
getlightfovouter
setlightfovrange
getlightexponent
setlightexponent
makelightslave
makemixerlight
activatemixer
setmixerlightbehavior
setmixerbehavior
setmixerexploderid
setmixerlightparam
setmixerparam
setmixerl2rrampspeed
setmixerr2lrampspeed
setmixerlightintensity
setmixerlightcolor
setmixerlightexponent
setmixerlightradius
setmixerlightfovrange
setmixerlightrotatetime
setmixerspinmodels
setmixerlightmodels
getentnum
getentitynumber
setmodel
setscale
settargethighlight
attach
istouching
isalive
getspeed
getvelocity
underwater
isplayer
islocalplayer
isai
hasdobj
setcompassicon
launchragdoll
show
hide
setmaterialoverride
clearmaterialoverride
setsteptriggersound
clearsteptriggersound
getmovementtype
isinsideheightlock
isgrenadedud
getcharacterindex
linkto
unlink
islocalplayerviewlinked
getthrottle
getbrake
getmaxspeed
getsteering
getmaxreversespeed
islocalclientdriver
getlocalclientdriver
getwheelsurface
ispeelingout
iswheelsliding
iswheelcolliding
getlocalgunnerangles
setstunned
isdriving
rotatepitch
rotateyaw
rotateroll
rotateto
moveto
movegravity
movex
movey
movez
rotatevelocity
playrumbleonentity
playrumblelooponentity
stoprumble
startpoisoning
stoppoisoning
ispoisoned
issplitscreenhost
setwatchstyle
getstance
getweaponposfrac
getcontrollertype
getwiiuremotepointerposition
islocalplayerweaponviewonlylinked
getcampos
getcamangles
useanimtree
hasanimtree
clearanim
clearanimlimited
setanim
setanimlimited
setanimrestart
setanimlimitedrestart
setflaggedanim
setflaggedanimlimited
setflaggedanimrestart
setflaggedanimlimitedrestart
animscripted
animflaggedscripted
setanimknob
setanimknoblimited
setanimknobrestart
setanimknoblimitedrestart
setanimknoball
setanimknoballlimited
setanimknoballrestart
setanimknoballlimitedrestart
setflaggedanimknob
setflaggedanimknoblimited
setflaggedanimknobrestart
setflaggedanimknoblimitedrestart
setflaggedanimknoball
setflaggedanimknoballrestart
getanimtime
setanimtime
getanimcurrframecount
setentityanimrate
getentityanimrate
animgetchildat
animgetnumchildren
map_material
set_filter_pass_material
set_filter_pass_enabled
set_filter_pass_quads
set_filter_pass_constant
set_filter_bit_flag
set_overlay_enabled
set_overlay_material
set_overlay_constant
setinfraredvisionset
setsonarenabled
forceinfraredmaterialsstreaming
setambienttrigger
geteye
geteyeapprox
getlocalclientnumber
mapshaderconstant
setshaderconstant
setviewmodelrenderflag
cincaptureenablealpha
cincapturedisablealpha
setforcenotsimple

gettagorigin
gettagangles
getinkillcam
getowner
setrenderinthirdpersonspectate
getanimstate
getanimstatecategory
getvehiclehealth
gethelidamagestate
isburning
isremotecontrolling
overridelightingorigin
hasperk
getstance
shellshock
earthquake
setenemyglobalscrambler
setenemyscrambleramount
getenemyscrambleramount
isscrambled
setfriendlyscrambleramount
getfriendlyscrambleramount
addfriendlyscrambler
clearnearestenemyscrambler
setnearestenemyscrambler
removefriendlyscrambler
removeallfriendlyscramblers
hastacticalmaskoverlay
setblur
setflagasaway
getparententity
useweaponhidetags
useweaponmodel
setalphafadeforname
usealternateaimparams
clearalternateaimparams
setphysicsgravity
clearphysicsgravity
setmultiextracamactive
isextracam
setsonarattachmentenabled
processclientfieldsasifnew
equipflashlight
removeflashlight
zbarriergetpiece
zbarriergetnumpieces

Some Random Functions
 
Spoiler: click to show...
Godmode (toggle)
Code Snippet
Plaintext
function god_mode()
{
    if(!isDefined(self.god_mode))
    {
        self.god_mode = true;
        self enableInvulnerability();
        self iprintln("God Mode: [^2ON^7]");
    }
    else
    {
        self.god_mode = undefined;
        self disableInvulnerability();
        self iprintln("God Mode: [^1OFF^7]");
    }
}

Change Map
Code Snippet
Plaintext
Map(mapname, true);

Restart Map
Code Snippet
Plaintext
Map_Restart(true);

Remove Deathbarrier
Code Snippet
Plaintext
function deathBarrier()
{
ents = getEntArray();
for(index = 0; index < ents.size; index++)
{
    if(isSubStr(ents[index].classname, "trigger_hurt"))
    ents[index].origin = (0, 0, 9999999);
}
}

Ban and Kick Player
Code Snippet
Plaintext
ban(player GetEntityNumber()); //just means the player won't be able to join back
kick(player GetEntityNumber());

Disable Cheats
Code Snippet
Plaintext
//CabCon

//add this to the very bottom of your mapname.gsc
function disable_cheats()
{
    ModVar("god", 0);
    ModVar("demigod", 0);
    ModVar("noclip", 0);
    ModVar("ufo", 0);
    ModVar("give", 0);
    ModVar("notarget", 0);
}

//put this right below main
level disable_cheats();

Unlimited Ammo (toggle)
Code Snippet
Plaintext
//CabCon
function unlimited_ammo()
{
    if(!isDefined(self.unlim_ammo))
    {
        self notify("unlim_ammo");
        self thread restock_ammo();
        self iprintln("Unlimited Ammo: [^2ON^7]");
        self.unlim_ammo = true;
    }
    else
    {
        self notify("stop_ammo");
        self.unlim_ammo = undefined;
        self iprintln("Unlimited Ammo [^1OFF]");
    }
}

function restock_ammo()
{
    self endon("unlim_ammo");

    for(;;)
    {
        if(self.unlim_ammo)
        {
            if (self getcurrentweapon() != "none")
            {
                self setweaponammostock( self getcurrentweapon(), 1337 );
                self setweaponammoclip( self getcurrentweapon(), 1337 );
            }
        }
        wait 0.1;
    }
}

Multiplayer movement
Code Snippet
Plaintext
//doesn't work on soe as far as I know (probably something with zones idk)
function newMovment()
{
    SetDvar("doublejump_enabled", 1);
    SetDvar("juke_enabled", 1);
    SetDvar("playerEnergy_enabled", 1);
    SetDvar("wallrun_enabled", 1);
    SetDvar("sprintLeap_enabled", 1);
    SetDvar("traverse_mode", 1);
    SetDvar("weaponrest_enabled", 1);
}

Forge Mode (toggle)
Code Snippet
Plaintext
//Joker and NGU
function togge_forge()
{
    if(!self.forge_mode)
    {
        self thread forge_mode();
        self iPrintln("Forge Mode: [^2ON^7]\nHold [{+speed_throw}] to move objects");
        self.forge_mode = true;
    }
    else
    {
        self notify("forge_mode");
        self iPrintln("^7Forge Mode: [^1OFF^7]");
        self.forge_mode = false;
    }
}

function forge_mode()
{
    self endon("death");
    self endon("forge_mode");
    for(;;)
    {
        while(self adsbuttonpressed())
        {
            trace = bulletTrace(self GetTagOrigin("j_head"), self GetTagOrigin("j_head") + anglesToForward(self GetPlayerAngles())*1000000, true, self);
            while(self adsbuttonpressed())
            {
                trace["entity"] setOrigin(self GetTagOrigin("j_head") + anglesToForward(self GetPlayerAngles())*200);
                trace["entity"].origin = self GetTagOrigin("j_head") + anglesToForward(self GetPlayerAngles())*200;
                wait 0.05;
            }
        }
        wait 0.05;
    }
}

Disable Player Collision (toggle)
Code Snippet
Plaintext
function toggle_player_collision()
{
    if(!isDefined(level.player_collision))
    {
        self thread set_player_collision(false);
        self iPrintln("Forge Mode [^2ON^7]\nHold [{+speed_throw}] to move objects");
        self.player_collision: = true;
    }
    else
    {
        self thread set_player_collision(true);
        self iPrintln("^7Forge Mode: [^1OFF^7]");
        self.player_collision = undefined;
    }
}

function set_player_collision(bool, include_self = true)
{
players = getPlayers(self.team);
for(i = 0; i < players.size; i++)
{
if(players[i] == self && !include_self)
continue;

players[i] SetPlayerCollision(bool);
}
}

Unlimited Boost (toggle)
Code Snippet
Plaintext
//Aspire
function toggle_boost()
{
if(!isDefined(self.toggle_boost))
{
self thread maintain_boost();
self iPrintln("Unlimited Boost: [^2ON^7]");
self.toggle_boost = 1;
}
else
{
self notify("unlim_boost");
self iPrintln("Unlimited Boost: [^1OFF]");
self.toggle_boost = undefined;
}
}

function maintain_boost()
{
self endon("unlim_boost");

for(;;)
{
if(isDefined(self) && isAlive(self))
{
if(self IsPlayerDoubleJumping())
{
self SetDoubleJumpEnergy(100);
wait 0.05;
}
}
wait 0.05;
}
}

Healthbar (toggle)
Code Snippet
Plaintext
//CabCon
function toggle_healthbar()
{
if(!isDefined(self.healthbar))
{
self thread healthbar();
self iPrintln("Unlimited Boost: [^2ON^7]");
self.healthbar = 1;
}
else
{
self notify("health_bar");
self.health_bar destroy();
self.health_text destroy();

self iPrintln("Unlimited Boost: [^1OFF^7]");
self.healthbar = undefined;
}
}

function healthbar()
{
    self endon("disconnect");
    x = 80;
    y = 40;
    self.health_bar = newClientHudElem( self );
    self.health_bar.x = x + 80;
    self.health_bar.y = y + 2;
    self.health_bar.alignx = "left";
    self.health_bar.aligny = "top";
    self.health_bar.horzalign = "fullscreen";
    self.health_bar.vertalign = "fullscreen";
    self.health_bar.alpha = 1;
    self.health_bar.foreground = 1;
    self.health_bar setshader( "black", 1, 8 );
    self.health_text = newClientHudElem( self );
    self.health_text.x = x + 80;
    self.health_text.y = y;
    self.health_text.alignx = "left";
    self.health_text.aligny = "top";
    self.health_text.horzalign = "fullscreen";
    self.health_text.vertalign = "fullscreen";
    self.health_text.alpha = 1;
    self.health_text.fontscale = 1;
    self.health_text.foreground = 1;

    if(!isDefined(self.maxhealth) || self.maxhealth <= 0)
        self.maxhealth = 100;
    self thread update_healthbar();
}

function update_healthbar()
{
self endon("health_bar");
for(;;)
    {
        wait 0.05;
        width = (self.health / self.maxhealth) * 300;
        width = int( max(width, 1) );

        self.health_bar setshader("black", width, 8);
        self.health_text setvalue(self.health);
    }
}
7 years ago
So since there are a lot of new people comming to the modding community, I decided to make this small post to help others understand GSC better, anyway lets begin.

Contents:
  • Setting Up
  • Understanding The Syntax
  • Understanding Variables
  • Using 'using' and 'insert'
  • Basic Scripting
  • Threading
  • GSC Functions
  • Cleaning up your script
  • FAQ

Setting Up

Spoiler: click to open...
In order to code GSC you do not need any fancy or pricy programs to do so, all you need is a simple text editor.
If you want you could use the default notepad application that comes with windows but if you prefer something a bit more advanced that has syntax highlighting and some other groovy features then I suggest using some of the programs I have listed below.

Notepad++
Sublime Text
UltraEdit
GSC Studio By iMCSx

I'm sure if you were to do a quick google search you could find more but these are probably the best ones!

Understanding The Syntax

Spoiler: click to open...
If you are new to coding getting your head around the syntax can take quiet a bit of time to get the hang off.
If you are unsure what I mean by "The Syntax" then feel free to google it and come back when you are ready
The Syntax in GSC is similar to most general programming languages such as C++, C#, Ruby and many more.

The 2 Curly Brackets Are Used To Define where the start and end of your functions/statements are.
Code Snippet
Plaintext
Curly Brackets: { }
Example
function funcName()         //'function' Let's Me Define My Function
{              //Starting My Function
                 
}              //Ending It
The Semi-Colon is used to define where a line or statement will end it is also used as a separator in some cases.
Code Snippet
Plaintext
Semi-Colon: ;
Example
funcName(); //By Putting The Semi-Colon I Am Ending My Line/Statement So My Code Knows To Go To The Next Line
Example 2
for (i = 0; i < 10; i++)//In This Example You Can See Im Using The Semi-Colon To Seperate The Variables
{ }
The Brackets are mainly used to indicate an argument, to tell the compiler what data type the function needs to look for first in order to start.
Code Snippet
Plaintext
Brackets: ( )
Example
number = 1;
funcName(number)//Initialising A Function With The Argument being number
//An argument is only to be included if the function supports them if not I would just put brackets with nothing inside

The Square Brackets Are Really Only Used To Declare & Access Arrays
Code Snippet
Plaintext
Square Brackets: [ ]
Example
studentAge["Justin"] = 15;
studentAge["Brandon"] = 16;
number = studentAge["Justin"] //Number would know be equal to 15

Quotation Marks Are Used For Declaring A String
[code]
Code:
Quotation Marks: " "
Example
myName = "Justin"//myName is now equal to Justin

Understanding Variables

Spoiler: click to open...
A Variable is used as a storage point, they are used within almost every programming language and are extremely useful for storing any type of data.
Before declaring a variable you should first know about all the different data types, ill list them below.
Code Snippet
Plaintext
String
Boolean
Float
Integer

There is many more but this is all you will need to know for GSC

Now To declare a variable its actually quiet simple, you don't need to say what type of variable it is you are declaring you just need to put the data in, I'll put some examples below.
Code Snippet
Plaintext
self.stringVariable = "MyString";
self.integerVariable = 1;
self.floatVariable = 1.23;
self.booleanVariable = true;
The names of your variables can be anything you desire, by doing self.variableName I am defining a variable for my own player in GSC, I will talk about this later in Basic Scripting.

Using 'using' and 'insert'

Spoiler: click to open...
I'm sure everyone has seen it when at the top of a GSC code you see something that looks like this
Code Snippet
Plaintext
#using scripts\shared\callbacks_shared
Think of using as a way of copying and pasting, what the above code would be doing is copying and pasting all the contents from another GSC file into our GSC file.
But why would we want to do this? Well the answer to that is quiet simple, so we can use the functions that are in that GSC file in our own GSC file. Insert is basically the same just with variables.

Basic Scripting

Spoiler: click to open...
Now I Will Talk About The Basics of GSC Scripting!

If you have ever seen GSC Coding before I'm sure you are wondering what it means by self and player and all that other stuff that you see before functions.
Well to start off self means the entity/player that is calling the current script, example lets say my player just spawned and I run the code below.
Code Snippet
Plaintext
self freezeControls(true);
Now from what I have told you we know that self is my player because my player is calling this code, so therefore my players controls will be frozen.

Now for a more complex example.
Lets say we have a function with the argument player.
Code Snippet
Plaintext
freezePlayer(player)
{
     player freezeControls(true);
}
Now I'm sure you are wondering how we are supposed to call this if we don't know what to put in the player argument, well ill explain.
There is an array that stores all the players in it, this is what we will use for our argument.
So to call it we could do both ways listed below.
Code Snippet
Plaintext
freezePlayer(level.players[0]); //Freeze Client 0

freezePlayer(self); //Freeze Player Running The Code

Threading

Spoiler: click to open...
Now we know the basics lets move onto something a tiny bit more complex, threading.
Threading is extremely useful within GSC, it is mainly used when doing loops, if we were to create a loop on the main thread we would probably freeze the game, but if we were to make a new thread what would happen is that the main thread would keep running and a new thread would run next to it therefore preventing the game from freezing.

Before creating a new thread that uses a loop there is one thing you should know which is that a loop must have a small wait time, if not your game will lag out and freeze ill provide an example shortly of how to add a wait.

to create a new thread its fairly straight forward all you need to do is put thread infront of where your calling your function.
Code Snippet
Plaintext
function myLoop()//Defining The Function With The Loop
{
     self endon("disconnect");//Ends the thread if player disconnects or dies.
     self endon("death");
     self.number = 1;
     for (;;)
     {
          self.number++; //Increase the number by 1 constantly
          wait 0.05; //stop it from lagging and freezing.
     }
}

//Calling It On A New Thread
self thread myLoop(); //This will make a new thread and run myLoop

GSC Functions

Spoiler: click to open...
I'm not sure if everyone is the same as me but I cant stand seeing ugly codes, this does not mean your code is bad it just makes it harder to understand for others and sometimes for yourself if you want to go back and review it to improve it or check something in it.

Below is an example of what I would call an "ugly" code. (I just used a function I found on NGU and made it ugly)
Code Snippet
Plaintext
play_sound_on_shoot()
{
self endon("disconnect")
self endon("death")
self iPrintln("press shoot button to play a sound");
for(;;)
{
self waittill ("weapon_fired");
self playsound("zmb_cherry_explode");
wait 1;
}
}
Now looking at this code its very hard to read and everything is really close together now below I'm going to show you the neat version of this function
Code Snippet
Plaintext
play_sound_on_shoot()
{
    self endon("disconnect")
    self endon("death")

    self iPrintln("Shoot To Play A Sound!");
    for(;;)
    {
        self waittill ("weapon_fired");
        self PlaySound("zmb_cherry_explode");
        wait 1;
    }
}
You can see I have added indents and changed the iPrintln to something more formal.
If you are unsure how to do your indentations correctly then I will briefly explain.

Indentations are not important and will not affect the way your code functions but like I said before they make your code much more readable and formal. If you are using a text editor like one of the ones I suggested at the start of this tutorial then getting your indentations correct is easy on every keyboard we have a magical button called the "tab button" what this will do is move your writing pointer across a number of spaces depending on where you have pressed tab from.
To indent a function correctly is simple all you have to do is indent your code inside each new code block, example below and further explaination below.



Basically for each code block you define you have to press tab for each code block you are writing in, if you are writing in the main code block you only indent once if you are writing inside a code block thats in the main code block then you indent twice etc.

As for making your code more understandable try to name things to what they are so they make more sense, example below.
Code Snippet
Plaintext
//Lets Compare
self.swagjumpmodeon = true;
//To
self.superJump = true;

//Which one do you understand more? The Bottom One? yea though so...
//Same goes with function names and anything else that requires naming
So just remember to code your functions correctly especially if you are releasing them!

Cleaning up your script

Spoiler: click to open...

Toggles

Cluttered Way
Code Snippet
Plaintext
function godmode_toggle()
{
if(self.godmode == false)
{
self EnableInvulnerability();
self iPrintln("Godmode Enabled");
self.godmode = true;
}
else
{
self DisableInvulnerability();
self iPrintln("Godmode Disabled");
self.godmode = false;
}
}

Clean Way
Code Snippet
Plaintext
function godmode_toggle()
{
if(!isDefined(self.isGod) || !self.isGod)
self EnableInvulnerability();
else
self DisableInvulnerability();

self.isGod = !self.isGod;
self iPrintLn("Godmode " + self.isGod ? "Enabled" : "Disabled");
}
I use this method myself and it is overall better. It may look like more code however the toggle function can be re-used with multiple functions. So instead of writing the same two lines over and over again you have one function that you call that does it for you. As well as the toggle function itself being smaller.


If statements and 'for' loops

Cluttered Way
Code Snippet
Plaintext
if(self.menuOpen == true)
{
for(i = 0; i < level.players.size; i++)
{
level.players[i] iPrintln("Menu is open");
}
}

Clean Way
Code Snippet
Plaintext
if(self.menuOpen)
{
for(i = 0; i < level.players.size; i++)
level.players[i] iPrintln("Menu is open");
}
When using if statements and for loops, you do not need to add braces to your code IF AND ONLY IF the code that you would put between the braces is one line of code. Also you don't need self.menuOpen == true, self.menuOpen by itself works just as fine. If will read the variable as true because if(self.menuOpen) is like saying if(true). Likewise with variables that are false. You don't need self.menuOpen == false, if(!self.menuOpen) will read the variable as false.


Function calling

Cluttered Way
Code Snippet
Plaintext
self thread test();

function test()
{
self iPrintln("I am NOT a looped function");
}

Clean Way
Code Snippet
Plaintext
self thread test();

function test()
{
self iPrintln("I am NOT a looped function");
}

OR
Code Snippet
Plaintext
test();

function test()
{
self iPrintln("I am NOT a looped function");
}

FAQ

Spoiler: click to open...

Q: My Game Freezes On Loading Screen
A: This Means You Either Have A Non-Existant Function or A Syntax Error!

Q: Connection Interrupted then Freeze when calling a function or spawning in
A: This Means You Have A Loop With No Waits

----------------------------------------------------------------------------------------------------------------------------

Credits:
  • Shark
  • Taylor

7 years ago
Okay so I'm fairly new to zombie modding, but I used to code BO2 GSC and now since BO3 Modtools were released I decided to come back to modding :D

So my main questions are:
How do I get the costs of an trigger? (.costs is just made up)
 How do I make it so that the trigger doesn't cost anything for only me?

Spoiler: click to open...
Shopping Free
Code Snippet
Plaintext
//bgb shopping free
function bgb_shopping_free()
{
    self endon("bgb_done");

    self thread wait_notify(60, "bgb_done"); //1min
    self thread waittill_call("bgb_done", "reset_triggers");

    self.shopping_free = true;
    setdvar("zombie_unlock_all", 1);

    self.triggers = strTok("zombie_doors, zombie_door, zombie_airlock_buy, zombie_debris, flag_blocker, window_shutter", ", ");
    wait 0.1;

    foreach(trigger in triggers)
    {
        trigger_ent = GetEntArray(trigger, "targetname");
        for(i = 0; i < trigger_ent.size; i++)
        {
            trigger_ent[i].old_costs = trigger_ent[i].costs;
            trigger_ent[i].costs = 0;
            trigger_ent[i].was_player_triggered = false;
           
            //add check if player is self
            trigger_ent[i] waittill("trigger", player);
            trigger_ent[i].was_player_triggered = true;
        }
    }
}

function reset_triggers()
{
    triggers = self.triggers;
    foreach(trigger in triggers)
    {
        trigger_ent = GetEntArray(trigger, "targetname");
        for(i = 0; i < trigger_ent.size; i++)
        {
            if( !trigger_ent[i].was_player_triggered )
                trigger_ent[i].costs = trigger_ent[i].old_costs;
        }
    }
    wait 0.1;

    if(!self others_have_shopping_free())
        setdvar("zombie_unlock_all", 0);
    self.triggers = undefined;
}

function others_have_shopping_free()
{
    players = GetPlayers(self.team);
    foreach(player in players)
    {
        if(player == self)
            continue;

        if(player.shopping_free)
            return true;
        else
            result = false;
    }
    return result;
}

function wait_notify(time, event)
{
    wait time;
    self notify(event);
}

function waittill_call(event, func, arg1, arg2)
{
    self waittill(event);

    if(isDefined( arg1 ) && isDefined( arg2 ))
        self thread [[ func ]](arg1, arg2);

    else if(isDefined( arg1 ) && !isDefined( arg2 ))
        self thread [[ func ]](arg1);

    else
        self thread [[ func ]]();
}

And I'm trying to make my own gobblegums (bgbs) and I made this script but I don't know the names of the fxs/sounds, can someone help me with it or show me a way to work around it?

This is more of a random question
Are there any effects for stuff like the electric cherry electricity/blast furnace? (sound, fx)

Spoiler: click to open...
Has no name yet
Code Snippet
Plaintext
//new bgb
function have_not_found_a_name_yet()
{
    self endon("bgb_done");

    range = 120;
    rangeSQ = range*range; //since we're using distanceSquared
    self thread electrocuting_ambient(range);

    //time = &RandomIntRange(1, 3); //would be better because i wont get results like 0.11
    time = &RandomFloatRange(0.1, 0.3);
    self waittill("player_used_bgb");

    AI = GetAITeamArray("axis");
    AI = self getClosest(AI, rangeSQ);
    for(i = 0; i < AI.size; i++)
    {
        AI[i] FreezeControls(true); //idk how to freeze a zombie lol
        fx_duration = RandomFloatRange(0.1, 0.3);

        wait time; //or time/10 if I use IntRange
        self notify("electrocuting_zombies");

        while(fx_duration <= 0)
        {
            //bo2's fx - don't know bo3's fx
            PlayFxOnTag(level._effect["prox_grenade_player_shock"], AI[i], "j_head");
            PlayFxOnTag(level._effect["prox_grenade_player_shock"], AI[i], "J_Spine1");
            PlayFxOnTag(level._effect["prox_grenade_player_shock"], AI[i], "J_Spine4");
            PlayFxOnTag(level._effect["prox_grenade_player_shock"], AI[i], "pelvis");
            fx_duration -= 0.09; //just to add more randomness
            wait 0.05;
        }
        wait 0.05;
        AI[i] FreezeControls(false);
        AI[i] DetachAll();
        AI[i] DoDamage(AI[i].health + 1, self.origin, self);
        self zm_score::add_to_player_score(100); //or less idk
    }
}

function electrocuting_ambient(range)
{
    self endon("bgb_done");

    self waittill("electrocuting_zombies");
    pos = self.origin;

    PlaySoundAtPosition("wpn_taser_mine_zap", pos); //bo2's sound
    Earthquake(0.22, 0.4, pos, range);
}

function getClosest(ents, rangeSQ, is_squared = true) //SQ = squared
{
    index = 0;
    newArr = []

    if(!is_squared)
        rangeSQ *= rangeSQ;

    for(i = 0; i < ents.size; i++)
    {
        if(DistanceSquared(self.origin, ents[i].origin) <= rangeSQ)
        {
            newArr[index] = ents[i];
            index++;
        }
    }
    return newArr;
}
I would be thankfull for any help I can get!
7 years ago
Loading ...