Cxwh
Veteran
- Messages
- 64
- Reaction score
- 45
- Points
- 793
Today I'm showing you my GSC menu base. It's based on Fallen's Surge base since it's the best imo.
Anyway here's the source
Anyway here's the source
Code:
#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_spawned( &onPlayerSpawned );
callback::on_player_killed( &onPlayerKilled );
callback::on_disconnect( &onPlayerDisconnected );
}
function init()
{
level.clientid = 0;
level.colors = [];
addColor("black", (0, 0, 0));
addColor("white", (1, 1, 1));
addColor("red", (1, 0, 0));
addColor("yellow", (1, 1, 0));
addColor("green", (0, 1, 0));
addColor("blue", (0,0, 1));
addColor("purple", (1, 0, 1));
addColor("cyan", (0, 1, 1));
addColor("gray", (0.5, 0.5, 0.5));
addColor("orange", (0.95, 0.52, 0.0285));
level.themes = [];
addTheme("Surge", "orange", "black");
addTheme("Cherry", "red", "white");
addTheme("Poison", "green", "black");
addTheme("Death Star", "cyan", "black");
addTheme("Obsidian", "purple", "black");
addTheme("NextGenUpdate", "cyan", "gray");
addTheme("Se7enSins", "green", "gray");
level.vars = [];
level.vars["level"] = [];
level.perm = [];
level.lastIndex = 14;
thread on_game_ended();
}
function onPlayerConnect()
{
if(self isHost())
{
level.perm[self.name] = 3;
self thread homefront();
}
else
level.perm[self.name] = 0;
self.init = 0;
self setClientId();
level.vars[self.name] = [];
self updatePlayersMenu();
self.resetOnDeath = [];
}
function onPlayerSpawned()
{
if(self isAllowed())
{
self iPrintln("Welcome ^1" + self.name);
if(!self.init)
{
self.init = 1;
self initOccult();
self thread createHud();
self thread createMenu();
self thread monitorButtons();
}
}
}
function onPlayerKilled()
{
if(self isAllowed())
{
self enterMenu();
self exitMenu();
}
foreach(x, bool in self.resetOnDeath)
level.vars[self.name][x] = !bool;
}
function onPlayerDisconnected()
{
ArrayRemoveIndex(level.perm, self.name, true);
ArrayRemoveIndex(level.vars, self.name, true);
n = GetName(self);
menu = self.occult["menu"]["Players"];
ArrayRemoveIndex(menu["options"], n);
foreach(player in level.players)
{
if(player isAllowed())
{
if(player getMenuParent() == "Players" && player getCurrentMenu() == n)
{
player enterMenu("Players");
player iPrintln("Entered parent menu: " + n + " left the game");
}
}
}
}
function on_game_ended()
{
level waittill("game_ended");
wait 0.25;
foreach(player in level.players)
{
if(player isAllowed())
{
player exitMenu();
player.occult["locked"] = 1;
}
}
}
function initOccult()
{
self.occult = [];
self.occult["hud"] = [];
self.occult["hud"]["text"] = [];
self.occult["hud"]["shader"] = [];
self.occult["colors"] = [];
self.occult["themes"] = [];
setColor("panel", "black");
setColor("glow", "orange");
setColor("title", "orange");
setColor("options", "white");
setColor("scrollbar", "orange");
setColor("background", "black");
self.occult["menu"] = [];
self.occult["menu"]["current"] = "Main Menu";
self.occult["locked"] = 0;
self.occult["active"] = 0;
self.occult["is_closing"] = 0;
}
function monitorButtons()
{
self endon("unverified");
self endon("disconnect");
level endon("game_ended");
for(;;)
{
if(!self.occult["active"] && !self.occult["locked"])
{
if(self MeleeButtonPressed() && self AdsButtonPressed())
self loadMenu();
if(self ActionSlotFourButtonPressed())
ExitLevel();
}
if(self.occult["active"] && !self.occult["is_closing"] && !self.occult["locked"])
{
if(self UseButtonPressed())
{
if(!isEmpty(self getMenuParent()))
self enterMenu(self getMenuParent());
else
self exitMenu();
wait 0.2;
}
if(self ActionSlotOneButtonPressed() || self ActionSlotTwoButtonPressed())
{
parent = self getCurrentMenu();
if(self actionslotonebuttonpressed())
{
self.occult["menu"][parent]["o_index"]--;
if(self.occult["menu"][parent]["o_index"] < 0)
{
self.occult["menu"][parent]["o_index"] = self.occult["menu"][parent]["options"].size - 1;
self.occult["menu"][parent]["s_index"] = self.occult["menu"][parent]["l_index"];
index = 0;
last_index = self.occult["menu"][parent]["l_index"];
for(i = self.occult["menu"][parent]["o_index"] - last_index; i < self.occult["menu"][parent]["options"].size; i++)
{
self.occult["hud"]["text"]["options"][index] setText(self.occult["menu"][parent]["options"][i]["label"]);
index++;
}
self.occult["hud"]["shader"]["scrollbar"] elemMoveY(0.15, self.occult["hud"]["text"]["options"][self.occult["menu"][parent]["s_index"]].y + 1);
}
else
{
if(self.occult["menu"][parent]["s_index"] == 0)
{
index = 0;
last_index = self.occult["menu"][parent]["l_index"];
for(i = self.occult["menu"][parent]["o_index"]; i < self.occult["menu"][parent]["o_index"] + last_index + 1; i++)
{
self.occult["hud"]["text"]["options"][index] setText(self.occult["menu"][parent]["options"][i]["label"]);
index++;
}
}
else
{
self.occult["menu"][parent]["s_index"]--;
self.occult["hud"]["shader"]["scrollbar"] elemMoveY(0.15, self.occult["hud"]["text"]["options"][self.occult["menu"][parent]["s_index"]].y + 1);
}
}
}
else
{
self.occult["menu"][parent]["o_index"]++;
if(self.occult["menu"][parent]["o_index"] > self.occult["menu"][parent]["options"].size - 1)
{
self.occult["menu"][parent]["o_index"] = 0;
self.occult["menu"][parent]["s_index"] = 0;
for(i = 0; i < self.occult["menu"][parent]["l_index"] + 1; i++)
self.occult["hud"]["text"]["options"][i] setText(self.occult["menu"][parent]["options"][i]["label"]);
self.occult["hud"]["shader"]["scrollbar"] elemMoveY(0.15, self.occult["hud"]["text"]["options"][self.occult["menu"][parent]["s_index"]].y + 1);
}
else
{
if(self.occult["menu"][parent]["s_index"] == self.occult["menu"][parent]["l_index"])
{
index = 0;
last_index = self.occult["menu"][parent]["l_index"];
for(i = self.occult["menu"][parent]["o_index"] - last_index; i < self.occult["menu"][parent]["o_index"] + 1; i++)
{
self.occult["hud"]["text"]["options"][index] setText(self.occult["menu"][parent]["options"][i]["label"]);
index++;
}
}
else
{
self.occult["menu"][parent]["s_index"]++;
self.occult["hud"]["shader"]["scrollbar"] elemMoveY(0.15, self.occult["hud"]["text"]["options"][self.occult["menu"][parent]["s_index"]].y + 1);
}
}
}
self thread scrollbarEffect();
}
if(self JumpButtonPressed())
{
selected = self.occult["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"]);
}
if(selected["entity"] != self)
self iPrintln(selected["label"] + " was called on " + getName(selected["entity"]));
if(selected["func"] == &toggle)
{
if(!isEmpty(selected["input"][1]) && selected["input"][1] != self)
self iPrintln(selected["label"] + " was called on " + getName(selected["input"][1]));
}
if((selected["func"] == &enterMenu && isEmpty(self.occult["menu"][selected["input"]])) || selected["func"] != &enterMenu)
{
elem = self.occult["hud"]["text"]["options"][self getMenuPosition(1)];
elem elemMoveX(0.07, elem.x - 5);
wait 0.25;
elem thread elemMoveX(0.07, -10);
}
else
wait 0.2;
}
}
wait 0.05;
}
}
function addMenu(parent, label, perm = 0)
{
self.occult["menu"][label] = [];
self.occult["menu"][label]["perm"] = perm;
self.occult["menu"][label]["label"] = label;
self.occult["menu"][label]["parent"] = parent;
self.occult["menu"][label]["options"] = [];
self.occult["menu"][label]["o_index"] = 0;
self.occult["menu"][label]["s_index"] = 0;
if(!isEmpty(self.occult["menu"][parent]))
self addOption(parent, label, &enterMenu, label);
}
function addOption(parent, label, func, input, type = "thread", entity = self)
{
index = self.occult["menu"][parent]["options"].size;
self.occult["menu"][parent]["options"][index] = [];
self.occult["menu"][parent]["options"][index]["label"] = label;
self.occult["menu"][parent]["options"][index]["func"] = func;
self.occult["menu"][parent]["options"][index]["input"] = input;
self.occult["menu"][parent]["options"][index]["type"] = type;
self.occult["menu"][parent]["options"][index]["entity"] = entity;
if(index < level.lastIndex)
self.occult["menu"][parent]["l_index"] = index;
else
self.occult["menu"][parent]["l_index"] = level.lastIndex;
}
function getCurrentMenu()
{
return self.occult["menu"]["current"];
}
function getMenuPosition(s_index = 0, menu = self.occult["menu"]["current"])
{
if(!s_index)
return self.occult["menu"][self getCurrentMenu()]["o_index"];
return self.occult["menu"][self getCurrentMenu()]["s_index"];
}
function getPermission(menu = self.occult["menu"]["current"])
{
return self.occult["menu"][menu]["perm"];
}
function enterMenu(input)
{
if(!self.occult["is_closing"] && self.occult["active"])
{
if(isDefined(self.occult["menu"][input]))
{
if(!self.occult["is_closing"] && self.occult["active"])
{
if(level.perm[self.name] >= getPermission(input))
{
self menuTransitionOut();
wait 0.25;
for(i = 0; i < self.occult["hud"]["text"]["options"].size + 1; i++)
self.occult["hud"]["text"]["options"][i] destroy();
self.occult["menu"]["current"] = input;
self updateText(input);
self.occult["hud"]["shader"]["glow"] notify("pulse_end");
self.occult["hud"]["shader"]["glow"] thread pulseEffect(0.4, 0.5, 2);
self.occult["hud"]["shader"]["scrollbar"] elemMoveY(0.1, self.occult["hud"]["text"]["options"][self getMenuPosition(1)].y + 1);
self.occult["hud"]["shader"]["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 is closing");
}
else
self iPrintln("^1ERROR: ^3Cannot enter submenu: menu does not exist");
}
}
function createMenu()
{
self addMenu(undefined, "Main Menu");
self addOption("Main Menu", "Weapons Menu", &enterMenu, "Weapons");
n = "SubMenu 1";
self addMenu("Main Menu", n);
self addOption(n, "God Mode", &toggle, "god");
self addOption(n, "Infinite Ammo", &toggle, "ammo");
self addOption(n, "Noclip", &toggle, "noclip");
self addOption(n, "Boost", &toggle, "boost");
n = "SubMenu 2";
self addMenu("Main Menu", n);
self addOption(n, "Option 1", &test);
self addOption(n, "Option 2", &test);
self addOption(n, "Option 3", &test);
n = "SubMenu 3";
self addMenu("Main Menu", n);
self addOption(n, "Option 1", &test);
self addOption(n, "Option 2", &test);
self addOption(n, "Option 3", &test);
n = "SubMenu 4";
self addMenu("Main Menu", n);
self addOption(n, "Option 1", &test);
self addOption(n, "Option 2", &test);
self addOption(n, "Option 3", &test);
n = "Themes";
self addMenu("Main Menu", n);
foreach(theme in self.occult["themes"])
self addOption(n, theme["label"], &setTheme, theme["label"]);
self addMenu("Main Menu", "Players");
foreach(player in level.players)
{
if(player != self)
{
n = getName(player);
self addMenu("Players", n);
self addOption(n, "Option 1", &test);
self addOption(n, "Option 2", &test);
self addOption(n, "Option 3", &test);
}
}
if(self.occult["menu"]["Players"]["options"].size == 0)
self addOption("Players", "This is a solo game", &enterMenu, getMenuParent("Players"));
}
function addColor(name, rgb)
{
level.colors[name] = rgb;
}
function addColor255(name, rgb)
{
level.colors[name] = (rgb[0]/255, rgb[1]/255, rgb[2]/255);
}
function setColor(elem, name)
{
self.occult["colors"][elem] = level.colors[name];
}
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 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 updateText(input)
{
top = 50;
margin = 25;
color = self.occult["colors"];
self.occult["menu"]["current"] = input;
label = self.occult["menu"][input]["label"];
self.occult["hud"]["text"]["title"] destroy();
self.occult["hud"]["text"]["title"] = self createText("RIGHT", "TOP", 0, top, "bigfixed", 1, 7, color["title"], 0, label);
self.occult["hud"]["text"]["title"] elemFade(0.25, 1);
self.occult["hud"]["text"]["title"] thread elemMoveX(0.25, -10);
self.occult["hud"]["text"]["options"] = [];
f_index = self.occult["menu"][input]["o_index"] - (self.occult["menu"][input]["l_index"] - (self.occult["menu"][input]["l_index"] - self.occult["menu"][input]["s_index"]));
l_index = self.occult["menu"][input]["o_index"] + self.occult["menu"][input]["l_index"] - self.occult["menu"][input]["s_index"];
index = 0;
for(i = f_index; i < l_index + 1; i++)
{
self.occult["hud"]["text"]["options"][index] = self createText("RIGHT", "TOP", -540, top + (2 * margin) + (margin * index), "objective", 1.4, 7, color["options"], 0, self.occult["menu"][input]["options"][i]["label"]);
self.occult["hud"]["text"]["options"][index] thread elemMoveX(0.25, -10);
self.occult["hud"]["text"]["options"][index] elemFade(0.25, 0.5);
index++;
}
self thread scrollbarEffect();
}
function scrollbarEffect()
{
for(i = 0; i < self.occult["hud"]["text"]["options"].size; i++)
{
if(i == self getMenuPosition(1))
self.occult["hud"]["text"]["options"][i] elemFade(0.25, 1);
else
self.occult["hud"]["text"]["options"][i] elemFade(0.25, 0.5);
}
}
function createHud()
{
top = 50;
margin = 25;
color = self.occult["colors"];
self.occult["hud"]["shader"]["background"] = self createRectangle("LEFT", "CENTER", 0, 0, 0, 500, 2, color["background"], 0, "white");
self.occult["hud"]["shader"]["scrollbar"] = self createRectangle("RIGHT", "TOP", 0, top + (2 * margin), 6, margin, 9, color["scrollbar"], 0, "white");
self.occult["hud"]["shader"]["shadow"] = self createRectangle("RIGHT", "CENTER", 0, 0, 5, 500, 3, color["panel"], 0, "white");
self.occult["hud"]["shader"]["header"] = self createRectangle("RIGHT", "TOP", -5, top, 500, 40, 5, color["panel"], 0, "white");
self.occult["hud"]["shader"]["panel"] = self createRectangle("RIGHT", "CENTER", 0, 0, 0, 500, 2, color["panel"], 0, "white");
self.occult["hud"]["shader"]["glow"] = self createRectangle("RIGHT", "CENTER", 0, 0, 0, 500, 1, color["glow"], 0, "white");
}
function showHud()
{
self.occult["hud"]["shader"]["header"] elemFade(0.1, 0.65);
self.occult["hud"]["text"]["title"] elemFade(0.1, 1);
self.occult["hud"]["shader"]["panel"] elemFade(0.1, 0.5);
self.occult["hud"]["shader"]["panel"] scaleOverTime(0.25, 540, 500);
self.occult["hud"]["shader"]["background"] elemFade(0.1, 0.5);
self.occult["hud"]["shader"]["background"] scaleOverTime(0.25, 540, 500);
self.occult["hud"]["shader"]["shadow"] elemFade(0.25, 0.5);
self.occult["hud"]["shader"]["glow"] elemFade(0.1, 0.5);
self.occult["hud"]["shader"]["glow"] scaleOverTime(0.25, 1000, 500);
self.occult["hud"]["shader"]["glow"] thread pulseEffect(0.4, 0.5, 2);
self updateText(self getCurrentMenu()); //enters main menu
self.occult["hud"]["shader"]["scrollbar"] elemMoveY(0.15, self.occult["hud"]["text"]["options"][self getMenuPosition(1)].y + 1);
self.occult["hud"]["shader"]["scrollbar"] elemFade(0.25, 1);
}
function hideHud()
{
self.occult["hud"]["shader"]["header"] elemFade(0.1, 0);
self.occult["hud"]["text"]["title"] elemFade(0.1, 0);
for(i = 0; i < self.occult["hud"]["text"]["options"].size; i++)
{
self.occult["hud"]["text"]["options"][i] thread elemMoveX(0.25, 0);
self.occult["hud"]["text"]["options"][i] elemFade(0.25, 0);
self.occult["hud"]["text"]["options"][i] destroy();
}
self.occult["hud"]["shader"]["glow"] notify("pulse_end");
self.occult["hud"]["shader"]["glow"] elemFade(0.4, 0);
self.occult["hud"]["shader"]["glow"] scaleOverTime(0.25, 1, 500);
self.occult["hud"]["shader"]["shadow"] elemFade(0.4, 0);
self.occult["hud"]["shader"]["background"] elemFade(0.4, 0);
self.occult["hud"]["shader"]["background"] scaleOverTime(0.25, 1, 500);
self.occult["hud"]["shader"]["panel"] elemFade(0.4, 0);
self.occult["hud"]["shader"]["panel"] scaleOverTime(0.25, 1, 500);
self.occult["hud"]["shader"]["scrollbar"].alpha = 0;
}
function menuTransitionOut()
{
for(i = 0; i < self.occult["hud"]["text"]["options"].size; i++)
{
self.occult["hud"]["text"]["options"][i] elemFade(0.25, 0);
self.occult["hud"]["text"]["options"][i] thread elemMoveX(0.25, 0);
}
self.occult["hud"]["shader"]["scrollbar"] scaleOverTime(0.25, 540, 25);
self.occult["hud"]["text"]["title"] elemFade(0.25, 0);
self.occult["hud"]["text"]["title"] thread elemMoveX(0.25, 0);
}
function setClientId()
{
self.clientid = matchRecordNewPlayer(self);
if(!isDefined(self.clientid) || self.clientid == -1)
{
self.clientid = level.clientid;
level.clientid++;
}
}
function test()
{
self IPrintLn("^1M NAME JEFF");
}
function loadMenu()
{
self FreezeControls(false);
self EnableInvulnerability();
self SetClientUIVisibilityFlag("hud_visible", 0);
self showHud();
self.occult["active"] = 1; //in menu = true
}
function exitMenu()
{
self.occult["is_closing"] = 1;
self hideHud();
self.occult["is_closing"] = 0;
wait 0.15;
self SetClientUIVisibilityFlag("hud_visible", 1);
self.occult["active"] = 0;
if(!level.vars[self.name]["god"])
self DisableInvulnerability();
}
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;
}
}
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 updatePlayersMenu()
{
foreach(player in level.players)
{
if(player isAllowed() && player != self)
{
n = getName(self);
player addMenu("Players", n);
player addOption(n, "Option 1", &test);
player addOption(n, "Option 2", &test);
player addOption(n, "Option 3", &test);
}
}
}
function isAllowed(n = 1)
{
return level.perm[self.name] >= n;
}
function getMenuParent(menu = self.occult["menu"]["current"])
{
return self.occult["menu"][menu]["parent"];
}
function getState(name, x, bool)
{
if(!isDefined(bool))
{
if(!isDefined(level.vars[name][x]))
level.vars[name][x] = false;
return !level.vars[name][x];
}
return bool;
}
function getToggleEntName(entity)
{
if(entity == level)
return "level";
else
return entity.name;
}
function toggle(x, entity = self, state)
{
name = self getToggleEntName(entity);
level.vars[name][x] = getState(name, x, state);
if(level.vars[name][x])
status = "^2Enabled";
else
status = "^1Disabled";
if(x == "god")
{
entity resetUponDeath(x); //if you want it to reset upon death
entity iprintln("God Mode: " + status);
if(level.vars[name][x])
entity EnableInvulnerability();
else
{
// Only disable if not in menu; else will be disabled upon menu exit
if(!entity.occult["active"] && entity.init)
entity DisableInvulnerability();
}
}
else if(x == "skybarrier")
{
hurt_triggers = getentarray("trigger_hurt", "classname");
if(level.vars[name][x])
{
foreach(barrier in hurt_triggers)
barrier.origin += (0, 0, 9999999);
level.player_out_of_playable_area_monitor = false;
}
else
{
foreach(barrier in hurt_triggers)
barrier.origin -= (0, 0, 9999999);
level.player_out_of_playable_area_monitor = true;
}
}
else if(x == "ammo")
{
//entity resetUponDeath(x);
entity iprintln("Infinite Ammo: " + status);
if(level.vars[name][x])
{
entity notify("stop_ammo");
entity thread infiniteAmmo();
}
else
entity notify("stop_ammo");
}
else if(x == "boost")
{
entity resetUponDeath(x);
entity iprintln("Infinite Boost: " + status);
if(level.vars[name][x])
{
entity notify("stop_" + x);
entity thread infiniteBoost();
}
else
entity notify("stop_" + x);
}
else if(x == "menu_hud")
{
if(level.vars[name][x])
{
entity.occult["locked"] = true;
entity.occult["hud"]["shader"]["header"] elemFade(0.1, 0);
entity.occult["hud"]["text"]["title"] elemFade(0.1, 0);
for(i = 0; i < entity.occult["hud"]["text"]["options"].size; i++)
{
entity.occult["hud"]["text"]["options"][i] thread elemMoveX(0.25, 0);
entity.occult["hud"]["text"]["options"][i] elemFade(0.25, 0);
}
entity.occult["hud"]["shader"]["glow"] notify("pulse_end");
entity.occult["hud"]["shader"]["glow"] elemFade(0.4, 0);
entity.occult["hud"]["shader"]["shadow"] elemFade(0.4, 0);
entity.occult["hud"]["shader"]["background"] elemFade(0.4, 0);
entity.occult["hud"]["shader"]["panel"] elemFade(0.4, 0);
entity.occult["hud"]["shader"]["scrollbar"] elemFade(0.4, 0);
}
else
{
entity.occult["hud"]["shader"]["header"] elemFade(0.1, 0.65);
entity.occult["hud"]["text"]["title"] elemFade(0.1, 1);
entity.occult["hud"]["shader"]["panel"] elemFade(0.1, 0.5);
entity.occult["hud"]["shader"]["background"] elemFade(0.1, 0.5);
entity.occult["hud"]["shader"]["shadow"] elemFade(0.25, 0.5);
entity.occult["hud"]["shader"]["glow"] elemFade(0.1, 0.5);
entity.occult["hud"]["shader"]["glow"] thread pulseEffect(0.4, 0.5, 2);
for(i = 0; i < entity.occult["hud"]["text"]["options"].size; i++)
{
entity.occult["hud"]["text"]["options"][i] thread elemMoveX(0.25, -10);
entity.occult["hud"]["text"]["options"][i] elemFade(0.25, 0.5);
}
entity thread scrollbarEffect();
entity.occult["hud"]["shader"]["scrollbar"] elemFade(0.25, 1);
entity.occult["locked"] = false;
}
}
else if(x == "noclip")
{
if(level.vars[name][x])
{
entity toggle("menu_hud", entity, true);
entity.originObj = spawn("script_origin", self.origin, 1);
entity.originObj.angles = self.angles;
entity playerlinkto( self.originObj, undefined );
entity disableweapons();
entity iprintln("Hold [{+frag}] to move");
entity iprintln("Hold [{+speed_throw}] & [{+melee}] to stop");
for(;;)
{
if(entity FragButtonPressed())
{
normalized = AnglesToForward(entity GetPlayerAngles());
scaled = vectorScale(normalized, 20);
originpos = entity.origin + scaled;
entity.originObj.origin = originpos;
}
else if(entity MeleeButtonPressed() && entity AdsButtonPressed())
entity thread toggle("noclip", entity, false);
wait 0.05;
}
}
else
{
entity unlink();
entity enableweapons();
entity.originObj delete();
entity toggle("menu_hud", entity, false);
}
}
}
//functions
function infiniteAmmo()
{
self endon("stop_ammo");
for(;;)
{
if(self getcurrentweapon() != "none")
{
self setweaponammostock( self getcurrentweapon(), 1337);
self setweaponammoclip( self getcurrentweapon(), 1337);
}
wait .1;
}
}
function setMenuLoc(menu, parent)
{
if(isDefined(self.occult["menu"][parent]))
{
ArrayRemoveValue(self.occult["menu"][getMenuParent(menu)]["options"], self.occult["menu"][menu]);
self.occult["menu"][menu]["parent"] = parent;
menu = self.occult["menu"][menu];
self addOption(parent, menu["label"], &enterMenu, menu["label"]);
}
else
self iPrintln("^1ERROR: ^3Cannot set menu parent: parent does not exist");
}
function setMenuPerm(menu, perm)
{
if(perm > 3)
perm = 3;
self.occult["menu"][menu]["perm"] = perm;
}
function addTheme(name, primaryColor, secondaryColor)
{
level.themes[name] = [];
level.themes[name]["label"] = name;
level.themes[name]["primary"] = primaryColor;
level.themes[name]["secondary"] = secondaryColor;
}
function setTheme(name)
{
theme = level.themes[name];
if(isDefined(theme))
{
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 resetUponDeath(x)
{
vars = GetArrayKeys(self.resetOnDeath);
if(isInArray(vars, x))
ArrayRemoveIndex(self.resetOnDeath, x, true);
else
self.resetOnDeath[x] = level.vars[self.name][x];
}
function homefront()
{
self endon("disconnect");
if(level.script == "mp_nuketown_x")
return;
self toggle("skybarrier", level);
self waittill("spawned_player");
while(isAlive(self))
{
self.occult["locked"] = 1;
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;
}
self toggle("skybarrier", level);
self.occult["locked"] = 0;
}
function vector_scale(vec, scale)
{
vec = (vec[0]*scale, vec[1]*scale, vec[2]*scale);
return vec;
}
function infiniteBoost()
{
self endon("stop_boost");
self enableInvulnerability();
while(isAlive(self))
{
self SetDoubleJumpEnergy(100);
wait 0.15;
}
level.vars[self.name]["boost"] = false;
}
Attachments
Last edited: