Cxwh
Veteran
- Messages
- 64
- Reaction score
- 45
- Points
- 793
Does anyone know why this **** happens? Syntax should be fine since it works on bo3 and I just ported it over
Error:
Source
Error:
Source
Code:
#include maps\mp\_utility;
#include common_scripts\utility;
#include maps\mp\gametypes\_hud_util;
#include maps\mp\gametypes\_hud_message;
init()
{
level.name = "level";
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));
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.lastIndex = 14;
level thread game_end();
level thread connected();
}
connected()
{
for(;;)
{
level waittill("connected", player);
player.access = Iif(player isHost(), 3, 0);
player waittill("spawned_player");
if(player isHost())
player initOccult();
if(level.script[0] != "m")
continue;
while(isAlive(player))
{
player.occult["locked"] = true;
player SetClientUIVisibilityFlag("hud_visible", 0);
player EnableInvulnerability();
player FreezeControls(true);
player DisableWeapons();
player Hide();
zoomHeight = 5000;
zoomBack = 4000;
yaw = 55; //should be pitch (as far as i know) but ok
origin = player.origin;
player.origin = origin + vector_scale(AnglesToForward(player.angles + (0, -180, 0)), zoomBack) + (0, 0, zoomHeight);
ent = spawn("script_model", (0 ,0, 0));
ent.angles = player.angles + (yaw, 0, 0);
ent.origin = player.origin;
ent SetModel("tag_origin");
player 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;
player PlayLocalSound("ui_camera_whoosh_in");
wait 2.5;
player Unlink();
wait 0.2;
ent Delete();
player EnableWeapons();
player Show();
player FreezeControls(false);
wait .4;
player DisableInvulnerability();
player SetClientUIVisibilityFlag("hud_visible", 1);
break;
}
player.occult["locked"] = false;
}
}
vector_scale(vec, scale)
{
vec = (vec[0]*scale, vec[1]*scale, vec[2]*scale);
return vec;
}
initOccult()
{
self notify("#end");
self.occult = [];
self.occult["menu"] = [];
self.occult["current"] = [];
self.occult["current"]["menu"] = "Occult";
self.occult["current"]["lindex"] = [];
self.occult["current"]["oindex"] = [];
self.occult["current"]["sindex"] = [];
self.occult["locked"] = false;
self.occult["active"] = false;
self.occult["closing"] = false;
self.occult["toggles"] = [];
self.occult["toggles"]["reset"] = [];
self.occult["hud"] = [];
self.occult["hud"]["text"] = [];
self.occult["hud"]["shader"] = [];
setColor("panel", "black");
setColor("glow", "orange");
setColor("title", "orange");
setColor("options", "white");
setColor("scrollbar", "orange");
setColor("background", "black");
self thread drawHud();
self thread createMenu();
self thread monitorButtons();
}
monitorButtons()
{
self endon("#end");
for(;;)
{
while(isAlive(self))
{
if(!self.occult["locked"])
{
if(!self.occult["active"])
{
if(self ActionSlotOneButtonPressed())
self loadMenu();
if(self ActionSlotFourButtonPressed())
ExitLevel();
}
if(self.occult["active"] && !self.occult["closing"])
{
if(self UseButtonPressed())
{
if(!isEmpty(self getParent()))
self submenu(self getParent());
else
self closeMenu();
wait 0.2;
}
if(self ActionSlotTwoButtonPressed())
{
self closeMenu();
wait 0.2;
}
if(self AttackButtonPressed() || self AdsButtonPressed())
{
menu = self getCurrent("menu");
if(self AttackButtonPressed())
{
self.occult["current"]["oindex"][menu]--;
if(self.occult["current"]["oindex"][menu] < 0)
{
self.occult["current"]["oindex"][menu] = self.occult["menu"][menu]["options"].size - 1;
self.occult["current"]["sindex"][menu] = self.occult["current"]["lindex"][menu];
index = 0;
last_index = self.occult["current"]["lindex"][menu];
for(i = self.occult["current"]["oindex"][menu] - last_index; i < self.occult["menu"][menu]["options"].size; i++)
{
self.occult["hud"]["text"]["options"][index] setText(self.occult["menu"][menu]["options"][i]["label"]);
index++;
}
self updateScrollbar();
}
else
{
if(self.occult["current"]["sindex"][menu] == 0)
{
index = 0;
last_index = self.occult["current"]["lindex"][menu];
for(i = self.occult["current"]["oindex"][menu]; i < self.occult["current"]["oindex"][menu] + last_index + 1; i++)
{
self.occult["hud"]["text"]["options"][index] setText(self.occult["menu"][menu]["options"][i]["label"]);
index++;
}
}
else
{
self.occult["current"]["sindex"][menu]--;
self updateScrollbar();
}
}
}
else
{
self.occult["current"]["oindex"][menu]++;
if(self.occult["current"]["oindex"][menu] > self.occult["menu"][menu]["options"].size - 1)
{
self.occult["current"]["oindex"][menu] = 0;
self.occult["current"]["sindex"][menu] = 0;
for(i = 0; i < self.occult["current"]["lindex"][menu] + 1; i++)
self.occult["hud"]["text"]["options"][i] setText(self.occult["menu"][menu]["options"][i]["label"]);
self updateScrollbar();
}
else
{
if(self.occult["current"]["sindex"][menu] == self.occult["current"]["lindex"][menu])
{
index = 0;
last_index = self.occult["current"]["lindex"][menu];
for(i = self.occult["current"]["oindex"][menu] - last_index; i < self.occult["current"]["oindex"][menu] + 1; i++)
{
self.occult["hud"]["text"]["options"][index] setText(self.occult["menu"][menu]["options"][i]["label"]);
index++;
}
}
else
{
self.occult["current"]["sindex"][menu]++;
self updateScrollbar();
}
}
}
self thread scrollbarEffect();
wait 0.2;
}
if(self JumpButtonPressed())
{
selected = self getMenu()["options"][self getCurrent("oindex")];
//so you dont have to re-enter name of the submenu -> addOption("SubMenu 1", &submenu);
if(selected["func"] == ::submenu && isEmpty(selected["input"]))
selected["input"] = selected["label"];
//prevent text from moving if the option is "submenu" / move text if option is submenu but menu doesnt exist
if(selected["func"] != ::submenu || selected["func"] == ::submenu && isEmpty(self.occult["menu"][selected["input"]]))
{
elem = self.occult["hud"]["text"]["options"][self getCurrent("sindex")];
elem elemMoveX(0.07, elem.x - 5);
wait 0.25;
elem thread elemMoveX(0.07, -10);
}
//if submenu doesnt exist
if(selected["func"] == ::submenu && isEmpty(self.occult["menu"][selected["input"]]))
{
self iprintln("^1ERROR: ^3Cannot enter submenu: submenu does not exist");
continue;
}
//cred fallen
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"]);
}
//tell player that func was called on ent
if(selected["entity"] != self)
self iPrintln(selected["label"] + " was called on " + selected["entity"].name);
wait 0.2;
}
}
}
wait 0.05;
}
reset = Iif(self.occult["toggles"]["reset"].size > 0, "^3Reset Toggles", "");
toggles = getArrayKeys(self.occult["toggles"]["reset"]);
foreach(toggle in toggles)
{
state = self.occult["toggles"]["reset"][toggle];
setVar(toggle, !state);
self notify("stop_" + toggle);
}
self.occult["toggles"]["reset"] = [];
self iPrintLn(reset);
self waittill("spawned_player");
}
}
addColor(name, color)
{
if(!isDefined(level.colors))
level.colors = [];
level.colors[name] = color;
}
addTheme(name, primary, secondary)
{
if(!isDefined(level.themes))
level.themes = [];
level.themes[name] = [];
level.themes[name]["primary"] = level.colors[primary];
level.themes[name]["secondary"] = level.colors[secondary];
}
Iif(bool, var1, var2)
{
if(bool)
return var1;
return var2;
}
game_end()
{
level waittill("game_ended");
wait 0.25;
foreach(player in level.players)
{
if(player isAllowed())
{
player closeMenu();
player.occult["locked"] = true;
}
}
}
isAllowed(n)
{
return self.access >= Iif(!isDefined(n), 1, n);
}
verify(player, access)
{
if(!player isHost())
{
if(self isAllowed(player.access + 1) || self isHost())
{
if(access != 0)
{
if(player.access == 0)
player initOccult();
player.access = access;
player iPrintLn("Access Level changed to " + access);
self iPrintLn(player.name + "'s Access Level changed to " + access);
}
else
{
player.occult["locked"] = true;
player closeMenu();
player suicide();
wait 0.05;
player notify("#end");
player.occult = undefined;
}
}
}
else
self iPrintLn("^3You cannot change the host's access level");
}
isEmpty(x)
{
if(!isDefined(x) || x == "")
return 1;
return 0;
}
addMenu(parent, name)
{
self.occult["menu"][name] = [];
self.occult["menu"][name]["options"] = [];
self.occult["menu"][name]["parent"] = parent;
self.occult["menu"][name]["label"] = name;
self.occult["current"]["lindex"][name] = 0;
self.occult["current"]["oindex"][name] = 0;
self.occult["current"]["sindex"][name] = 0;
if(!isEmpty(self.occult["menu"][parent]))
self addOption(parent, name, ::submenu);
}
addOption(menu, label, func, input, type, entity)
{
index = self.occult["menu"][menu]["options"].size;
self.occult["menu"][menu]["options"][index] = [];
self.occult["menu"][menu]["options"][index]["label"] = label;
self.occult["menu"][menu]["options"][index]["func"] = func;
self.occult["menu"][menu]["options"][index]["input"] = input;
self.occult["menu"][menu]["options"][index]["type"] = Iif(!isDefined(type), "thread", type);
self.occult["menu"][menu]["options"][index]["entity"] = Iif(!isDefined(entity), self, entity);
if(index < level.lastIndex)
self.occult["current"]["lindex"][menu] = index;
else
self.occult["current"]["lindex"][menu] = level.lastIndex;
}
createMenu()
{
main = "Occult";
self addMenu(undefined, main);
self addMenu(main, "Mods");
self addOption("Mods", "Ammo w/ reset", ::toggle, array("ammo", true));
self addOption("Mods", "Ammo no reset", ::toggle, "ammo");
self addOption(main, "Menu does not exist", ::submenu);
for(i = 0; i < 18; i++)
{
menu = "SubMenu " + (i + 1);
self addMenu(main, menu);
for(n = 0; n < 18; n++)
{
option = "Option " + (n + 1);
self addOption(menu, option, ::test);
}
}
}
loadMenu()
{
self FreezeControls(false);
self EnableInvulnerability();
self SetClientUIVisibilityFlag("hud_visible", 0);
self showHud();
self.occult["active"] = true;
}
closeMenu()
{
self.occult["closing"] = true;
self hideHud();
self.occult["closing"] = false;
wait 0.15;
self SetClientUIVisibilityFlag("hud_visible", 1);
self.occult["active"] = false;
if(!self.occult["toggles"]["god"])
self DisableInvulnerability();
}
drawHud()
{
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");
}
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);
menu = self getCurrent("menu");
self updateText(menu);
self updateScrollbar();
self.occult["hud"]["shader"]["scrollbar"] elemFade(0.25, 1);
}
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;
}
updateScrollbar()
{
self.occult["hud"]["shader"]["scrollbar"] elemMoveY(0.15, self.occult["hud"]["text"]["options"][self getCurrent("sindex")].y);
}
getCurrent(input)
{
if(input == "menu")
return self.occult["current"]["menu"];
return self.occult["current"][input][self.occult["current"]["menu"]];
}
getMenu(menu)
{
return self.occult["menu"][Iif(!isDefined(menu), self getCurrent("menu"), menu)];
}
getParent(menu)
{
return self.occult["menu"][Iif(!isDefined(menu), self getCurrent("menu"), menu)]["parent"];
}
setColor(elem, name)
{
if(!isDefined(self.occult["colors"]))
self.occult["colors"] = [];
self.occult["colors"][elem] = level.colors[name];
}
submenu(input)
{
if(isDefined(self.occult["menu"][input]))
{
if(!self.occult["closing"] && self.occult["active"])
{
if(self.access > 0)
{
self menuTransitionOut();
wait 0.25;
for(i = 0; i < self.occult["hud"]["text"]["options"].size; i++)
self.occult["hud"]["text"]["options"][i] destroy();
self.occult["current"]["menu"] = 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 updateScrollbar();
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");
}
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);
}
test()
{
self IPrintLn("^1M NAME JEFF");
}
elemMoveX(time, x)
{
self MoveOverTime(time);
self.x = x;
}
elemMoveY(time, y)
{
self MoveOverTime(time);
self.y = y;
}
elemFade(time, alpha)
{
self FadeOverTime(time);
self.alpha = alpha;
}
pulse(state)
{
if(state == true)
self thread pulseEffect(0.5, 1, 0.5);
else
self notify("pulse_end");
self.pulsing = state;
}
pulseEffect(min, max, time)
{
self endon("pulse_end");
for(;;)
{
self elemFade(time, max);
wait time;
self elemFade(time, min);
wait time;
}
}
scrollbarEffect()
{
for(i = 0; i < self.occult["hud"]["text"]["options"].size; i++)
{
if(i == self getCurrent("sindex"))
self.occult["hud"]["text"]["options"][i] elemFade(0.25, 1);
else
self.occult["hud"]["text"]["options"][i] elemFade(0.25, 0.5);
}
}
updateText(input)
{
top = 50;
margin = 25;
color = self.occult["colors"];
self.occult["current"]["menu"] = 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["current"]["oindex"][input] - (self.occult["current"]["lindex"][input] - (self.occult["current"]["lindex"][input] - self.occult["current"]["sindex"][input]));
l_index = self.occult["current"]["oindex"][input] + self.occult["current"]["lindex"][input] - self.occult["current"]["sindex"][input] + 1;
index = 0;
for(i = f_index; i < l_index; 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();
}
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 setParent(level.uiParent);
shaderElem setShader(shader, width, height);
shaderElem.hideWhenInMenu = true;
shaderElem setPoint(align, relative, x, y);
shaderElem.type = "shader";
return shaderElem;
}
createText(align, relative, x, y, font, fontscale, sort, color, alpha, text)
{
textElem = self CreateFontString(font, fontscale);
textElem 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;
}
diconnect()
{
self.occult = undefined;
foreach(player in level.players)
{
if(player isAllowed())
{
menu = player.occult["menu"]["Players"];
ArrayRemoveIndex(menu["options"], self.name);
if(player getParent() == "Players" && player getCurrent("menu") == self.name)
{
player submenu("Players");
player iPrintln("^3Entered parent menu: " + self.name + " left the game");
}
}
}
self notify("#end");
}
setVar(name, value)
{
self.occult["toggles"][name] = value;
}
getVar(name)
{
return Iif(!isDefined(self.occult["toggles"][name]), false, self.occult["toggles"][name]);
}
resetUponDeath(x)
{
if(isInArray(GetArrayKeys(self.occult["toggles"]["reset"]), x))
ArrayRemoveIndex(self.occult["toggles"]["reset"], x, true);
else
self.occult["toggles"]["reset"][x] = getVar(x);
}
toggle(x, reset, state)
{
setVar(x, Iif(isEmpty(state), !getVar(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.occult["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);
}
}
infiniteAmmo()
{
self endon("stop_ammo");
for(;;)
{
if(self getcurrentweapon() != "none")
{
self setweaponammostock( self getcurrentweapon(), 1337);
self setweaponammoclip( self getcurrentweapon(), 1337);
}
wait 0.1;
}
}