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

Options in submenu won't show up

broken avatar :(
Created 7 years ago
by Cxwh
0 Members and 1 Guest are viewing this topic.
1,122 views
broken avatar :(
×
broken avatar :(
Location: at
Date Registered: 26 November 2016
Last active: 6 years ago
Posts
45
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Signature
12 year old music critic, quadrasexual Minecrafter, Linkin Park fan, Hentai enthusiast, intelligent atheist and vegan.
×
Cxwh's Groups
Cxwh's Contact & Social LinksCxwhModsGodAspire
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"));
}

 
Loading ...