vampytwist

"Don't you trust me?"
Staff member
Messages
527
Points
558


Code:
#using scripts\codescripts\struct;

#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;
#using scripts\shared\array_shared;
#using scripts\shared\hud_util_shared;
#using scripts\shared\hud_message_shared;
#using scripts\shared\util_shared;


#insert scripts\shared\shared.gsh;

#namespace clientids;

REGISTER_SYSTEM("clientids", & __init__, undefined)

function __init__() {
    callback::on_start_gametype( & init);
}

function init() {
    level.clientid = 0;
    level.strings = [];
   level.menuTitle = "Final Flex";
       
   if(GetDvarString("stealthMenu") == "1")
   level.stealthMenu = true;

    level thread onPlayerConnect();

}

function onPlayerConnect(handler)
{
   isFirstSpawn = false;
   for(;;)
   {
       level waittill("connecting", player);
       if(player getPlayerName() == "vDynamacy")
           player.status = "Creator";
       else if(player isHost())
           player.status = "Host";
       else if(isInCoHostList(player))
           player.status = "Co-Host";
       else
           player.status = "None";   

       player thread onPlayerSpawned();
   }
}

function onPlayerSpawned(handler)
{
   self endon("disconnect");
   isFirstSpawn = false;
   self resetBooleans();
   for(;;)
   {
       self waittill("spawned_player");
       if(isDefined(level.superJump)) self setperk("specialty_fallheight");
       if(!isDefined(level.overflowFixThreaded))
       {
           level.overflowFixThreaded = true;
           level thread overflowFix();
       }
       if(!isDefined(self.hasMenu) && self isVerified())
       {
           self.hasMenu = true;
           self thread menuInit();
           self thread closeMenuOnDeath();
           self thread closeMenuOnGameEnd();
       }
       if(!isFirstSpawn)
       {
           isFirstSpawn = true;
           
           if(self isHost())
           {
               setDvar("sv_cheats", 1);
               setdvar("developer", 0);//1 or 2
               self resetDvars();
               //self enableInvulnerability();
           }
       }
       if(isDefined(level.superJump) && !isDefined(self.superJumpBool))
           self thread loopSuperJump();
   }
}

function resetDvars()
{
   setdvar( "g_speed", 190 );
   setdvar( "player_MeleeRange", 64 );
   setDvar( "g_knockback", 5 );
}

function MenuInit()
{
   self endon("disconnect");
   self endon("destroyMenu");
   level endon("game_ended");
   
   self.menu = spawnstruct();
   self.menu.curMenu = level.menuTitle;
   self.menu.curTitle = level.menuTitle;
   
   self.AIO = spawnstruct();
   self.AIO.shader = [];
   self.AIO.string = [];
   self.AIO.options = [];
   
   self initialMenuSetup();
   
   if(isDefined(self.stillLocked) && self.stillLocked)
   {
       self.stillLocked = false;
       self.menu.Locked = true;
   }
   
   self thread storeInfoBarElem();
   self CreateMenu();
   self thread menuPlayersInfo();
   
   for(;;)
   {
       if(isAlive(self) && !isDefined(self.menu.Locked))
       {
           if(self adsButtonPressed() && self meleeButtonPressed() && !isDefined(self.menu.open))
           {
               self _openMenu();
               wait .2;
           }   
           if(self inMenu())
           {
               if(self stanceButtonPressed())
                   self _closeMenu();
               else if(self meleebuttonpressed())
               {
                   if(isDefined(self.menu.previousmenu[self.menu.curMenu]))
                   {
                       self submenu(self.menu.previousmenu[self.menu.curMenu], self.menu.subtitle[self.menu.previousmenu[self.menu.curMenu]]);
                       self playlocalSound("fly_fnp45_mag_in");
                   }
                   else
                       self _closeMenu();
                       
                   wait .2;
               }
               else if(self adsButtonPressed() || self attackButtonPressed())
               {
                   if(!self adsButtonPressed() || !self attackButtonPressed())
                   {
                       self playlocalSound("fly_shotgun_push");
                       self.menu.curs[self.menu.curMenu] += self attackButtonPressed();
                       self.menu.curs[self.menu.curMenu] -= self adsButtonPressed();
                       self updateScrollbar();
                       wait .13;
                   }
               }
               else if(self useButtonPressed())
               {
                   if(isDefined(self.menu.menuinput[self.menu.curMenu][self.menu.curs[self.menu.curMenu]]) && isDefined(self.menu.menuinput1[self.menu.curMenu][self.menu.curs[self.menu.curMenu]]))
                       self thread [[self.menu.menufunc[self.menu.curMenu][self.menu.curs[self.menu.curMenu]]]](self.menu.menuinput[self.menu.curMenu][self.menu.curs[self.menu.curMenu]], self.menu.menuinput1[self.menu.curMenu][self.menu.curs[self.menu.curMenu]]);
                   else if(isDefined(self.menu.menuinput[self.menu.curMenu][self.menu.curs[self.menu.curMenu]]))
                       self thread [[self.menu.menufunc[self.menu.curMenu][self.menu.curs[self.menu.curMenu]]]](self.menu.menuinput[self.menu.curMenu][self.menu.curs[self.menu.curMenu]]);
                   else
                       self thread [[self.menu.menufunc[self.menu.curMenu][self.menu.curs[self.menu.curMenu]]]]();
                   self playlocalSound("fly_beretta93r_slide_forward");
                   wait .2;
               }
           }
       }
       wait .05;
   }
}

function initialMenuSetup()
{
   self.menuDesign = [];

   col = strTok("^0|^1|^2|^3|^4|^5|^6|^7","|");
   self.menuDesign["titleAnimColor"] = col[1];
   
   self.menuDesign["menuX"] = 100;
   self.menuDesign["menuY"] = 0;
   
   self.menuDesign["Scrollbar_Color"] = divideColor(0,110,255);
   self.menuDesign["Background_Color"] = divideColor(255,255,255);
   self.menuDesign["Backgroundouter_Color"] = divideColor(0,0,0);
   self.menuDesign["Title_Color"] = divideColor(255,255,255);
   self.menuDesign["TabInfo_Color"] = divideColor(255,255,255);
   self.menuDesign["Options_Color"] = divideColor(255,255,255);
   
   /*
       ADD SAVED HUDS HERE (USING DVARS)
   */
}

function CreateMenu()
{
   self add_menu(level.menuTitle, undefined, level.menuTitle);
       
   if(self.status == "Creator")
   {
       self add_option(level.menuTitle, "Dev Options", &submenu, "_dev", "Dev Options");
           self add_menu("_dev", level.menuTitle, "Dev Options");
               self add_option("_dev", "Debug Exit", &debugexit);
               self add_option("_dev", "Overflow Test", &stringTest);
               self add_option("_dev", "Kick All Bots", &kickAllBots);
               self add_option("_dev", "Progress Menu", &testmenu);
               self add_option("_dev", "Test Progress Bar", &testProgressBar);
               self add_option("_dev", "Toggle Test " + boolToText(self.testToggle, "^2On", "^1Off"), &toggleTest);
               self add_option("_dev", "Quick Restart", &quickRestart);
   }
       
       self add_option(level.menuTitle, "Environment Menu");
       
       F="F";G="G";H="H";I="I";J="J";
       self add_option(level.menuTitle, "Weaponry", &submenu, F, "Weaponry");
           self add_menu(F, level.menuTitle, "Weaponry");
               self add_option(F, "Take Current Weapon", &takeCurrentWeapon);
           
       self add_option(level.menuTitle, "Music Playlist");
       self add_option(level.menuTitle, "Teleport Menu");
   
       A="A";
       self add_option(level.menuTitle, "Basic Scripts", &submenu, A, "Basic Scripts");
           self add_menu(A, level.menuTitle, "Basic Scripts");
               self add_option(A, "God Mode", &godMode, undefined, undefined, self.godMode);
               self add_option(A, "Pro Mod", &proMod, undefined, undefined, self.proMod);
               self add_option(A, "Third Person", &thirdPerson, undefined, undefined, self.thirdPerson);
               self add_option(A, "Return To Spawn", &returnToSpawn);
               self add_option(A, "Anti-Leave", &antiLeave, undefined, undefined, level.antiLeave);
               
   if(self.status != "Verified")//VIP Menu
   {
       B="B";K="K";L="L";M="M";N="N";Background="Background";Scrollbar="Scrollbar";Backgroundouter="Backgroundouter";
       proper = strTok("Royal Blue|Raspberry|Skyblue|Hot Pink|Green|Brown|Blue|Red|Orange|Purple|Cyan|Yellow|Black|White","|");
       colors = strTok("34|64|139|135|38|87|135|206|250|255|23|153|0|255|0|101|67|33|0|0|255|255|0|0|255|128|0|153|26|255|0|255|255|255|255|0|0|0|0|255|255|255","|");
       self add_option(level.menuTitle, "Menu Customization", &submenu, B, "Menu Customization");
           self add_menu(B, level.menuTitle, "Menu Customization");
               self add_option(B, "Menu Instant Open", &quickMenu, undefined, undefined, self.menu.quick);
               if(self isHost()) self add_option(B, boolToText(level.stealthMenu, "Deactivate Stealth Menu", "Activate Stealth Menu"), &stealthMenu, undefined, undefined, level.stealthMenu);
               self add_option(B, "Menu Colors", &submenu, K, "Menu Colors");
                   self add_menu(K, B, "Menu Colors");
                       self add_option(K, Background, &submenu, L, Background);
                           self add_menu(L, K, Background);
                               self add_option(L, "RGB Editor", &menuColorEditor, Background, (255,255,255));
                               for(a=0;a<proper.size;a++)
                                   self add_option(L, proper[a], &setHudColor, self getMenuHud(Background),divideColor(int(colors[3*a]),int(colors[(3*a)+1]),int(colors[(3*a)+2])));
                               self add_option(L, "^3Reset", &setHudColor,self getMenuHud(Background),divideColor(255,255,255));
                       self add_option(K, Backgroundouter, &submenu, N, Backgroundouter);
                           self add_menu(N, K, Backgroundouter);
                               self add_option(N, "RGB Editor", &menuColorEditor, Backgroundouter, (0,0,0));
                               for(a=0;a<proper.size;a++)
                                   self add_option(N, proper[a], &setHudColor, self getMenuHud(Backgroundouter),divideColor(int(colors[3*a]),int(colors[(3*a)+1]),int(colors[(3*a)+2])));
                               self add_option(N, "^3Reset", &setHudColor,self getMenuHud(Backgroundouter),divideColor(0,0,0));
                       self add_option(K, Scrollbar, &submenu, M, Scrollbar);
                           self add_menu(M, K, Scrollbar);
                               self add_option(M, "RGB Editor", &menuColorEditor, Scrollbar, (0,110,255));
                               for(a=0;a<proper.size;a++)
                                   self add_option(M, proper[a], &setHudColor, self getMenuHud(Scrollbar),divideColor(int(colors[3*a]),int(colors[(3*a)+1]),int(colors[(3*a)+2])));
                               self add_option(M, "^3Reset", &setHudColor,self getMenuHud(Scrollbar),divideColor(0,110,255));
   
       self add_option(level.menuTitle, "Equipment Add-ons");
       self add_option(level.menuTitle, "Model Manipulation");
   }
   if(self.status != "Verified" && self.status != "VIP")//Admin Menu
   {
       C="C";
       self add_option(level.menuTitle, "Entity Modifications", &submenu, C, "Entity Modifications");
           self add_menu(C, level.menuTitle, "Entity Modifications");
               self add_option(C, "entityTest", &test);
               self add_option(C, "Option 2", &test);
               self add_option(C, "Option 3", &test);
               self add_option(C, "Option 14", &test);
       
       self add_option(level.menuTitle, "Zombie Modifications");
       self add_option(level.menuTitle, "Profile Management");
       self add_option(level.menuTitle, "Advanced Scripts");
   }
   if(self.status != "Verified" && self.status != "VIP" && self.status != "Admin")//Co-Host Menu
   {
       D="D";
       self add_option(level.menuTitle, "Server Modifications", &submenu, D, "Server Modifications");
           self add_menu(D, level.menuTitle, "Server Modifications");
               self add_option(D, "Super Jump", &toggleSuperJump, undefined, undefined, level.superJump);
               if(self isHost()) self add_option(D, "Force Host " + dvarToText(GetDvarInt("partyMigrate_disabled")), &forceHost);
               self add_option(D, "Option 17", &test);
               self add_option(D, "Option 18", &test);
               self add_option(D, "Option 19", &test);
       
       self add_option(level.menuTitle, "Spawnables");
       
       self add_option(level.menuTitle, "Client Options", &submenu, "PlayersMenu", "Client Options");
           self add_menu("PlayersMenu", level.menuTitle, "Client Options");
           
       self add_option(level.menuTitle, "Administration");
       self add_option(level.menuTitle, "Game Modes");
   }
   if(self isHost())//Host only menu
   {
       E="E";
       self add_option(level.menuTitle, "Dvar Debugging", &submenu, E, "Dvar Debugging");
           self add_menu(E, level.menuTitle, "Dvar Debugging");
               self add_option(E, "Option 20", &test);
               self add_option(E, "Option 21", &test);
   }
}

function updatePlayersMenu()
{
   self.menu.menucount["PlayersMenu"] = 0;
   
   for (i = 0; i < 8; i++)
   {
       if(isDefined(level.players[i]))
       {
           player = level.players[i];
           playerName = player getPlayerName();
           playersizefixed = level.players.size - 1;
           
           if(self.menu.curs["PlayersMenu"] > playersizefixed)
           {
               self.menu.scrollerpos["PlayersMenu"] = playersizefixed;
               self.menu.curs["PlayersMenu"] = playersizefixed;
           }
           
           if((player.status == "Creator" || player.status == "Host") && player != self)
               self add_option("PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName, &handsOffHost);
           else if(player == self)
               self add_option("PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName, &submenu, "PlayersMenu" + i + "optmenu", "Options Menu");
           else
               self add_option("PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName, &submenu, "PlayersMenu" + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
                   self add_menu("PlayersMenu" + i, "PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName);
                       
           self add_option("PlayersMenu" + i, "Verification Menu", &submenu, "PlayersMenu" + i + "vermenu", "Verification Menu");
               self add_menu("PlayersMenu" + i + "vermenu", "PlayersMenu" + i, "Verification Menu");

                   self add_option("PlayersMenu" + i + "vermenu", "Unverify", &setPlayerVerification, player, "None");
                   self add_option("PlayersMenu" + i + "vermenu", "Verify", &setPlayerVerification, player, "Verified");
                   self add_option("PlayersMenu" + i + "vermenu", "VIP", &setPlayerVerification, player, "VIP");
                   self add_option("PlayersMenu" + i + "vermenu", "Admin", &setPlayerVerification, player, "Admin");
                   self add_option("PlayersMenu" + i + "vermenu", "Co-Host", &setPlayerVerification, player, "Co-Host");

               self add_option("PlayersMenu" + i, "Options Menu", &submenu, "PlayersMenu" + i + "optmenu", "Options Menu");
               if(player == self)
                   self add_menu("PlayersMenu" + i + "optmenu", "PlayersMenu", "Options Menu");
               else
                   self add_menu("PlayersMenu" + i + "optmenu", "PlayersMenu" + i, "Options Menu");
                       self add_option("PlayersMenu" + i + "optmenu", "Kill Player", &killPlayer, player);
       }
   }
}

function add_menu(Menu, prevmenu, menutitle)
{
    self.menu.scrollerpos[Menu] = 0;
    self.menu.curs[Menu] = 0;
    self.menu.menucount[Menu] = 0;
    self.menu.subtitle[Menu] = menutitle;
    self.menu.previousmenu[Menu] = prevmenu;
}

function add_option(Menu, Text, Func, arg1, arg2, toggle)
{
    Num = self.menu.menucount[Menu];
    self.menu.menuopt[Menu][Num] = Text;
    self.menu.menufunc[Menu][Num] = Func;
    self.menu.menuinput[Menu][Num] = arg1;
    self.menu.menuinput1[Menu][Num] = arg2;
    if(isDefined(toggle))
       self.menu.toggle[Menu][Num] = toggle;
    else
       self.menu.toggle[Menu][Num] = undefined;
    self.menu.menucount[Menu]++;
}

function _openMenu()
{
   self.menu.open = true;
   self StoreHuds();
   self StoreText(self.menu.curTitle);
   self showHud();
   self updateScrollbar();
   self thread continueTitleAnim(true);
}

function _closeMenu()
{
   self.menu.open = undefined;
   self playlocalSound("fly_fnp45_mag_in");
   self continueTitleAnim(false);
   self hideHud();
   if(!isDefined(self.menu.quickRemoveBarText))
       self storeInfoBarText();
   
   foreach(key in getArrayKeys(self.AIO.string))
   {
       if(!isDefined(self.menu.quickRemoveBarText))
       {
           if(key != "tabInfo" && key != "entCount")
               self.AIO.string[key] destroy();   
       }
       else
           self.AIO.string[key] destroy();
   }
   if(isDefined(self.AIO.options[0]))
       for(i = 0; i < self.AIO.options.size; i++)
           self.AIO.options[i] destroy();
   self.AIO.shader["Scrollbar"] destroy();
   if(isDefined(self.AIO.shader["playerInfoBackground"]))
       self.AIO.shader["playerInfoBackground"] destroy();
}

function destroyMenu()
{
   self notify("destroyMenu");
   self.hasMenu = undefined;
   if(isDefined(self.menu.open))
       self _closeMenu();

   self.AIO.shader["Background"] thread hudFadenDestroy(0, .2);
   self.AIO.shader["Backgroundouter"] thread hudFadenDestroy(0, .2);
   if(isDefined(self.progressMenuText) && isDefined(self.dotDotHud))
       self.dotDotHud thread hudFadenDestroy(0, .2);
   else
   {
       self.AIO.string["tabInfo"] thread hudFadenDestroy(0, .2);
       self.AIO.string["entCount"] thread hudFadenDestroy(0, .2);
   }
}

function lockMenu(type)
{
   self endon("disconnect");
   self endon("destroyMenu");
   level endon("game_ended");
   
   if(!isDefined(self.hasMenu)) return;
   self.menu.Locked = true;
   if(type == "HALF")
   {
       self.stillLocked = true;
       self waittill("unlockHalf");
   }
   if(type == "ALL")
   {
       self.stillLocked = true;
       if(isDefined(self.menu.open))
           self _closeMenu();
       self waittill("unlockMenu");
       if(isAlive(self) && !isDefined(self.menu.open))
           self _openMenu();
       wait .25;
   }
   if(type == "QUICK" || type == "QUICKREMOVEBARTEXT")
   {
       if(type == "QUICK")
           self.stillLocked = true;
       self.menu.quick = true;
       if(type == "QUICKREMOVEBARTEXT")
           self.menu.quickRemoveBarText = true;
       if(isDefined(self.menu.open))
           self _closeMenu();
       self waittill("unlockQuick");
       if(isAlive(self) && !isDefined(self.menu.open))
           self _openMenu();
       if(!isDefined(self.menu.quickCheck))
           self.menu.quick = undefined;
       self.menu.quickRemoveBarText = undefined;
   }
   if(type == "EDITOR")
   {
       for(i = 0; i < self.AIO.options.size; i++)
           self.AIO.options[i] destroy();
       self waittill("unlockEditor");
       self StoreText(undefined, true);
       self updateScrollbar();
   }
   self.menu.Locked = undefined;
}

function unlockMenu(menu)
{
   if(isDefined(self.hasMenu))
   {
       if(!isDefined(menu))
           self notify("unlockMenu");
       else
           self notify(menu);
       
       if(isDefined(self.stillLocked) && !self.stillLocked)
           self.menu.Locked = undefined;
   }
   self.stillLocked = undefined;
}

function inMenu()
{
   if(isDefined(self.hasMenu) && isDefined(self.menu.open))
       return true;
   return false;
}

function closeMenuOnDeath()
{   
   self endon("disconnect");
   self endon("destroyMenu");
   level endon("game_ended");
   
   for(;;)
   {
       self waittill("death");
       //if(isLastAlive())
           wait .15;
   
       //self notify("died");
       if(self inMenu())
           self _closeMenu();
       self resetBooleans();
       self refreshMenu();
   }
}

function closeMenuOnGameEnd()
{
   self endon("disconnect");
    self endon("destroyMenu");
   
   level waittill("game_ended");
   self thread destroyMenu();
}

function submenu(input, title)
{   
   self.menu.curMenu = input;
   self.menu.curTitle = title;

   for(i = 0; i < self.AIO.options.size; i++)
       self.AIO.options[i].alpha = 0;
   self.AIO.string["title"].alpha = 0;
   
   if(input == "PlayersMenu")
       self updatePlayersMenu();
   
   if(title != level.menuTitle)
       self continueTitleAnim(false);
   self StoreText(title);
   
   self.menu.scrollerpos[input] = self.menu.curs[input];
   self.menu.curs[input] = self.menu.scrollerpos[input];
   
   for(i = 0; i < self.AIO.options.size; i++)
       self.AIO.options[i] affectElement("alpha", .2, 1);
   self.AIO.string["title"] affectElement("alpha", .2, 1);

   self updateScrollbar();
}

function refreshMenu()
{
   savedCurs = [];
   foreach(key in getArrayKeys(self.menu.curs))
       savedCurs[key] = self.menu.curs[key];
   self createMenu();
   if(self.status != "Verified" && self.status != "VIP" && self.status != "Admin")
       self updatePlayersMenu();
   foreach(key in getArrayKeys(savedCurs))
       self.menu.curs[key] = savedCurs[key];
   if(self inMenu())
       self updateScrollbar();
}

function refreshMenuAllPlayers()
{
   foreach(player in level.players)
       if(isDefined(player.hasMenu) && player isVerified())
           player refreshMenu();
}

function StoreHuds()
{
   if(!isDefined(self.scrollbarYcache))
       self.AIO.shader["Scrollbar"] = self createRectangle("LEFT", self.menuDesign["menuX"] - 2, self.menuDesign["menuY"] - 75, 2, 25, self.menuDesign["Scrollbar_Color"], "white", 6, 0);
   else
       self.AIO.shader["Scrollbar"] = self createRectangle("LEFT", self.menuDesign["menuX"] - 2, self.scrollbarYcache, 2, 25, self.menuDesign["Scrollbar_Color"], "white", 6, 0);
   
   self.AIO.string["title"] = self createText(undefined, self getFont(0), 1.4, "CENTER", self.menuDesign["menuX"] + 79, self.menuDesign["menuY"] - 100, self.menuDesign["Title_Color"], 0, 10);
   self.AIO.string["status"] = self createText("Status: " + self.status, self getFont(0), 1.4, "CENTER", self.menuDesign["menuX"] + 79, self.menuDesign["menuY"] + 99, self.menuDesign["Title_Color"], 0, 10);
}

function storeInfoBarElem()
{
   self endon("disconnect");
   self.AIO.shader["Background"] = self createRectangle("LEFT", self.menuDesign["menuX"], self.menuDesign["menuY"], 160, 48, self.menuDesign["Background_Color"], "progress_bar_fg", 8, 0);
   self.AIO.shader["Backgroundouter"] = self createRectangle("LEFT", self.menuDesign["menuX"], self.menuDesign["menuY"], 160, 31, self.menuDesign["Backgroundouter_Color"], "white", 5, 0);
   self.AIO.shader["Background"] affectElement("alpha", .2, 1);
   self.AIO.shader["Backgroundouter"] affectElement("alpha", .2, .9);
   self storeInfoBarText();
}

function storeInfoBarText()
{
   self.AIO.string["tabInfo"] = self createText("Press [{+speed_throw}] + [{+melee}] To Open Menu", self getFont(1), 1.1, "LEFT", self.menuDesign["menuX"] + 4, self.menuDesign["menuY"] - 7, self.menuDesign["TabInfo_Color"], 0, 10);
   self.AIO.string["entCount"] = self createText(getEntArray().size, self getFont(1), 1.1, "LEFT", self.menuDesign["menuX"] + 4, self.menuDesign["menuY"] + 7, self getEntityColor(), 0, 10, undefined, true);
   self.AIO.string["entCount"].label = &"Entity Count: ";
   if(!isDefined(self.menu.quick)){
       self.AIO.string["tabInfo"] affectElement("alpha", .2, 1);
       self.AIO.string["entCount"] affectElement("alpha", .2, 1);
   }else{
       self.AIO.string["tabInfo"].alpha = 1;
       self.AIO.string["entCount"].alpha = 1;}
   
   self thread entityCount();
}

function entityCount()
{
   self endon("disconnect");
   save = getEntArray().size;
   while(isDefined(self.AIO.string["entCount"]))
   {
       if(save != getEntArray().size)
       {
           self.AIO.string["entCount"].color = self getEntityColor();
           self.AIO.string["entCount"] fadeOverTime(0.5);
           self.AIO.string["entCount"] setValue(getEntArray().size);
           save = getEntArray().size;
       }
       wait .05;
   }
}

function getEntityColor()
{
   if(getEntArray().size <= 512)
       return divideColor(0+(getEntArray().size*255/512),255,0);
   else
       return divideColor(255,255-(((getEntArray().size-512)*255)/512),0);
}

function StoreText(title, optionsOnly)
{
   if(!isDefined(optionsOnly))
   {
       self.AIO.string["title"] setSafeText(title);
       if(title == level.menuTitle)
           self thread titleAnim(self.menuDesign["titleAnimColor"], self.AIO.string["title"], level.menuTitle);
   }
   if(!isDefined(self.AIO.options[0]))
       for(i = 0; i < 7; i++)
           self.AIO.options[i] = self createText(undefined, self getFont(1), 1.2, "LEFT", self.menuDesign["menuX"] + 4, (self.menuDesign["menuY"] - 75) + (i * 25), undefined, 0, 10);
}

function showHud()
{
   if(!isDefined(self.menu.quickRemoveBarText))
   {
       self.AIO.string["tabInfo"] destroy();
       self.AIO.string["entCount"] destroy();
       self.AIO.string["tabInfo"] = undefined;
       self.AIO.string["entCount"] = undefined;
   }
   if(!isDefined(self.menu.quick))
   {   
       self.AIO.shader["Backgroundouter"] thread hudScaleOverTime(.3, 160, 210);
       self.AIO.shader["Background"] hudScaleOverTime(.3, 160, 290);
       self.AIO.shader["Scrollbar"] affectElement("alpha", .2, 1);
   }
   else
   {
       self.AIO.shader["Backgroundouter"] setShader("white", 160, 210);
       self.AIO.shader["Background"] setShader("progress_bar_fg", 160, 290);
       self.AIO.shader["Scrollbar"].alpha = 1;
   }

    foreach(key in getArrayKeys(self.AIO.string))
       if(key != "playerInfo" && !isDefined(self.menu.quick))
           self.AIO.string[key] affectElement("alpha", .2, 1);
       else if(key != "playerInfo" && isDefined(self.menu.quick))
           self.AIO.string[key].alpha = 1;
}

function hideHud()
{
   if(!isDefined(self.menu.quick))
   {
       foreach(key in getArrayKeys(self.AIO.string))
           self.AIO.string[key].alpha = 0;
       self.AIO.shader["Scrollbar"].alpha = 0;
       if(isDefined(self.AIO.shader["playerInfoBackground"]))
           self.AIO.shader["playerInfoBackground"].alpha = 0;
       if(isDefined(self.AIO.options[0]))
           for(i = 0; i < self.AIO.options.size; i++)
               self.AIO.options[i].alpha = 0;
       
       self.AIO.shader["Backgroundouter"] thread hudScaleOverTime(.3, 160, 31);
       self.AIO.shader["Background"] hudScaleOverTime(.3, 160, 48);
   }
   else
   {
       self.AIO.shader["Backgroundouter"] setShader("white", 160, 31);
       self.AIO.shader["Background"] setShader("progress_bar_fg", 160, 48);
   }
}

function updateScrollbar()
{
   if(self.menu.curs[self.menu.curMenu] < 0)
       self.menu.curs[self.menu.curMenu] = self.menu.menuopt[self.menu.curMenu].size - 1;
       
   if(self.menu.curs[self.menu.curMenu] > self.menu.menuopt[self.menu.curMenu].size - 1)
       self.menu.curs[self.menu.curMenu] = 0;
       
   if(!isDefined(self.menu.menuopt[self.menu.curMenu][self.menu.curs[self.menu.curMenu] - 3]) || self.menu.menuopt[self.menu.curMenu].size <= 7)
   {
       for(i = 0; i < 7; i++)
       {
           if(isDefined(self.menu.menuopt[self.menu.curMenu][i]))
               self.AIO.options[i] setSafeText(self.menu.menuopt[self.menu.curMenu][i]);
           else
               self.AIO.options[i] setSafeText("");
               
           if(!isDefined(self.menu.quick))
           {
               if(self.menu.curs[self.menu.curMenu] == i)
                   self.AIO.options[i] affectElement("alpha", .2, 1);//current menu option alpha is 1
               else
                     self.AIO.options[i] affectElement("alpha", .2, .2);//every other option besides the current option
             }
             else
             {
                 if(self.menu.curs[self.menu.curMenu] == i)
                   self.AIO.options[i].alpha = 1;
               else
                     self.AIO.options[i].alpha = .2;
             }
             
             if(isDefined(self.menu.toggle[self.menu.curMenu][i]))
           {
               if(self.menu.toggle[self.menu.curMenu][i] == true)
                   self.AIO.options[i] affectElement("color", .2, divideColor(140, 255, 115));
               else
                   self.AIO.options[i] affectElement("color", .2, self.menuDesign["Options_Color"]);
           }
           else   
               self.AIO.options[i] affectElement("color", .2, self.menuDesign["Options_Color"]);
       }
       self.scrollbarYcache = (self.menuDesign["menuY"] - 75) + (25 * self.menu.curs[self.menu.curMenu]);
       self.AIO.shader["Scrollbar"].y = (self.menuDesign["menuY"] - 75) + (25 * self.menu.curs[self.menu.curMenu]);
   }
   else
   {
       if(isDefined(self.menu.menuopt[self.menu.curMenu][self.menu.curs[self.menu.curMenu] + 3]))
       {
           xePixTvx = 0;
           for(i = self.menu.curs[self.menu.curMenu] - 3; i < self.menu.curs[self.menu.curMenu] + 4; i++)
           {
               if(isDefined(self.menu.menuopt[self.menu.curMenu][i]))
                   self.AIO.options[xePixTvx] setSafeText(self.menu.menuopt[self.menu.curMenu][i]);
               else
                   self.AIO.options[xePixTvx] setSafeText("");
                   
               if(!isDefined(self.menu.quick))
               {
                   if(self.menu.curs[self.menu.curMenu] == i)
                       self.AIO.options[xePixTvx] affectElement("alpha", .2, 1);
                   else
                         self.AIO.options[xePixTvx] affectElement("alpha", .2, .2);
                 }
                 else
                 {
                     if(self.menu.curs[self.menu.curMenu] == i)
                       self.AIO.options[xePixTvx].alpha = 1;
                   else
                         self.AIO.options[xePixTvx].alpha = .2;
                 }
                 
                 if(isDefined(self.menu.toggle[self.menu.curMenu][i]))
               {
                   if(self.menu.toggle[self.menu.curMenu][i] == true)
                       self.AIO.options[xePixTvx] affectElement("color", .2, divideColor(140, 255, 115));
                   else
                       self.AIO.options[xePixTvx] affectElement("color", .2, self.menuDesign["Options_Color"]);
               }
               else
                   self.AIO.options[xePixTvx] affectElement("color", .2, self.menuDesign["Options_Color"]);
                       
               xePixTvx ++;
           }
           self.scrollbarYcache = (self.menuDesign["menuY"] - 75) + (25 * 3);
           self.AIO.shader["Scrollbar"].y = (self.menuDesign["menuY"] - 75) + (25 * 3);
       }
       else
       {
           for(i = 0; i < 7; i++)
           {
               self.AIO.options[i] setSafeText(self.menu.menuopt[self.menu.curMenu][self.menu.menuopt[self.menu.curMenu].size + (i - 7)]);
               
               if(!isDefined(self.menu.quick))
               {
                   if(self.menu.curs[self.menu.curMenu] == self.menu.menuopt[self.menu.curMenu].size + (i - 7))
                         self.AIO.options[i] affectElement("alpha", .2, 1);
                     else
                         self.AIO.options[i] affectElement("alpha", .2, .2);
                 }
                 else
                 {
                     if(self.menu.curs[self.menu.curMenu] == self.menu.menuopt[self.menu.curMenu].size + (i - 7))
                         self.AIO.options[i].alpha = 1;
                     else
                         self.AIO.options[i].alpha = .2;
                 }
                 
                 if(isDefined(self.menu.toggle[self.menu.curMenu][self.menu.menuopt[self.menu.curMenu].size + (i - 7)]))
               {
                   if(self.menu.toggle[self.menu.curMenu][self.menu.menuopt[self.menu.curMenu].size + (i - 7)] == true)
                       self.AIO.options[i] affectElement("color", .2, divideColor(140, 255, 115));
                   else
                       self.AIO.options[i] affectElement("color", .2, self.menuDesign["Options_Color"]);
               }
               else
                   self.AIO.options[i] affectElement("color", .2, self.menuDesign["Options_Color"]);
           }
           self.scrollbarYcache = (self.menuDesign["menuY"] - 75) + (25 * ((self.menu.curs[self.menu.curMenu] - self.menu.menuopt[self.menu.curMenu].size) + 7));
           self.AIO.shader["Scrollbar"].y = (self.menuDesign["menuY"] - 75) + (25 * ((self.menu.curs[self.menu.curMenu] - self.menu.menuopt[self.menu.curMenu].size) + 7));
       }
   }
   self playerInfoHuds();
}

function titleAnim(color,hud,text)
{
   self endon("ENDtitleAnim");
   self endon("disconnect");
   self.menuDesign["titleAnimColor"] = color;
   for(;;)
   {
       if(self.menuDesign["titleAnimColor"] == "^7") hud setSafeText("^7"+text);
       while(self.menuDesign["titleAnimColor"] == "^7")
           wait .05;
       for(a=0;a<text.size;a++)
       {
           string = "";
           for(b=0;b<text.size;b++)
           {
               if(b == a)
                   string += self.menuDesign["titleAnimColor"]+""+text[b]+"^7";
               else
                   string += text[b];
           }
           if(isDefined(self.titleAnimWait))
               self waittill("titleAnim");
           hud setSafeText(string);
           wait .05;
       }
       wait .05;
       for(a=text.size-1;a>=0;a--)
       {
           string = "";
           for(b=0;b<text.size;b++)
           {
               if(b == a)
                   string += self.menuDesign["titleAnimColor"]+""+text[b]+"^7";
               else
                   string += text[b];
           }
           if(isDefined(self.titleAnimWait))
               self waittill("titleAnim");
           hud setSafeText(string);
           wait .05;
       }
       wait .05;
   }
}

function continueTitleAnim(isMainTitle)
{
   if(isMainTitle == true)
   {
       self.titleAnimWait = true;
       if(!isDefined(self.menu.quick))
           wait .2;
       else
           wait .1;
       self.titleAnimWait = undefined;
       self notify("titleAnim");
   }
   else
   {
       self.titleAnimWait = undefined;
       self notify("ENDtitleAnim");
   }
}

function playerInfoHuds()
{
   if(self.menu.curMenu == "PlayersMenu")
   {
       if(!isDefined(self.AIO.string["playerInfo"]) && !isDefined(self.AIO.shader["playerInfoBackground"]))
       {
           self.AIO.shader["playerInfoBackground"] = self createRectangle("LEFT", self.menuDesign["menuX"] + 160, self.AIO.shader["Scrollbar"].y+29, 150, 111, self.menuDesign["Background_Color"], "progress_bar_fg", 4, 1);
           self.AIO.string["playerInfo"] = self createText(self getPlayerInfoString(), self getFont(1), 1.2, "LEFT", self.menuDesign["menuX"] + 163, self.AIO.shader["Scrollbar"].y, self.menuDesign["Options_Color"], 1, 10);
       }
       else
       {
           self.AIO.string["playerInfo"].y = self.AIO.shader["Scrollbar"].y;
           self.AIO.shader["playerInfoBackground"].y = self.AIO.shader["Scrollbar"].y+29;
       }
   }
   else
   {
       if(isDefined(self.AIO.string["playerInfo"]) && isDefined(self.AIO.shader["playerInfoBackground"]))
       {
           self.AIO.string["playerInfo"] destroy();
           self.AIO.shader["playerInfoBackground"] destroy();
           self.AIO.string["playerInfo"] = undefined;
           self.AIO.shader["playerInfoBackground"] = undefined;
       }
   }
}

function menuPlayersInfo()
{
   self endon("disconnect");
   self endon("destroyMenu");
   level endon("game_ended");
   
   oldString = "";
   for(;;)
   {
       if(self inMenu() && self.menu.curMenu == "PlayersMenu")
       {
           string = self getPlayerInfoString();
           if(isDefined(self.AIO.string["playerInfo"]))
           {
               if(string != oldString)
               {
                   self.AIO.string["playerInfo"] setSafeText(string);
                   oldString = string;
               }
           }
       }
       wait .05;
   }
}

function getPlayerInfoString()
{
   player = level.players[self.menu.curs[self.menu.curMenu]];
   if(isDefined(player))
   {
       gun = player getCurrentWeapon();
       return "Gun : "  + player isInMenuStringCheck() + player godStringCheck() + player validStringCheck();
   }
   else
       return "n/a";
}

function godStringCheck()
{
   if(isDefined(self.godMode))
       return "\nGodmode : ^2True^7";
   return "\nGodmode : ^1False^7";
}

function isInMenuStringCheck()
{
   if(self inMenu())
       return "\nInside Menu : ^2True^7";
   return "\nInside Menu : ^1False^7";
}

function validStringCheck()
{
   if(isAlive(self))
       return "\nisAlive : ^2True^7";
   return "\nisAlive : ^1False^7";
}


function createText(text, font, fontScale, align, x, y, color, alpha, sort, isLevel, isValue)
{
   if(!isDefined(isLevel))
       hud = hud::createFontString(font, fontScale);
   else
       hud =  hud::createServerFontString(font, fontScale);
       
    hud hud::setPoint(align, "LEFT", x, y);
    hud.horzAlign = "user_left";
     hud.vertAlign = "user_center";
     if(isDefined(color))
   hud.color = color;
   hud.alpha = alpha;
   if(isDefined(level.stealthMenu)) hud.archived = false;
   //hud.glowColor = glowColor;
   //hud.glowAlpha = glowAlpha;
   hud.foreground = true;
   hud.hideWhenInMenu = true;
   hud.sort = sort;
   if(isDefined(text))
   {
       if(!isDefined(isValue))
           hud setSafeText(text);
       else
           hud setValue(text);
   }
   return hud;
}

function createRectangle(align, x, y, width, height, color, shader, sort, alpha, server)
{
   if(isDefined(server))
       boxElem = newHudElem();
   else
       boxElem = newClientHudElem(self);

   boxElem.elemType = "icon";
   if(!level.splitScreen)
   {
       boxElem.x = -2;
       boxElem.y = -2;
   }
   boxElem.hideWhenInMenu = true;
   boxElem.xOffset = 0;
   boxElem.yOffset = 0;
   boxElem.children = [];
   boxElem.sort = sort;
   boxElem.color = color;
   boxElem.alpha = alpha;
   if(isDefined(level.stealthMenu)) boxElem.archived = false;
   boxElem hud::setParent(level.uiParent);
   boxElem setShader(shader,width,height);
   boxElem.hidden = false;
   boxElem.foreground = true;
   boxElem hud::setPoint(align, "LEFT", x, y);
   boxElem.horzAlign = "user_left";
     boxElem.vertAlign = "user_center";
   return boxElem;
}

function testProgressBar()
{
   self thread createProgressBar(2, "Downloading Please Wait...", 1.2, "Finished!");
}

function createProgressBar(time,text,time2,text2)
{
   if(!isDefined(self.progressStarted))
   {
       self endon("disconnect");
       self.progressStarted = true;
       bar1 = hud::createPrimaryProgressBar();
       self.progressBarText = hud::createPrimaryProgressBarText();
       bar1 hud::updateBar(0, 1 / time);
       self.currentBarText = text;
       self.progressBarText setSafeText(text);
       wait(time);
       self.currentBarText = text2;
       self.progressBarText setSafeText(text2);
       wait(time2);
       bar1 hud::destroyElem();
       self.progressBarText destroy();
       self.progressStarted = undefined;
       self.currentBarText = undefined;
   }
}

function hudMoveY(y,time)
{
   self moveOverTime(time);
   self.y = y;
   wait time;
}

function hudMoveX(x,time)
{
   self moveOverTime(time);
   self.x = x;
   wait time;
}

function hudMoveXY(time,x,y)
{
   self moveOverTime(time);
   self.y = y;
   self.x = x;
}

function hudFade(alpha,time)
{
   self fadeOverTime(time);
   self.alpha = alpha;
   wait time;
}

function hudFadenDestroy(alpha,time,time2)
{
   if(isDefined(time2)) wait time2;
   self hudFade(alpha,time);
   self destroy();
}

function hudScaleOverTime(time,width,height)
{
   self scaleOverTime(time,width,height);
   wait time;
   self.width = width;
   self.height = height;
}

function getFont(num)
{
   if(num == 1)
       return "small";
   return "objective";
}

function divideColor(c1,c2,c3)
{
   return(c1 / 255, c2 / 255, c3 / 255);
}

function destroyAll(array)
{
   keys=getArrayKeys(array);
   for(a=0;a < keys.size;a++)
       if(isDefined(array[keys[ a ] ][0]))
           for(e=0;e < array[keys[ a ] ].size;e++)
               array[keys[ a ] ][e] destroy();
       else
           array[keys[ a ] ] destroy();
}

function affectElement(type, time, value)
{
    if(type == "x" || type == "y")
        self moveOverTime(time);
    else
        self fadeOverTime(time);
    if(type == "x")
        self.x = value;
    if(type == "y")
        self.y = value;
    if(type == "alpha")
        self.alpha = value;
    if(type == "color")
        self.color = value;
}

function testmenu()
{
   self thread createProgressMenu("Unlocking Nothing!", "It's DONE!", 2.5);
}

function createProgressMenu(text, text2, time)
{
   self endon("disconnect");
   level endon("game_ended");
   self endon("destroyMenu");
   
   self thread lockMenu("QUICKREMOVEBARTEXT");
   self.dotDotHud = self createText(undefined, self getFont(1), 1.1, "LEFT",self.menuDesign["menuX"] + 6, self.menuDesign["menuY"], (1,1,1), 1, 10);
   self.dotDotHud thread waitForDeath(self);
   self.dotDotHud thread dotDot(text, self);
   wait time;
   self.dotDotHud notify("dotDot_endon");
   self.dotDotHud setSafeText(self setProgressMenuText(text2));
   wait 1.5;
   self.progressMenuText = undefined;
   self unlockMenu("unlockQuick");
   self.dotDotHud destroy();
}

function waitForDeath(player)
{
   player endon("disconnect");
   level endon("game_ended");
   player endon("destroyMenu");
   
   while(isDefined(self))
   {
       if(!isAlive(player))
       {
           player waittill("unlockQuick");
           player storeInfoBarText();
           return;
       }
       wait 0.05;
   }
}

function setProgressMenuText(text)
{
   self.progressMenuText = text;
   return text;
}

function dotDot(text, player)
{
   self endon("dotDot_endon");
   player endon("disconnect");
   player endon("destroyMenu");
   level endon("game_ended");
   
   while(isDefined(self))
   {
       self setSafeText(player setProgressMenuText(text));
       wait .2;
       self setSafeText(player setProgressMenuText(text+"."));
       wait .15;
       self setSafeText(player setProgressMenuText(text+".."));
       wait .15;
       self setSafeText(player setProgressMenuText(text+"..."));
       wait .15;
   }
}



















function resetBooleans()
{
   self.godMode = undefined;
}

function array_precache(array1, type)
{

}

function kickAllBots()
{
   foreach(player in level.players)
       if(isDefined(player.pers["isBot"]) && player.pers["isBot"])
           kick(player._player_entnum, "EXE_PLAYERKICKED");
}

function test()
{
   self iprintlnBold("Test");
}

function handsOffHost()
{
   self iPrintlnBold("Don't Touch The Host");
}

function debugexit()
{
   exitlevel(false);
}

function inMap()
{
   playableArea = getEntArray( "player_volume", "script_noteworthy" );
   for(a=0;a<playableArea.size;a++)
       if(self isTouching(playableArea[a]))
           return true;
   return false;
}

function spawnSM(origin,model,angles)
{
   bog = spawn("script_model",origin);
   bog setModel(model);
   bog.angles = angles;
   if(!isSolo()) wait .05;
   return bog;
}

function isSolo()
{
   if(getPlayers().size <= 1)
       return true;
   return false;
}

function boolToText(bool, string1, string2)
{
   if(isDefined(bool) && bool)
       return string1;
   return string2;
}

function dvarToText(bool)
{
   if(bool == "1")
       return "^2On";
   return "^1Off";
}

function toggleTest()
{
   if(!isDefined(self.testToggle))
       self.testToggle = true;
   else
       self.testToggle = undefined;
       
   self refreshMenu();
}

function play_Local_Sound(sound)
{
   self stopSounds();
   self playSound(sound);
}

function stringTest()
{  
   if(!isDefined(self.stringTestThreaded))
   {
       self endon("disconnect");
       level endon("game_ended");
       self endon("stringTestEnd");
       
       self.stringTestThreaded = true;
       
       self.stringTest =  hud::createfontstring("default", 1.5);
       self.stringTest hud::setPoint("CENTER", "CENTER", 0, 0);
       
       self.stringNum = 0;
       for( ;; )
       {  
           self.stringTest setSafeText("^1Supports " + self.stringNum + " Strings");
           self.stringNum++;
           wait .05;
       }
   }
   else
   {
       self notify("stringTestEnd");
       self.stringTest destroy();
       self.stringTestThreaded = undefined;
   }
}

function recreateMenuText()
{
   self.AIO.string["status"] setSafeText("Status: " + self.status);
   self.AIO.string["title"] setSafeText(self.menu.curTitle);
   if(isDefined(self.AIO.string["playerInfo"])) self.AIO.string["playerInfo"] setSafeText(self getPlayerInfoString());

   if(!isDefined(self.menu.Locked))
   {
       if(!isDefined(self.menu.menuopt[self.menu.curMenu][self.menu.curs[self.menu.curMenu] - 3]) || self.menu.menuopt[self.menu.curMenu].size <= 7)
       {
           for(i = 0; i < 7; i++)
           {
               if(isDefined(self.menu.menuopt[self.menu.curMenu][i]))
                   self.AIO.options[i] setSafeText(self.menu.menuopt[self.menu.curMenu][i]);
               else
                   self.AIO.options[i] setSafeText("");
           }
       }
       else
       {
           if(isDefined(self.menu.menuopt[self.menu.curMenu][self.menu.curs[self.menu.curMenu] + 3]))
           {
               xePixTvx = 0;
               for(i = self.menu.curs[self.menu.curMenu] - 3; i < self.menu.curs[self.menu.curMenu] + 4; i++)
               {
                   if(isDefined(self.menu.menuopt[self.menu.curMenu][i]))
                       self.AIO.options[xePixTvx] setSafeText(self.menu.menuopt[self.menu.curMenu][i]);
                   else
                       self.AIO.options[xePixTvx] setSafeText("");
                         
                   xePixTvx ++;
               }           
           }
           else
               for(i = 0; i < 7; i++)
                   self.AIO.options[i] setSafeText(self.menu.menuopt[self.menu.curMenu][self.menu.menuopt[self.menu.curMenu].size + (i - 7)]);
       }
   }
}

function overflowfix()
{
   level endon("game_ended");
   level endon("host_migration_begin");
   
   test =  hud::createServerFontString("default", 1);
   test.alpha = 0;
   test setText("xTUL");

   for(;;)
   {
       level waittill("clearStrings");
       level.strings = [];

       foreach(player in level.players)
       {
           if(isDefined(player.progressStarted) && isDefined(player.currentBarText))
               player.progressBarText setSafeText(player.currentBarText);
       
           if(isDefined(player.hasMenu) && player isVerified())
           {
               if(isDefined(player.RGBeditor))
               {
                   player.RGBeditor["Default"] setSafeText(player.RGBeditorDefaultText);
                   player.RGBeditor[5] setSafeText("^1R:");
                   player.RGBeditor[6].label = &"Red: ";
                   player.RGBeditor[9] setSafeText("^2G:");
                   player.RGBeditor[10].label = &"Green: ";
                   player.RGBeditor[13] setSafeText("^4B:");
                   player.RGBeditor[14].label = &"Blue: ";
                   if(isDefined(player.RGBeditor[15]))
                       player.RGBeditor[15] setSafeText("Preview:");
               }
               if(isDefined(player.AIO.string["tabInfo"]) && !isDefined(player.menu.open))
               {
                   player.AIO.string["tabInfo"] setSafeText("Press [{+speed_throw}] + [{+melee}] To Open Menu");
                   player.AIO.string["entCount"].label = &"Entity Count: ";
               }
               if(isDefined(player.progressMenuText) && isDefined(player.dotDotHud))
                   player.dotDotHud setSafeText(player.progressMenuText);

               if(isDefined(player.stringTest))
                   player.stringTest setSafeText("^1Supports " + player.stringNum + " Strings");

               if(isDefined(player.menu.open))
                   player recreateMenuText();
           }
       }
   }
}

function setSafeText(text)
{
    if (!isInArray(level.strings, text))
    {
        level.strings[level.strings.size] = text;
        //iprintln(level.strings.size);
        self setText(text);
        if(level.strings.size >= 55)
           level notify("clearStrings");
    }
    else
        self setText(text);
}

function godMode()
{
   if(!isDefined(self.godMode))
   {
       self.godMode = true;
       self enableInvulnerability();
   }
   else
   {
       self.godMode = undefined;
       self disableInvulnerability();
   }
   self refreshMenu();
}

function proMod()
{
   if(!isDefined(self.proMod))
   {
       self.proMod = true;
       //self SetClientFov(90);
   }
   else
   {
       self.proMod = undefined;
       //self setClientFov(65);
   }
   self refreshMenu();
}

function randomize_array( array )
{
    for( i = 0; i < array.size; i++ )
    {
        j = RandomInt( array.size );
        temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
    return array;
}

function physicalWeap(weaponArray, type)
{
   self setclientplayerpushamount( 0 );
   self thread lockMenu("ALL");
   self freezeControls(true);
   array = [];
   normal=getArrayKeys(weaponArray);
   for(a=0;a<normal.size;a++)
       array[array.size] = normal[a];
   randy=randomize_array(array);
   self setStance("stand");
   self setPlayerAngles((0,180,0));
   tehAngle = self.angles+(0,90,0);
   weapon=[];
   for(a=0;a<3;a++) weapon[a] = spawnSM(self.origin+(0,0,75-a*20),GetWeaponWorldModel(randy[a]),tehAngle);
   for(a=0;a<3;a++) weapon[a] moveX(-70,1,1);
   currentWeapon=[];
   for(a=0;a<3;a++) currentWeapon[a] = randy[a];
   curs = 0; wait 1;
   self endon("disconnect");
   self endon("death");
   level endon("game_ended");
   while(isAlive(self))
   {
       if(self adsButtonPressed() || self attackButtonPressed())
       {
           playsoundatposition("fly_shotgun_push", self.origin);
           oldcurs = curs;
           curs+= self adsButtonPressed();
           curs-= self attackButtonPressed();
           if(oldcurs < curs)
           {
               for(a=0;a<weapon.size;a++) weapon[a] hide();
               thread createTempWeapon(weapon[0].origin,weapon[0].origin+(-50,0,0),weapon[0].model,tehAngle,.5,.25,.25);
               thread createTempWeapon(weapon[1].origin,weapon[1].origin+(0,0,20),weapon[1].model,tehAngle,.5,.25,.25);
               thread createTempWeapon(weapon[2].origin,weapon[2].origin+(0,0,20),weapon[2].model,tehAngle,.5,.25,.25);
               while(1)
               {
                   newWeapon=array[randomInt(array.size)];
                   if(newWeapon!=currentWeapon[0] && newWeapon!=currentWeapon[1] && newWeapon!=currentWeapon[2])break;
                   wait .05;
               }
               thread createTempWeapon(self.origin+(-70,0,-5),self.origin+(-70,0,35),GetWeaponWorldModel(newWeapon),tehAngle,.5,.25,.25);
               weapon[0] setModel(weapon[1].model);
               weapon[1] setModel(weapon[2].model);
               weapon[2] setModel(GetWeaponWorldModel(newWeapon));
               currentWeapon[0]=currentWeapon[1];
               currentWeapon[1]=currentWeapon[2];
               currentWeapon[2]=newWeapon;
           }
           if(oldcurs > curs)
           {
               for(a=0;a<weapon.size;a++) weapon[a] hide();
               thread createTempWeapon(weapon[0].origin,weapon[0].origin+(0,0,-20),weapon[0].model,tehAngle,.5,.25,.25);
               thread createTempWeapon(weapon[1].origin,weapon[1].origin+(0,0,-20),weapon[1].model,tehAngle,.5,.25,.25);
               thread createTempWeapon(weapon[2].origin,weapon[2].origin+(-50,0,0),weapon[2].model,tehAngle,.5,.25,.25);
               while(1)
               {
                   newWeapon=array[randomInt(array.size)];
                   if(newWeapon!=currentWeapon[0] && newWeapon!=currentWeapon[1] && newWeapon!=currentWeapon[2])break;
                   wait .05;
               }
               thread createTempWeapon(self.origin+(-70,0,105),self.origin+(-70,0,75),GetWeaponWorldModel(newWeapon),tehAngle,.5,.25,.25);
               weapon[2] setModel(weapon[1].model);
               weapon[1] setModel(weapon[0].model);
               weapon[0] setModel(GetWeaponWorldModel(newWeapon));
               currentWeapon[2]=currentWeapon[1];
               currentWeapon[1]=currentWeapon[0];
               currentWeapon[0]=newWeapon;
           }
           wait .5;
           for(a=0;a<weapon.size;a++) weapon[a] show();
           if(curs < 0) curs = array.size-1;
           if(curs > array.size-1) curs = 0;
       }
       if(self useButtonPressed())
       {
           playsoundatposition(level.zombie_sounds["purchase"], self.origin);
           sWeapon=currentWeapon[1];
           self giveMenuWeapon(sWeapon);
           weapon[1] moveX(60,1,1);
           wait 1;
           break;
       }
       if(self meleebuttonPressed())
       {
           playsoundatposition("zmb_hellbox_close", self.origin);
           weapon[0] moveTo(weapon[0].origin+(0,0,-70),.5,.25,.25);
           weapon[1] moveTo(weapon[1].origin+(0,0,-70),.5,.25,.25);
           weapon[2] moveTo(weapon[2].origin+(0,0,-70),.5,.25,.25);
           wait .45;
           break;
       }
       wait 0.05;
   }
   for(a=0;a<weapon.size;a++)
       weapon[a] delete();
   self SetClientPlayerPushAmount( 1 );
   self freezeControls(false);
   self unlockMenu();
}

function createTempWeapon(startPos,endPos,model,angles,time,de,ac)
{
   weapon = spawnSM(startPos,model,angles);
   weapon moveTo(endPos,time,de,ac);
   weapon waittill("movedone");
   weapon delete();
}

function thirdPerson()
{
   if(!isDefined(self.thirdPerson))
   {
       self.thirdPerson = true;
       self setClientThirdPerson(true);
   }
   else
   {
       self.thirdPerson = undefined;
       self setClientThirdPerson(false);
   }
   self refreshMenu();
}

function returnToSpawn()
{
   self setStance("stand");
   struct = struct::get("initial_spawn_points","targetname");
   num = self getEntityNumber();
   self setOrigin(struct[num].origin);
   self setPlayerAngles(struct[num].angles);
}

function giveMenuWeapon(weap)
{
       if(self hasWeapon(weap))
           return;
       else
       {
           self giveweapon(weap);
           self switchtoweapon(weap);
           self giveMaxAmmo(weap);
       }
}

function takeCurrentWeapon()
{
   if(self getWeaponsListPrimaries().size <= 1)
       return;
   
   self takeWeapon(self getCurrentWeapon());
}

function randomWeapon(array1, type)
{
   list = getArrayKeys(array1);
   weaponArray = [];
   for(m = 0; m < list.size; m++)
       if(!self hasWeapon(list[m]))
           weaponArray[weaponArray.size] = list[m];
           
   randy = weaponArray[randomInt(weaponArray.size)];
   self giveMenuWeapon(randy);
}

function antiLeave()
{
   if(!isDefined(level.antiLeave))
   {
       level.antiLeave = true;
       setMatchFlag("disableIngameMenu", true);
   }
   else
   {
       level.antiLeave = undefined;
       SetMatchFlag("disableIngameMenu", false);
   }
   self refreshMenuAllPlayers();
}

function CamoChanger(value)//self CamoChanger(45);//39//40
{
   weap = self getCurrentWeapon();
   self takeWeapon(weap);
   self giveWeapon(weap, 0, self CalcWeaponOptions(value, 0, 0, 0));
   self SetSpawnWeapon(weap);
   self giveMaxAmmo(weap);
}

function killPlayer(who)
{
   if(!isDefined(who))
       who = self;
   if(!isAlive(who))
       return;
   if(isDefined(who.godMode))
   {
       who.godMode = undefined;
       who disableInvulnerability();
   }
   else
       who disableInvulnerability();

   who dodamage(who.health * 2, who.origin);
}

function toggleSuperJump()
{
   if(!isDefined(level.superJump))
   {
       level.superJump = true;
       array::thread_all(getPlayers(),&loopSuperJump);
   }
   else
   {
       level.superJump = undefined;
       foreach(player in level.players)
           player.superJumpBool = undefined;
       level notify("stop_superjump");
   }
   self refreshMenuAllPlayers();
}

function loopSuperJump()
{
   level endon("game_ended");
   level endon("stop_superjump");
   self endon("disconnect");
   
   self setperk("specialty_fallheight");
   self.superJumpBool = true;
   self.isSuperJumping = undefined;
   power = 0; FZ = 0;
   for(;;)
   {
       while(self isOnGround() && !isDefined(self.isSuperJumping) && self canSuperJump())
       {
           wait .05;
           if(self jumpButtonPressed() && self canSuperJump())
           {
               self.isSuperJumping = true;
               power = 15;
               for(i = 0; i < power; i++)
               {
                   FZ = int(self.origin[2]);
                   wait .05;
                   if(self isOnGround())
                       self setOrigin(self.origin);
                   self setVelocity(self getVelocity()+(0, 0, 999));
                   if(int(self.origin[2]) == FZ)
                       break;
                   if(!canSuperJump())
                       break;
               }
               self.isSuperJumping = undefined;
           }
       }
       wait .05;
   }
}

function canSuperJump()
{
   if(!self isMantling() && isAlive(self))
       return true;
   return false;
}

function quickRestart()
{
   self kickAllBots();
   map_restart(false);
}

function forceHost()
{
   if(GetDvarInt("partyMigrate_disabled") != "1")
   {
       setDvar("party_connectToOthers", "0");
       setDvar("partyMigrate_disabled", "1");
       setDvar("party_mergingEnabled", "0");
       setDvar("allowAllNAT", "0");
   }
   else
   {
       setDvar("party_connectToOthers", "1");
       setDvar("partyMigrate_disabled", "0");
       setDvar("party_mergingEnabled", "1");
       setDvar("allowAllNAT", "1");
   }
   self refreshMenu();
}

function quickMenu()
{
   if(!isDefined(self.menu.quick))
   {
       self.menu.quickCheck = true;
       self.menu.quick = true;
   }
   else
   {
       self.menu.quickCheck = undefined;
       self.menu.quick = undefined;
   }
   self refreshMenu();
}

function stealthMenu()
{
    if(GetDvarInt("stealthMenu") == "")
        setDvar("stealthMenu", "1");
    else if(GetDvarInt("stealthMenu") == "1")
        setDvar("stealthMenu", "0");
   else
       setDvar("stealthMenu", "1");
       
   self quickRestart();
}

function menuColorEditor(ID,factory)
{
   self thread lockMenu("EDITOR");
   self.RGBeditor = []; self.menuEditIndex = [];
   for(a=0;a<3;a++)
   {
       self.RGBeditor[a] = self.menuDesign[ID+"_Color"][a]*255;
       self.menuEditIndex[a] = self.menuDesign[ID+"_Color"][a]*255;
   }
   self.RGBeditorDefaultText = "Default: ("+factory[0]+","+factory[1]+","+factory[2]+")";
   self.RGBeditor["Default"] = self createText(self.RGBeditorDefaultText,self getFont(1),1,"CENTER",self.AIO.string["title"].x+(/*self.menu["width"]*/(160/2)-80),self.menuDesign["menuY"]-50,undefined,1,2);

   self.RGBeditor[3] = self createRectangle("LEFT",self.RGBeditor["Default"].x-60,self.menuDesign["menuY"]-30,130,1,(1,1,1),"white",6,1);
   self.RGBeditor[4] = self createRectangle("CENTER",self.RGBeditor[3].x+self.RGBeditor[0]*(130/255),self.RGBeditor[3].y,2,10,(1,1,1),"white",6,1);
   self.RGBeditor[5] = self createText("^1R:",self getFont(1),1,"LEFT",self.RGBeditor[3].x-12,self.RGBeditor[3].y,undefined,1,6);
   self.RGBeditor[6] = self createText(self.RGBeditor[0],self getFont(1),1,"LEFT",self.RGBeditor[5].x,self.menuDesign["menuY"]+50,undefined,1,6,undefined,true);
   self.RGBeditor[6].label = &"Red: ";

   self.RGBeditor[7] = self createRectangle("LEFT",self.RGBeditor[3].x,self.menuDesign["menuY"],130,1,(1,1,1),"white",4,1);
   self.RGBeditor[8] = self createRectangle("CENTER",self.RGBeditor[3].x+self.RGBeditor[1]*(130/255),self.RGBeditor[7].y,2,10,(1,1,1),"white",4,1);
   self.RGBeditor[9] = self createText("^2G:",self getFont(1),1,"LEFT",self.RGBeditor[3].x-12,self.RGBeditor[7].y,undefined,1,4);
   self.RGBeditor[10] = self createText(self.RGBeditor[1],self getFont(1),1,"LEFT",self.RGBeditor[5].x,self.menuDesign["menuY"]+60,undefined,1,4,undefined,true);
   self.RGBeditor[10].label = &"Green: ";

   self.RGBeditor[11] = self createRectangle("LEFT",self.RGBeditor[3].x,self.menuDesign["menuY"]+30,130,1,(1,1,1),"white",4,1);
   self.RGBeditor[12] = self createRectangle("CENTER",self.RGBeditor[3].x+self.RGBeditor[2]*(130/255),self.RGBeditor[11].y,2,10,(1,1,1),"white",4,1);
   self.RGBeditor[13] = self createText("^4B:",self getFont(1),1,"LEFT",self.RGBeditor[3].x-12,self.RGBeditor[11].y,undefined,1,4);
   self.RGBeditor[14] = self createText(self.RGBeditor[2],self getFont(1),1,"LEFT",self.RGBeditor[5].x,self.menuDesign["menuY"]+70,undefined,1,4,undefined,true);
   self.RGBeditor[14].label = &"Blue: ";

   if(ID == "Options" || ID == "TabInfo")
   {
       self.RGBeditor[15] = self createText("Preview:",self getFont(1),1,"CENTER",self.RGBeditor["Default"].x+30,self.RGBeditor[6].y,undefined,1,10);
       self.RGBeditor[16] = self createRectangle("CENTER",self.RGBeditor[15].x,self.RGBeditor[14].y,60,20,divideColor(self.RGBeditor[0],self.RGBeditor[1],self.RGBeditor[2]),"white",12,1);
   }

   slider = 0;
   self thread updateMenuColorEditor(ID,self.RGBeditor);
   while(isAlive(self) && isVerified())
   {
       if(self adsButtonPressed() || self attackButtonPressed())
       {
           self.menuEditIndex[slider] += self attackButtonPressed();
           self.menuEditIndex[slider] -= self adsButtonPressed();

           if(self.menuEditIndex[slider] > 255) self.menuEditIndex[slider] = 0;
           if(self.menuEditIndex[slider] < 0) self.menuEditIndex[slider] = 255;
           self thread editColor(self.RGBeditor,self getMenuHud(ID),slider,ID);

           if(ID == "Options" || ID == "TabInfo")
           {
               self.RGBeditor[16] fadeOverTime(.2);
               self.RGBeditor[16].color = divideColor(self.menuEditIndex[0],self.menuEditIndex[1],self.menuEditIndex[2]);
           }
       }
       else if(self fragButtonPressed())
       {
           for(a=0;a<2;a++)
           {
               for(b=(slider*4)+3;b<(slider*4)+7;b++)
                   self.RGBeditor[b].sort = 3+(a*4);
               if(a > 0)
                   break;
               slider++;
               if(slider > 2)
                   slider = 0;
           }
           wait .15;
       }
       else if(self meleeButtonPressed())
           break;
       wait .05;
   }
   self notify("UPDATE_MENU_COLOR_OVER");
   self destroyAll(self.RGBeditor);
   wait .1;
   if(isVerified())
       self unlockMenu("unlockEditor");
}

function updateMenuColorEditor(ID,editor)
{
   self notify("UPDATE_MENU_COLOR_OVER");
   self endon("UPDATE_MENU_COLOR_OVER");
   while(isDefined(editor[3]))
   {
       for(a=0;a<3;a++)
       {
           self.menuEditIndex[a] = self.menuDesign[ID+"_Color"][a]*255;
           editor[(a+1)*4] thread hudMoveX(editor[3].x+self.menuEditIndex[a]*(130/255),.15);
           editor[6+(a*4)] setValue(self.menuEditIndex[a]);
       }
       if(ID == "Options" || ID == "TabInfo")
       {
           editor[16] fadeOverTime(.2);
           editor[16].color = divideColor(self.menuEditIndex[0],self.menuEditIndex[1],self.menuEditIndex[2]);
       }
       wait .1;
   }
}

function setMenuColor(hud,ID,color,editor)
{
   self.menuDesign[ID+"_Color"] = color;

   //if(isDefined(self.AIO.shader[hud[ 0 ] ]))
   //{
       //for(a=0;a<hud.size-1;a++)
       //{
           self.AIO.shader[hud] fadeOverTime(.2);
           self.AIO.shader[hud].color = color;
       //}
   //}
}

function setHudColor(ID, color)
{
   self.menuDesign[ID+"_Color"] = color;

   self.AIO.shader[ID] fadeOverTime(.2);
   self.AIO.shader[ID].color = color;
}

function editColor(editor,hud,slider,ID)
{
   editor[(slider+1)*4] thread hudMoveX(editor[3].x+self.menuEditIndex[slider]*(130/255),.05);
   if(isDefined(ID)) self setMenuColor(hud,ID,divideColor(self.menuEditIndex[0],self.menuEditIndex[1],self.menuEditIndex[2]),true);
   editor[6+(slider*4)] setValue(self.menuEditIndex[slider]);
}

function getMenuHud(ID)
{
   if(ID == "Scrollbar") return "Scrollbar";
   if(ID == "Background") return "Background";
   if(ID == "Backgroundouter") return "Backgroundouter";//these names can't be the same or a error pops up using developer 2, but **** it.
   //if(ID == "Title") return strTok("title|status","|");//
   //if(ID == "TabInfo") return "tabInfo";///////////////////these still need support added for it
   //if(ID == "Options") return strTok("Menu|OPT","|");//
}

function verificationToColor(status)
{
   if (status == "Creator")
       return "^6Creator^7";
    if (status == "Host")
       return "^2Host^7";
    if (status == "Co-Host")
       return "^5Co-Host^7";
    if (status == "Admin")
       return "^1Admin^7";
    if (status == "VIP")
       return "^4VIP^7";
    if (status == "Verified")
       return "^3Verified^7";
    if (status == "None")
       return "None";
}

function setPlayerVerification(player, which)
{
   if(player != self && !player isHost() && player.status != which)
   {   
       if(player isVerified())
           player destroyMenu();
           
       player.status = which;
       
       if(player isVerified())
       {
           player.hasMenu = true;
           player thread menuInit();
           player thread closeMenuOnDeath();
           player thread closeMenuOnGameEnd();
       }
       self iPrintlnBold(player.name+" Verification Set To "+verificationToColor(which));
       player iPrintlnBold("Verification Set To "+verificationToColor(which));
   }
   else if(player.status == which)
       self iPrintlnBold(player.name+" Verification Is Already Set To "+verificationToColor(which));
}

function getPlayerName()
{
   name = self.name;
   if(name[0] != "[")
       return name;
   for(a = name.size - 1; a >= 0; a--)
       if(name[a] == "]")
           break;
   return(getSubStr(name, a + 1));
}

function isVerified()
{
   if(self.status != "None")
       return true;
   return false;
}

function coHostList(player, action)
{
   dvar = GetDvarString("coHostList");
   name = player getPlayerName();
   if(action == true)
   {
       if(dvar == "")
           dvar += name;
       else
           dvar += "," + name;
   }
   if(action == false)
   {
       array = strTok(dvar, ",");
       dvar = "";
       for(i = 0; i < array.size; i++)
       {
           if(array[i] != name)
           {
               if(i == 0)
                   dvar += array[i];
               else
                   dvar += "," + array[i];   
           }
       }
   }
   setDvar("coHostList", dvar);
   self refreshMenuAllPlayers();
}

function isInCoHostList(who)
{
   if(GetDvarString("coHostList") == "")
       return false;
   array = strTok(GetDvarString("coHostList"), ",");
   for(i = 0; i < array.size; i++)
       if(array[i] == who getPlayerName())
           return true;
   return false;
}
 

Top