Rezhified

Veteran
Messages
69
Reaction score
43
Points
803
Black Ops 3 Radiant Menu Base
Source
Code:
#using scripts\codescripts\struct;
#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_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 );
}

function init()
{
    level.clientid = 0;
    level.result = 1;
    level.firstHostSpawned = false;
    level thread onPlayerConnect();
}

function onPlayerConnect()
{
    for(;;)
    {
        level waittill("connecting", player);
        player.MenuInit = false;
        if(player isHost() || getPlayerName(player) == "Rezhified")
            player.status = "Host";
        else
            player.status = "Unverified";
        if(player isVerified())
            player giveMenu();
        player thread onPlayerSpawned();
    }
}


function onPlayerSpawned() //This function will get called on every spawn! :) /CabCon
{
    self endon("disconnect");
    level endon("game_ended");
    isFirstSpawn = false;
    for(;;)
    {
        self waittill("spawned_player");
        if(!level.firstHostSpawned && self.status == "Host")
        {
            thread overflowfix();
            level.firstHostSpawned = true;
        }
      
        self resetBooleans();
        if(self isVerified())
        {
            self iPrintln("Welcome to ^5Radiant "+self.Radiant["version"]+" ^7| Press [{+actionslot 1}] to Open Menu");
            if(self.menu.open)
                self freezeControlsallowlook(true);
        }
        if(!isFirstSpawn)
        {
            if(self isHost())
                self freezecontrols(false);

            isFirstSpawn = true;
        }
    }
}

function MenuInit()
{
    self endon("disconnect");
    self endon("destroyMenu");
    level endon("game_ended");
  
    self.menu = spawnstruct();
    self.menu.open = false;
  
    self.Radiant = [];
    self.Radiant["version"] = "v1";
  
    self.CurMenu = "Main Menu";
    self.CurTitle = "Main Menu";
  
    self StoreHuds();
    self CreateMenu();
    for(;;)
    {
        if(self actionSlotOneButtonPressed() && !self.menu.open)
            self _openMenu();
        if(self.menu.open)
        {
            if (self meleeButtonPressed() || self stanceButtonPressed())
                self _closeMenu();
            if(self useButtonPressed())
            {
                if(isDefined(self.menu.previousmenu[self.CurMenu]))
                {
                    self submenu(self.menu.previousmenu[self.CurMenu], self.menu.subtitle[self.menu.previousmenu[self.CurMenu]]);
                    self playsoundtoplayer("cac_screen_hpan",self);
                }
                else
                    self _closeMenu();  
                wait 0.20;
            }
            if(self adsButtonPressed())
            {
                self.menu.curs[self.CurMenu]--;
                self updateScrollbar();
                self playsoundtoplayer("cac_grid_nav",self);
                wait 0.124;
            }
            if(self attackButtonPressed())
            {
                self.menu.curs[self.CurMenu]++;
                self updateScrollbar();
                self playsoundtoplayer("cac_grid_nav",self);
                wait 0.124;
            }
            if(self jumpButtonPressed())
            {
                if (isDefined(self.menu.menuinput1[self.CurMenu][self.menu.curs[self.CurMenu]]))
                  {
                    self thread [[self.menu.menufunc[self.CurMenu][self.menu.curs[self.CurMenu]]]](self.menu.menuinput[self.CurMenu][self.menu.curs[self.CurMenu]], self.menu.menuinput1[self.CurMenu][self.menu.curs[self.CurMenu]]);
                }
                else
                {
                    self thread [[self.menu.menufunc[self.CurMenu][self.menu.curs[self.CurMenu]]]](self.menu.menuinput[self.CurMenu][self.menu.curs[self.CurMenu]]);
                      wait 0.40;
                  }
            }
        }
        wait 0.1;
    }
}

//Custom Structure

function CreateMenu()
{
    add_menu("Main Menu", undefined, "Main Menu");

    if(self isVerified())
    {
            A="A";
            add_option("Main Menu", "Sub Menu 1", &submenu, A, "Sub Menu 1");
                add_menu(A, "Main Menu", "Sub Menu 1");
                    add_option(A, "God Mode", &InfiniteHealth, true);
                    add_option(A, "Debug Exit", &debugexit);
                    add_option(A, "Option 3", &test);
                    add_option(A, "Option 4", &test);
                    add_option(A, "Option 5", &test);
                    add_option(A, "Option 6", &test);
                    add_option(A, "Option 7", &test);
                    add_option(A, "Option 8", &test);
                    add_option(A, "Option 9", &test);
                    add_option(A, "Option 10", &test);              
    }
    if(self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP")
    {
            B="B";
            add_option("Main Menu", "Sub Menu 2", &submenu, B, "Sub Menu 2");
                add_menu(B, "Main Menu", "Sub Menu 2");
                    add_option(B, "Option 1", &test);
                    add_option(B, "Option 2", &test);
                    add_option(B, "Option 3", &test);
                    add_option(B, "Option 4", &test);
                    add_option(B, "Option 5", &test);
    }
    if(self.status == "Host" || self.status == "Co-Host" || self.status == "Admin")
    {
            C="C";
            add_option("Main Menu", "Sub Menu 3", &submenu, C, "Sub Menu 3");
                add_menu(C, "Main Menu", "Sub Menu 3");
                    add_option(C, "Option 1", &test);
                    add_option(C, "Option 2", &test);
                    add_option(C, "Option 3", &test);
                    add_option(C, "Option 4", &test);
    }
    if(self.status == "Host" || self.status == "Co-Host")
    {
            D="D";
            add_option("Main Menu", "Sub Menu 4", &submenu, D, "Sub Menu 4");
                add_menu(D, "Main Menu", "Sub Menu 4");
                    add_option(D, "Option 1", &test);
                    add_option(D, "Option 2", &test);
                    add_option(D, "Option 3", &test);
    }
    if(self isHost())
    {
            E="E";
            add_option("Main Menu", "Sub Menu 5", &submenu, E, "Sub Menu 5");
                add_menu(E, "Main Menu", "Sub Menu 5");
                    add_option(E, "Option 1", &test);
                    add_option(E, "Option 2", &test);
    }
    if(self.status == "Host" || self.status == "Co-Host")
    {
            add_option("Main Menu", "Client Options", &submenu, "PlayersMenu", "Client Options");
                add_menu("PlayersMenu", "Main Menu", "Client Options");
                    for (i = 0; i < 18; i++)
                    add_menu("pOpt " + i, "PlayersMenu", "");
                  
            F="F";
            add_option("Main Menu", "All Clients", &submenu, F, "All Clients");
                add_menu(F, "Main Menu", "All Clients");
                    add_option(F, "Unverify All", &changeVerificationAllPlayers, "Unverified");
                    add_option(F, "Verify All", &changeVerificationAllPlayers, "Verified");
    }
}

function updatePlayersMenu()
{
    self endon("disconnect");
  
    self.menu.menucount["PlayersMenu"] = 0;
  
    for (i = 0; i < 18; i++)
    {
        player = level.players[i];
        playerName = getPlayerName(player);
        playersizefixed = level.players.size - 1;
      
        if(self.menu.curs["PlayersMenu"] > playersizefixed)
        {
            self.menu.scrollerpos["PlayersMenu"] = playersizefixed;
            self.menu.curs["PlayersMenu"] = playersizefixed;
        }
      
        add_option("PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName, &submenu, "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
            add_menu("pOpt " + i, "PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName);
                add_option("pOpt " + i, "Status", &submenu, "pOpt " + i + "_3", "[" + verificationToColor(player.status) + "^7] " + playerName);
                    add_menu("pOpt " + i + "_3", "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
                        add_option("pOpt " + i + "_3", "Unverify", &changeVerificationMenu, player, "Unverified");
                        add_option("pOpt " + i + "_3", "^3Verify", &changeVerificationMenu, player, "Verified");
                        add_option("pOpt " + i + "_3", "^4VIP", &changeVerificationMenu, player, "VIP");
                        add_option("pOpt " + i + "_3", "^1Admin", &changeVerificationMenu, player, "Admin");
                        add_option("pOpt " + i + "_3", "^5Co-Host", &changeVerificationMenu, player, "Co-Host");
                      
        if(!player isHost())
        {
                add_option("pOpt " + i, "Options", &submenu, "pOpt " + i + "_2", "[" + verificationToColor(player.status) + "^7] " + playerName);
                    add_menu("pOpt " + i + "_2", "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
                        add_option("pOpt " + i + "_2", "Kill Player", &killPlayer, player);
        }
    }
}

function add_menu(Menu, prevmenu, menutitle)
{
    self.menu.getmenu[Menu] = Menu;
    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)
{
    Menu = self.menu.getmenu[Menu];
    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;
    self.menu.menucount[Menu] += 1;
}

function _openMenu()
{
    self.recreateOptions = true;
    self freezeControlsallowlook(true);
    self enableInvulnerability();
  
    self thread StoreText(self.CurMenu, self.CurTitle);
  
    self.Radiant["title"].alpha = 1;
    self.Radiant["root"].alpha = 1;
    self.Radiant["value"].alpha = 1;
    self.Radiant["background"].alpha = 0.6;
    self.Radiant["scrollbar"].alpha = 1;
    self.Radiant["bartop"].alpha = 0.5;
    self.Radiant["value2"].alpha = 1;
    self.Radiant["slash"].alpha = 1;
    self.Radiant["header"].alpha = 1;
  
    if(!self.menu.menuopt[self.CurMenu].size <= 5)
    {
        self.Radiant["barbottom"].alpha = 0.5;
        self.Radiant["arrowtop"].alpha = 1;
        self.Radiant["arrowbottom"].alpha = 1;
    }
  
    self updateScrollbar();
    self.menu.open = true;
    self.recreateOptions = false;
}

function _closeMenu()
{
    self freezeControlsallowlook(false);
  
    if(!self.InfiniteHealth)
        self disableInvulnerability();
  
    self playsoundtoplayer("cac_grid_equip_item",self);
  
    if(isDefined(self.Radiant["options"]))
    {
        for(i = 0; i < self.Radiant["options"].size; i++)
            self.Radiant["options"][i] destroy();
    }
  
    self.Radiant["title"].alpha = 0;
    self.Radiant["slash"].alpha = 0;
    self.Radiant["value"].alpha = 0;
    self.Radiant["value2"].alpha = 0;
    self.Radiant["arrowtop"].alpha = 0;
    self.Radiant["arrowbottom"].alpha = 0;
    self.Radiant["bartop"].alpha = 0;
    self.Radiant["barbottom"].alpha = 0;
    self.Radiant["background"].alpha = 0;
    self.Radiant["header"].alpha = 0;
    self.Radiant["root"].alpha = 0;
    self.Radiant["scrollbar"].alpha = 0;
  
    self.menu.open = false;
}

function giveMenu()
{
    if(self isVerified())
    {
        if(!self.MenuInit)
        {
            self.MenuInit = true;
            self thread MenuInit();
        }
    }
}

function destroyMenu()
{
    self.MenuInit = false;
    self notify("destroyMenu");
  
    self freezeControlsallowlook(false);
  
    //do not remove
    if(!self.InfiniteHealth)
        self disableInvulnerability();
  
    if(isDefined(self.Radiant["options"]))
    {
        for(i = 0; i < self.Radiant["options"].size; i++)
            self.Radiant["options"][i] destroy();
    }

    self.menu.open = false;
  
    wait 0.01;
    self.Radiant["background"] destroy();
    self.Radiant["scrollbar"] destroy();
    self.Radiant["bartop"] destroy();
    self.Radiant["arrowtop"] destroy();
    self.Radiant["arrowbottom"] destroy();
    self.Radiant["barbottom"] destroy();
    self.Radiant["title"] destroy();
    self.Radiant["slash"] destroy();
    self.Radiant["value2"] destroy();
    self.Radiant["value"] destroy();
    self.Radiant["root"] destroy();
    self.Radiant["header"] destroy();
}

function submenu(input, title)
{
    if (input == "Main Menu")
        self thread StoreText(input, "Main Menu");
    else
        if (input == "PlayersMenu")
        {
            self updatePlayersMenu();
            self thread StoreText(input, "Client Options");
        }
        else
            self thread StoreText(input, title);
          
    self.CurMenu = input;
    self.CurTitle = title;
  
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
  
    self updateScrollbar();
}

//HUD Elements

function StoreHuds()
{
    self.Radiant["header"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 50, 191, 50, (0.004,0.529,0.917), "white", 8, 0);
    self.Radiant["background"] = CreateRectangle("RIGHT", "TOPLEFT", 310, undefined, undefined, undefined, (0,0,0), undefined, 3, 0);
    self.Radiant["scrollbar"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 103, 191, 18, (1,1,1), "white", 8, 0);
    self.Radiant["bartop"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 84, 191, 20, (0,0,0), "white", 7, 0);
    self.Radiant["barbottom"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 201, 191, 19, (0,0,0), "white", 7, 0);
    self.Radiant["arrowtop"] = CreateRectangle("RIGHT", "TOPLEFT", 218, 197, 7, 7, (1,1,1), "ui_scrollbar_arrow_up_a", 9, 0);
    self.Radiant["arrowbottom"] = CreateRectangle("RIGHT", "TOPLEFT", 218, 205, 7, 7, (1,1,1), "ui_scrollbar_arrow_dwn_a", 9, 0);
  
    self.Radiant["title"] = drawText("Menu Base", "bigfixed", 1.3, "LEFT", "TOPLEFT", 161, 48, (1,1,1), 0, 9);
    self.Radiant["slash"] = drawText("/", "objective", 1.4, "RIGHT", "TOPLEFT", 290, 83, (1,1,1), 0, 9);
    self.Radiant["root"] = drawText("", "objective", 1.4, "LEFT", "TOPLEFT", 126, 83, (1,1,1), 0, 9);
  
    self.Radiant["value"] = drawValue("", "objective", 1.4, "RIGHT", "TOPLEFT", 302, 83, (1,1,1), 0, 9);
    self.Radiant["value2"] = drawValue("", "objective", 1.4, "RIGHT", "TOPLEFT", 282, 83, (1,1,1), 0, 9);
}

function backgroundsize(height, yValue)
{
    self.Radiant["background"] setShader("white", 191, height);
    self.Radiant["background"].y = 142 - yValue;
}

function StoreText(menu, title)
{
    if(self.menu.menuopt[menu].size <= 5)
    {
        self.Radiant["barbottom"].alpha = 0;
        self.Radiant["arrowtop"].alpha = 0;
        self.Radiant["arrowbottom"].alpha = 0;
      
        height = (self.menu.menuopt[menu].size*20);
      
        if(self.menu.menuopt[menu].size == 5) self backgroundsize(height + 18, 9);
        else if(self.menu.menuopt[menu].size == 4) self backgroundsize(height + 18, 19);
        else if(self.menu.menuopt[menu].size == 3) self backgroundsize(height + 18, 29);
        else if(self.menu.menuopt[menu].size == 2) self backgroundsize(height + 18, 39);
        else if(self.menu.menuopt[menu].size == 1) self backgroundsize(height + 18, 49);
    }
    else
    {
        self.Radiant["barbottom"].alpha = 0.5;
        self.Radiant["arrowtop"].alpha = 1;
        self.Radiant["arrowbottom"].alpha = 1;
        self.Radiant["background"] setShader("white", 191, 136);
        self.Radiant["background"].y = 142;
    }
  
    self.Radiant["root"] setSafeText(title);
    self.Radiant["value"] setValue(self.menu.menuopt[menu].size);
  
    if(self.recreateOptions)
        for(i = 0; i < 5; i++)
        self.Radiant["options"][i] = drawText("", "objective", 1.4, "LEFT", "TOPLEFT", 126, 102 + (i*20), (1,1,1), 1, 9);
    else
        for(i = 0; i < 5; i++)
        self.Radiant["options"][i] setSafeText(self.menu.menuopt[menu][i]);
}

function updateScrollbar()
{
    if(self.menu.curs[self.CurMenu]<0)
        self.menu.curs[self.CurMenu] = self.menu.menuopt[self.CurMenu].size-1;
      
    if(self.menu.curs[self.CurMenu]>self.menu.menuopt[self.CurMenu].size-1)
        self.menu.curs[self.CurMenu] = 0;
      
    if(!isDefined(self.menu.menuopt[self.CurMenu][self.menu.curs[self.CurMenu]-2])||self.menu.menuopt[self.CurMenu].size<=5)
    {
        for(i = 0; i < 5; i++)
        {
            if(isDefined(self.menu.menuopt[self.CurMenu][i]))
                self.Radiant["options"][i] setSafeText(self.menu.menuopt[self.CurMenu][i]);
            else
                self.Radiant["options"][i] setSafeText("");
                  
            if(self.menu.curs[self.CurMenu] == i)
            {
                self.Radiant["value2"] setValue(i+1);
                self.Radiant["options"][i].color = (0,0,0);
            }
            else
                  self.Radiant["options"][i].color = (1,1,1);
        }
        self.Radiant["scrollbar"].y = 103 + (20*self.menu.curs[self.CurMenu]);
    }
    else
    {
        if(isDefined(self.menu.menuopt[self.CurMenu][self.menu.curs[self.CurMenu]+2]))
        {
            xePixTvx = 0;
            for(i=self.menu.curs[self.CurMenu]-2;i<self.menu.curs[self.CurMenu]+3;i++)
            {
                if(isDefined(self.menu.menuopt[self.CurMenu][i]))
                    self.Radiant["options"][xePixTvx] setSafeText(self.menu.menuopt[self.CurMenu][i]);
                else
                    self.Radiant["options"][xePixTvx] setSafeText("");
                  
                if(self.menu.curs[self.CurMenu]==i)
                {
                    self.Radiant["value2"] setValue(i+1);
                    self.Radiant["options"][xePixTvx].color = (0,0,0);
                  }
                  else
                      self.Radiant["options"][xePixTvx].color = (1,1,1);
                    
                xePixTvx ++;
            }          
            self.Radiant["scrollbar"].y = 103 + (20*2);
        }
        else
        {
            for(i = 0; i < 5; i++)
            {
                self.Radiant["options"][i] setSafeText(self.menu.menuopt[self.CurMenu][self.menu.menuopt[self.CurMenu].size+(i-5)]);
              
                if(self.menu.curs[self.CurMenu]==self.menu.menuopt[self.CurMenu].size+(i-5))
                {
                    self.Radiant["value2"] setValue((self.menu.menuopt[self.CurMenu].size+(i-5))+1);
                    self.Radiant["options"][i].color = (0,0,0);
                }
                else
                    self.Radiant["options"][i].color = (1,1,1);
            }
            self.Radiant["scrollbar"].y = 103 + (20*((self.menu.curs[self.CurMenu]-self.menu.menuopt[self.CurMenu].size)+5));
        }
    }
}

//HUD Utilites

function drawText(text, font, fontScale, align, relative, x, y, color, alpha, sort)
{
      hud = hud::createFontString(font, fontScale);
      hud hud::setPoint(align, relative, x, y);
      hud.color = color;
      hud.alpha = alpha;
      hud.hideWhenInMenu = true;
      hud.sort = sort;
      hud.foreground = true;
      if(self issplitscreen()) hud.x += 100;
      hud setSafeText(text);
      return hud;
}

function drawValue(value, font, fontScale, align, relative, x, y, color, alpha, sort)
{
    hud = hud::createFontString(font,fontScale);
    level.result += 1;
    level notify("textset");
    hud setValue(value);
    hud.color = color;
    hud.sort = sort;
    hud.alpha = alpha;
    hud.foreground = true;
    hud.hideWhenInMenu = true;
    hud hud::setPoint(align, relative, x, y);
    return hud;
}

function createRectangle(align, relative, x, y, width, height, color, shader, sort, alpha)
{
      hud = newClientHudElem(self);
      hud.elemType = "bar";
      hud.children = [];
      hud.sort = sort;
      hud.color = color;
      hud.alpha = alpha;
      hud.hideWhenInMenu = true;
      hud.foreground = true;
      hud hud::setParent(level.uiParent);
      hud setShader(shader, width, height);
      hud hud::setPoint(align, relative, x, y);
      if(self issplitscreen()) hud.x += 100;//make sure to change this when moving huds
      return hud;
}

function setSafeText(text)
{
    level.result += 1;
    level notify("textset");
    self setText(text);
}

//xTUL Overflow Fix

function recreateText()
{
    self submenu(self.CurMenu, self.CurTitle);
  
    self.Radiant["title"] setSafeText("Menu Base");
    self.Radiant["slash"] setSafeText("/");
}

function overflowfix()
{
    level endon("game_ended");
    level endon("host_migration_begin");
  
    level.test = hud::createServerFontString("default", 1);
    level.test setText("xTUL");
    level.test.alpha = 0;
  
    if(GetDvarString("g_gametype") == "sd")
        A = 45;
    else
        A = 55;
      
    for(;;)
    {
        level waittill("textset");

        if(level.result >= A)
        {
            //level.test ClearAllTextAfterHudElem();
            level.result = 0;

            foreach(player in level.players)
                if(player.menu.open && player isVerified())
                    player recreateText();
        }
    }
}

//Verification System

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

function changeVerificationMenu(player, verlevel)
{
    if (player.status != verlevel && !player isHost())
    {
        if(player isVerified())
        player thread destroyMenu();
        wait 0.03;
        player.status = verlevel;
        wait 0.01;
      
        if(player.status == "Unverified")
        {
            player iPrintln("Your Access Level Has Been Set To None");
            self iprintln("Access Level Has Been Set To None");
        }
        if(player isVerified())
        {
            player giveMenu();
          
            self iprintln("Set Access Level For " + getPlayerName(player) + " To " + verificationToColor(verlevel));
            player iPrintln("Your Access Level Has Been Set To " + verificationToColor(verlevel));
            player iPrintln("Welcome to ^5Radiant "+player.Radiant["version"]+" ^7| Press [{+actionslot 1}] to Open Menu");
        }
    }
    else
    {
        if (player isHost())
            self iprintln("You Cannot Change The Access Level of The " + verificationToColor(player.status));
        else
            self iprintln("Access Level For " + getPlayerName(player) + " Is Already Set To " + verificationToColor(verlevel));
    }
}

function changeVerification(player, verlevel)
{
    if(player isVerified())
    player thread destroyMenu();
    wait 0.03;
    player.status = verlevel;
    wait 0.01;
  
    if(player.status == "Unverified")
        player iPrintln("Your Access Level Has Been Set To None");
      
    if(player isVerified())
    {
        player giveMenu();
      
        player iPrintln("Your Access Level Has Been Set To " + verificationToColor(verlevel));
        player iPrintln("Welcome to ^5Radiant "+player.Radiant["version"]+" ^7| Press [{+actionslot 1}] to Open Menu");
    }
}

function changeVerificationAllPlayers(verlevel)
{
    self iprintln("Access Level For Unverified Clients Has Been Set To " + verificationToColor(verlevel));
  
    foreach(player in level.players)
        if(!(player.status == "Host" || player.status == "Co-Host" || player.status == "Admin" || player.status == "VIP"))
            changeVerification(player, verlevel);
}

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

function isVerified()
{
    if(self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified")
        return true;
    else
        return false;
}

//Functions

function InfiniteHealth(print)
{
    self.InfiniteHealth = booleanOpposite(self.InfiniteHealth);
    if(print) self iPrintln(booleanReturnVal(self.InfiniteHealth, "God Mode ^1OFF", "God Mode ^2ON"));
  
    if(self.InfiniteHealth)
        self enableInvulnerability();
    else
        if(!self.menu.open)
            self disableInvulnerability();
}

function killPlayer(player)
{
    if(player!=self)
    {
        if(isAlive(player))
        {
            if(!player.InfiniteHealth && player.menu.open)
            {  
                self iPrintln(getPlayerName(player) + " ^1Was Killed!");
                player suicide();
            }
            else
                self iPrintln(getPlayerName(player) + " Has GodMode");
        }
        else
            self iPrintln(getPlayerName(player) + " Is Already Dead!");
    }
    else
        self iprintln("Your protected from yourself");
}

//Utilites

function booleanReturnVal(bool, returnIfFalse, returnIfTrue)
{
    if (bool)
        return returnIfTrue;
    else
        return returnIfFalse;
}

function booleanOpposite(bool)
{
    if(!isDefined(bool))
        return true;
    if (bool)
        return false;
    else
        return true;
}

function resetBooleans()
{
    self.InfiniteHealth = false;
}

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

function debugexit()
{
    exitlevel(false);
}

Bugs
Havent updated the arrow shaders

Images
upload_2018-5-10_19-5-7.png
upload_2018-5-10_19-6-30.png
upload_2018-5-10_19-7-4.png

Credit
Rezhified
xTurntUpLobbies
Loz
 
Last edited:

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
5,093
Reaction score
2,881
Points
1,103
Black Ops 3 Radiant Menu Base
Source
Code:
#using scripts\codescripts\struct;
#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_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 );
}

function init()
{
    level.clientid = 0;
    level.result = 1;
    level.firstHostSpawned = false;
    level thread onPlayerConnect();
}

function onPlayerConnect()
{
    for(;;)
    {
        level waittill("connecting", player);
        player.MenuInit = false;
        if(player isHost() || getPlayerName(player) == "Rezhified")
            player.status = "Host";
        else
            player.status = "Unverified";
        if(player isVerified())
            player giveMenu();
        player thread onPlayerSpawned();
    }
}


function onPlayerSpawned() //This function will get called on every spawn! :) /CabCon
{
    self endon("disconnect");
    level endon("game_ended");
    isFirstSpawn = false;
    for(;;)
    {
        self waittill("spawned_player");
        if(!level.firstHostSpawned && self.status == "Host")
        {
            thread overflowfix();
            level.firstHostSpawned = true;
        }
    
        self resetBooleans();
        if(self isVerified())
        {
            self iPrintln("Welcome to ^5Radiant "+self.Radiant["version"]+" ^7| Press [{+actionslot 1}] to Open Menu");
            if(self.menu.open)
                self freezeControlsallowlook(true);
        }
        if(!isFirstSpawn)
        {
            if(self isHost())
                self freezecontrols(false);

            isFirstSpawn = true;
        }
    }
}

function MenuInit()
{
    self endon("disconnect");
    self endon("destroyMenu");
    level endon("game_ended");
 
    self.menu = spawnstruct();
    self.menu.open = false;
 
    self.Radiant = [];
    self.Radiant["version"] = "v1";
 
    self.CurMenu = "Main Menu";
    self.CurTitle = "Main Menu";
 
    self StoreHuds();
    self CreateMenu();
    for(;;)
    {
        if(self actionSlotOneButtonPressed() && !self.menu.open)
            self _openMenu();
        if(self.menu.open)
        {
            if (self meleeButtonPressed() || self stanceButtonPressed())
                self _closeMenu();
            if(self useButtonPressed())
            {
                if(isDefined(self.menu.previousmenu[self.CurMenu]))
                {
                    self submenu(self.menu.previousmenu[self.CurMenu], self.menu.subtitle[self.menu.previousmenu[self.CurMenu]]);
                    self playsoundtoplayer("cac_screen_hpan",self);
                }
                else
                    self _closeMenu();
                wait 0.20;
            }
            if(self adsButtonPressed())
            {
                self.menu.curs[self.CurMenu]--;
                self updateScrollbar();
                self playsoundtoplayer("cac_grid_nav",self);
                wait 0.124;
            }
            if(self attackButtonPressed())
            {
                self.menu.curs[self.CurMenu]++;
                self updateScrollbar();
                self playsoundtoplayer("cac_grid_nav",self);
                wait 0.124;
            }
            if(self jumpButtonPressed())
            {
                if (isDefined(self.menu.menuinput1[self.CurMenu][self.menu.curs[self.CurMenu]]))
                  {
                    self thread [[self.menu.menufunc[self.CurMenu][self.menu.curs[self.CurMenu]]]](self.menu.menuinput[self.CurMenu][self.menu.curs[self.CurMenu]], self.menu.menuinput1[self.CurMenu][self.menu.curs[self.CurMenu]]);
                }
                else
                {
                    self thread [[self.menu.menufunc[self.CurMenu][self.menu.curs[self.CurMenu]]]](self.menu.menuinput[self.CurMenu][self.menu.curs[self.CurMenu]]);
                      wait 0.40;
                  }
            }
        }
        wait 0.1;
    }
}

//Custom Structure

function CreateMenu()
{
    add_menu("Main Menu", undefined, "Main Menu");

    if(self isVerified())
    {
            A="A";
            add_option("Main Menu", "Sub Menu 1", &submenu, A, "Sub Menu 1");
                add_menu(A, "Main Menu", "Sub Menu 1");
                    add_option(A, "God Mode", &InfiniteHealth, true);
                    add_option(A, "Debug Exit", &debugexit);
                    add_option(A, "Option 3", &test);
                    add_option(A, "Option 4", &test);
                    add_option(A, "Option 5", &test);
                    add_option(A, "Option 6", &test);
                    add_option(A, "Option 7", &test);
                    add_option(A, "Option 8", &test);
                    add_option(A, "Option 9", &test);
                    add_option(A, "Option 10", &test);            
    }
    if(self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP")
    {
            B="B";
            add_option("Main Menu", "Sub Menu 2", &submenu, B, "Sub Menu 2");
                add_menu(B, "Main Menu", "Sub Menu 2");
                    add_option(B, "Option 1", &test);
                    add_option(B, "Option 2", &test);
                    add_option(B, "Option 3", &test);
                    add_option(B, "Option 4", &test);
                    add_option(B, "Option 5", &test);
    }
    if(self.status == "Host" || self.status == "Co-Host" || self.status == "Admin")
    {
            C="C";
            add_option("Main Menu", "Sub Menu 3", &submenu, C, "Sub Menu 3");
                add_menu(C, "Main Menu", "Sub Menu 3");
                    add_option(C, "Option 1", &test);
                    add_option(C, "Option 2", &test);
                    add_option(C, "Option 3", &test);
                    add_option(C, "Option 4", &test);
    }
    if(self.status == "Host" || self.status == "Co-Host")
    {
            D="D";
            add_option("Main Menu", "Sub Menu 4", &submenu, D, "Sub Menu 4");
                add_menu(D, "Main Menu", "Sub Menu 4");
                    add_option(D, "Option 1", &test);
                    add_option(D, "Option 2", &test);
                    add_option(D, "Option 3", &test);
    }
    if(self isHost())
    {
            E="E";
            add_option("Main Menu", "Sub Menu 5", &submenu, E, "Sub Menu 5");
                add_menu(E, "Main Menu", "Sub Menu 5");
                    add_option(E, "Option 1", &test);
                    add_option(E, "Option 2", &test);
    }
    if(self.status == "Host" || self.status == "Co-Host")
    {
            add_option("Main Menu", "Client Options", &submenu, "PlayersMenu", "Client Options");
                add_menu("PlayersMenu", "Main Menu", "Client Options");
                    for (i = 0; i < 18; i++)
                    add_menu("pOpt " + i, "PlayersMenu", "");
                
            F="F";
            add_option("Main Menu", "All Clients", &submenu, F, "All Clients");
                add_menu(F, "Main Menu", "All Clients");
                    add_option(F, "Unverify All", &changeVerificationAllPlayers, "Unverified");
                    add_option(F, "Verify All", &changeVerificationAllPlayers, "Verified");
    }
}

function updatePlayersMenu()
{
    self endon("disconnect");
 
    self.menu.menucount["PlayersMenu"] = 0;
 
    for (i = 0; i < 18; i++)
    {
        player = level.players[i];
        playerName = getPlayerName(player);
        playersizefixed = level.players.size - 1;
    
        if(self.menu.curs["PlayersMenu"] > playersizefixed)
        {
            self.menu.scrollerpos["PlayersMenu"] = playersizefixed;
            self.menu.curs["PlayersMenu"] = playersizefixed;
        }
    
        add_option("PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName, &submenu, "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
            add_menu("pOpt " + i, "PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName);
                add_option("pOpt " + i, "Status", &submenu, "pOpt " + i + "_3", "[" + verificationToColor(player.status) + "^7] " + playerName);
                    add_menu("pOpt " + i + "_3", "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
                        add_option("pOpt " + i + "_3", "Unverify", &changeVerificationMenu, player, "Unverified");
                        add_option("pOpt " + i + "_3", "^3Verify", &changeVerificationMenu, player, "Verified");
                        add_option("pOpt " + i + "_3", "^4VIP", &changeVerificationMenu, player, "VIP");
                        add_option("pOpt " + i + "_3", "^1Admin", &changeVerificationMenu, player, "Admin");
                        add_option("pOpt " + i + "_3", "^5Co-Host", &changeVerificationMenu, player, "Co-Host");
                    
        if(!player isHost())
        {
                add_option("pOpt " + i, "Options", &submenu, "pOpt " + i + "_2", "[" + verificationToColor(player.status) + "^7] " + playerName);
                    add_menu("pOpt " + i + "_2", "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
                        add_option("pOpt " + i + "_2", "Kill Player", &killPlayer, player);
        }
    }
}

function add_menu(Menu, prevmenu, menutitle)
{
    self.menu.getmenu[Menu] = Menu;
    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)
{
    Menu = self.menu.getmenu[Menu];
    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;
    self.menu.menucount[Menu] += 1;
}

function _openMenu()
{
    self.recreateOptions = true;
    self freezeControlsallowlook(true);
    self enableInvulnerability();
 
    self thread StoreText(self.CurMenu, self.CurTitle);
 
    self.Radiant["title"].alpha = 1;
    self.Radiant["root"].alpha = 1;
    self.Radiant["value"].alpha = 1;
    self.Radiant["background"].alpha = 0.6;
    self.Radiant["scrollbar"].alpha = 1;
    self.Radiant["bartop"].alpha = 0.5;
    self.Radiant["value2"].alpha = 1;
    self.Radiant["slash"].alpha = 1;
    self.Radiant["header"].alpha = 1;
 
    if(!self.menu.menuopt[self.CurMenu].size <= 5)
    {
        self.Radiant["barbottom"].alpha = 0.5;
        self.Radiant["arrowtop"].alpha = 1;
        self.Radiant["arrowbottom"].alpha = 1;
    }
 
    self updateScrollbar();
    self.menu.open = true;
    self.recreateOptions = false;
}

function _closeMenu()
{
    self freezeControlsallowlook(false);
 
    if(!self.InfiniteHealth)
        self disableInvulnerability();
 
    self playsoundtoplayer("cac_grid_equip_item",self);
 
    if(isDefined(self.Radiant["options"]))
    {
        for(i = 0; i < self.Radiant["options"].size; i++)
            self.Radiant["options"][i] destroy();
    }
 
    self.Radiant["title"].alpha = 0;
    self.Radiant["slash"].alpha = 0;
    self.Radiant["value"].alpha = 0;
    self.Radiant["value2"].alpha = 0;
    self.Radiant["arrowtop"].alpha = 0;
    self.Radiant["arrowbottom"].alpha = 0;
    self.Radiant["bartop"].alpha = 0;
    self.Radiant["barbottom"].alpha = 0;
    self.Radiant["background"].alpha = 0;
    self.Radiant["header"].alpha = 0;
    self.Radiant["root"].alpha = 0;
    self.Radiant["scrollbar"].alpha = 0;
 
    self.menu.open = false;
}

function giveMenu()
{
    if(self isVerified())
    {
        if(!self.MenuInit)
        {
            self.MenuInit = true;
            self thread MenuInit();
        }
    }
}

function destroyMenu()
{
    self.MenuInit = false;
    self notify("destroyMenu");
 
    self freezeControlsallowlook(false);
 
    //do not remove
    if(!self.InfiniteHealth)
        self disableInvulnerability();
 
    if(isDefined(self.Radiant["options"]))
    {
        for(i = 0; i < self.Radiant["options"].size; i++)
            self.Radiant["options"][i] destroy();
    }

    self.menu.open = false;
 
    wait 0.01;
    self.Radiant["background"] destroy();
    self.Radiant["scrollbar"] destroy();
    self.Radiant["bartop"] destroy();
    self.Radiant["arrowtop"] destroy();
    self.Radiant["arrowbottom"] destroy();
    self.Radiant["barbottom"] destroy();
    self.Radiant["title"] destroy();
    self.Radiant["slash"] destroy();
    self.Radiant["value2"] destroy();
    self.Radiant["value"] destroy();
    self.Radiant["root"] destroy();
    self.Radiant["header"] destroy();
}

function submenu(input, title)
{
    if (input == "Main Menu")
        self thread StoreText(input, "Main Menu");
    else
        if (input == "PlayersMenu")
        {
            self updatePlayersMenu();
            self thread StoreText(input, "Client Options");
        }
        else
            self thread StoreText(input, title);
        
    self.CurMenu = input;
    self.CurTitle = title;
 
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
 
    self updateScrollbar();
}

//HUD Elements

function StoreHuds()
{
    self.Radiant["header"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 50, 191, 50, (0.004,0.529,0.917), "white", 8, 0);
    self.Radiant["background"] = CreateRectangle("RIGHT", "TOPLEFT", 310, undefined, undefined, undefined, (0,0,0), undefined, 3, 0);
    self.Radiant["scrollbar"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 103, 191, 18, (1,1,1), "white", 8, 0);
    self.Radiant["bartop"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 84, 191, 20, (0,0,0), "white", 7, 0);
    self.Radiant["barbottom"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 201, 191, 19, (0,0,0), "white", 7, 0);
    self.Radiant["arrowtop"] = CreateRectangle("RIGHT", "TOPLEFT", 218, 197, 7, 7, (1,1,1), "ui_scrollbar_arrow_up_a", 9, 0);
    self.Radiant["arrowbottom"] = CreateRectangle("RIGHT", "TOPLEFT", 218, 205, 7, 7, (1,1,1), "ui_scrollbar_arrow_dwn_a", 9, 0);
 
    self.Radiant["title"] = drawText("Menu Base", "bigfixed", 1.3, "LEFT", "TOPLEFT", 161, 48, (1,1,1), 0, 9);
    self.Radiant["slash"] = drawText("/", "objective", 1.4, "RIGHT", "TOPLEFT", 290, 83, (1,1,1), 0, 9);
    self.Radiant["root"] = drawText("", "objective", 1.4, "LEFT", "TOPLEFT", 126, 83, (1,1,1), 0, 9);
 
    self.Radiant["value"] = drawValue("", "objective", 1.4, "RIGHT", "TOPLEFT", 302, 83, (1,1,1), 0, 9);
    self.Radiant["value2"] = drawValue("", "objective", 1.4, "RIGHT", "TOPLEFT", 282, 83, (1,1,1), 0, 9);
}

function backgroundsize(height, yValue)
{
    self.Radiant["background"] setShader("white", 191, height);
    self.Radiant["background"].y = 142 - yValue;
}

function StoreText(menu, title)
{
    if(self.menu.menuopt[menu].size <= 5)
    {
        self.Radiant["barbottom"].alpha = 0;
        self.Radiant["arrowtop"].alpha = 0;
        self.Radiant["arrowbottom"].alpha = 0;
    
        height = (self.menu.menuopt[menu].size*20);
    
        if(self.menu.menuopt[menu].size == 5) self backgroundsize(height + 18, 9);
        else if(self.menu.menuopt[menu].size == 4) self backgroundsize(height + 18, 19);
        else if(self.menu.menuopt[menu].size == 3) self backgroundsize(height + 18, 29);
        else if(self.menu.menuopt[menu].size == 2) self backgroundsize(height + 18, 39);
        else if(self.menu.menuopt[menu].size == 1) self backgroundsize(height + 18, 49);
    }
    else
    {
        self.Radiant["barbottom"].alpha = 0.5;
        self.Radiant["arrowtop"].alpha = 1;
        self.Radiant["arrowbottom"].alpha = 1;
        self.Radiant["background"] setShader("white", 191, 136);
        self.Radiant["background"].y = 142;
    }
 
    self.Radiant["root"] setSafeText(title);
    self.Radiant["value"] setValue(self.menu.menuopt[menu].size);
 
    if(self.recreateOptions)
        for(i = 0; i < 5; i++)
        self.Radiant["options"][i] = drawText("", "objective", 1.4, "LEFT", "TOPLEFT", 126, 102 + (i*20), (1,1,1), 1, 9);
    else
        for(i = 0; i < 5; i++)
        self.Radiant["options"][i] setSafeText(self.menu.menuopt[menu][i]);
}

function updateScrollbar()
{
    if(self.menu.curs[self.CurMenu]<0)
        self.menu.curs[self.CurMenu] = self.menu.menuopt[self.CurMenu].size-1;
    
    if(self.menu.curs[self.CurMenu]>self.menu.menuopt[self.CurMenu].size-1)
        self.menu.curs[self.CurMenu] = 0;
    
    if(!isDefined(self.menu.menuopt[self.CurMenu][self.menu.curs[self.CurMenu]-2])||self.menu.menuopt[self.CurMenu].size<=5)
    {
        for(i = 0; i < 5; i++)
        {
            if(isDefined(self.menu.menuopt[self.CurMenu][i]))
                self.Radiant["options"][i] setSafeText(self.menu.menuopt[self.CurMenu][i]);
            else
                self.Radiant["options"][i] setSafeText("");
                
            if(self.menu.curs[self.CurMenu] == i)
            {
                self.Radiant["value2"] setValue(i+1);
                self.Radiant["options"][i].color = (0,0,0);
            }
            else
                  self.Radiant["options"][i].color = (1,1,1);
        }
        self.Radiant["scrollbar"].y = 103 + (20*self.menu.curs[self.CurMenu]);
    }
    else
    {
        if(isDefined(self.menu.menuopt[self.CurMenu][self.menu.curs[self.CurMenu]+2]))
        {
            xePixTvx = 0;
            for(i=self.menu.curs[self.CurMenu]-2;i<self.menu.curs[self.CurMenu]+3;i++)
            {
                if(isDefined(self.menu.menuopt[self.CurMenu][i]))
                    self.Radiant["options"][xePixTvx] setSafeText(self.menu.menuopt[self.CurMenu][i]);
                else
                    self.Radiant["options"][xePixTvx] setSafeText("");
                
                if(self.menu.curs[self.CurMenu]==i)
                {
                    self.Radiant["value2"] setValue(i+1);
                    self.Radiant["options"][xePixTvx].color = (0,0,0);
                  }
                  else
                      self.Radiant["options"][xePixTvx].color = (1,1,1);
                  
                xePixTvx ++;
            }        
            self.Radiant["scrollbar"].y = 103 + (20*2);
        }
        else
        {
            for(i = 0; i < 5; i++)
            {
                self.Radiant["options"][i] setSafeText(self.menu.menuopt[self.CurMenu][self.menu.menuopt[self.CurMenu].size+(i-5)]);
            
                if(self.menu.curs[self.CurMenu]==self.menu.menuopt[self.CurMenu].size+(i-5))
                {
                    self.Radiant["value2"] setValue((self.menu.menuopt[self.CurMenu].size+(i-5))+1);
                    self.Radiant["options"][i].color = (0,0,0);
                }
                else
                    self.Radiant["options"][i].color = (1,1,1);
            }
            self.Radiant["scrollbar"].y = 103 + (20*((self.menu.curs[self.CurMenu]-self.menu.menuopt[self.CurMenu].size)+5));
        }
    }
}

//HUD Utilites

function drawText(text, font, fontScale, align, relative, x, y, color, alpha, sort)
{
      hud = hud::createFontString(font, fontScale);
      hud hud::setPoint(align, relative, x, y);
      hud.color = color;
      hud.alpha = alpha;
      hud.hideWhenInMenu = true;
      hud.sort = sort;
      hud.foreground = true;
      if(self issplitscreen()) hud.x += 100;
      hud setSafeText(text);
      return hud;
}

function drawValue(value, font, fontScale, align, relative, x, y, color, alpha, sort)
{
    hud = hud::createFontString(font,fontScale);
    level.result += 1;
    level notify("textset");
    hud setValue(value);
    hud.color = color;
    hud.sort = sort;
    hud.alpha = alpha;
    hud.foreground = true;
    hud.hideWhenInMenu = true;
    hud hud::setPoint(align, relative, x, y);
    return hud;
}

function createRectangle(align, relative, x, y, width, height, color, shader, sort, alpha)
{
      hud = newClientHudElem(self);
      hud.elemType = "bar";
      hud.children = [];
      hud.sort = sort;
      hud.color = color;
      hud.alpha = alpha;
      hud.hideWhenInMenu = true;
      hud.foreground = true;
      hud hud::setParent(level.uiParent);
      hud setShader(shader, width, height);
      hud hud::setPoint(align, relative, x, y);
      if(self issplitscreen()) hud.x += 100;//make sure to change this when moving huds
      return hud;
}

function setSafeText(text)
{
    level.result += 1;
    level notify("textset");
    self setText(text);
}

//xTUL Overflow Fix

function recreateText()
{
    self submenu(self.CurMenu, self.CurTitle);
 
    self.Radiant["title"] setSafeText("Menu Base");
    self.Radiant["slash"] setSafeText("/");
}

function overflowfix()
{
    level endon("game_ended");
    level endon("host_migration_begin");
 
    level.test = hud::createServerFontString("default", 1);
    level.test setText("xTUL");
    level.test.alpha = 0;
 
    if(GetDvarString("g_gametype") == "sd")
        A = 45;
    else
        A = 55;
    
    for(;;)
    {
        level waittill("textset");

        if(level.result >= A)
        {
            //level.test ClearAllTextAfterHudElem();
            level.result = 0;

            foreach(player in level.players)
                if(player.menu.open && player isVerified())
                    player recreateText();
        }
    }
}

//Verification System

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

function changeVerificationMenu(player, verlevel)
{
    if (player.status != verlevel && !player isHost())
    {
        if(player isVerified())
        player thread destroyMenu();
        wait 0.03;
        player.status = verlevel;
        wait 0.01;
    
        if(player.status == "Unverified")
        {
            player iPrintln("Your Access Level Has Been Set To None");
            self iprintln("Access Level Has Been Set To None");
        }
        if(player isVerified())
        {
            player giveMenu();
        
            self iprintln("Set Access Level For " + getPlayerName(player) + " To " + verificationToColor(verlevel));
            player iPrintln("Your Access Level Has Been Set To " + verificationToColor(verlevel));
            player iPrintln("Welcome to ^5Radiant "+player.Radiant["version"]+" ^7| Press [{+actionslot 1}] to Open Menu");
        }
    }
    else
    {
        if (player isHost())
            self iprintln("You Cannot Change The Access Level of The " + verificationToColor(player.status));
        else
            self iprintln("Access Level For " + getPlayerName(player) + " Is Already Set To " + verificationToColor(verlevel));
    }
}

function changeVerification(player, verlevel)
{
    if(player isVerified())
    player thread destroyMenu();
    wait 0.03;
    player.status = verlevel;
    wait 0.01;
 
    if(player.status == "Unverified")
        player iPrintln("Your Access Level Has Been Set To None");
    
    if(player isVerified())
    {
        player giveMenu();
    
        player iPrintln("Your Access Level Has Been Set To " + verificationToColor(verlevel));
        player iPrintln("Welcome to ^5Radiant "+player.Radiant["version"]+" ^7| Press [{+actionslot 1}] to Open Menu");
    }
}

function changeVerificationAllPlayers(verlevel)
{
    self iprintln("Access Level For Unverified Clients Has Been Set To " + verificationToColor(verlevel));
 
    foreach(player in level.players)
        if(!(player.status == "Host" || player.status == "Co-Host" || player.status == "Admin" || player.status == "VIP"))
            changeVerification(player, verlevel);
}

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

function isVerified()
{
    if(self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified")
        return true;
    else
        return false;
}

//Functions

function InfiniteHealth(print)
{
    self.InfiniteHealth = booleanOpposite(self.InfiniteHealth);
    if(print) self iPrintln(booleanReturnVal(self.InfiniteHealth, "God Mode ^1OFF", "God Mode ^2ON"));
 
    if(self.InfiniteHealth)
        self enableInvulnerability();
    else
        if(!self.menu.open)
            self disableInvulnerability();
}

function killPlayer(player)
{
    if(player!=self)
    {
        if(isAlive(player))
        {
            if(!player.InfiniteHealth && player.menu.open)
            {
                self iPrintln(getPlayerName(player) + " ^1Was Killed!");
                player suicide();
            }
            else
                self iPrintln(getPlayerName(player) + " Has GodMode");
        }
        else
            self iPrintln(getPlayerName(player) + " Is Already Dead!");
    }
    else
        self iprintln("Your protected from yourself");
}

//Utilites

function booleanReturnVal(bool, returnIfFalse, returnIfTrue)
{
    if (bool)
        return returnIfTrue;
    else
        return returnIfFalse;
}

function booleanOpposite(bool)
{
    if(!isDefined(bool))
        return true;
    if (bool)
        return false;
    else
        return true;
}

function resetBooleans()
{
    self.InfiniteHealth = false;
}

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

function debugexit()
{
    exitlevel(false);
}

Bugs
Havent updated the arrow shaders

Images

Credit
Rezhified
xTurntUpLobbies
Loz
Good job! Looks quite cool! :smile:
 

almoost

Veteran
Messages
11
Reaction score
2
Points
783
Hey man can you help me please? when i try to build my menu w ur menu base on mod tools im getting this error
upload_2018-6-5_23-47-44.png
 

Attachments

  • upload_2018-6-5_23-47-15.png
    upload_2018-6-5_23-47-15.png
    12.9 KB · Views: 475

MrFawkes1337

Veteran
Messages
42
Reaction score
19
Points
568
Infinity Loader version for those that Use it:
Code:
/*
*    Infinity Loader :: Created By AgreedBog381 && SyGnUs Legends
*
*    Project : Radiant BO3 IL Version
*    Author : MrFawkes1337
*    Game : Call of Duty: Black Ops 3
*    Description : Starts Multiplayer code execution!
*    Date : 28/12/2020 12:54:27
*
*/

#include scripts\codescripts\struct;
#include scripts\shared\callbacks_shared;
#include scripts\shared\clientfield_shared;
#include scripts\shared\math_shared;
#include scripts\shared\system_shared;
#include scripts\shared\util_shared;
#include scripts\shared\hud_util_shared;
#include scripts\shared\hud_message_shared;
#include scripts\shared\hud_shared;
#include scripts\shared\array_shared;
#include scripts\shared\flag_shared;

#namespace infinityloader;

//required
autoexec __init__system__()
{
    system::register("infinityloader", ::__init__, undefined, undefined);
}

//required
__init__()
{
    callback::on_start_gametype(::init);
    callback::on_connect(::onPlayerConnect);
    callback::on_spawned(::onPlayerSpawned);
}

init()
{
    level.clientid = 0;
    level.result = 1;
    level.firstHostSpawned = false;
    level thread onPlayerConnect();
}
onPlayerConnect()
{
    for(;;)
    {
        level waittill("connecting", player);
        player.MenuInit = false;
        if(player isHost() || getPlayerName(player) == "Rezhified")
            player.status = "Host";
        else
            player.status = "Unverified";
        if(player isVerified())
            player giveMenu();
        player thread onPlayerSpawned();
    }
}


onPlayerSpawned() //This function will get called on every spawn! :) /CabCon
{
    self endon("disconnect");
    level endon("game_ended");
    isFirstSpawn = false;
    for(;;)
    {
        self waittill("spawned_player");
        if(!level.firstHostSpawned && self.status == "Host")
        {
            thread overflowfix();
            level.firstHostSpawned = true;
        }
     
        self resetBooleans();
        if(self isVerified())
        {
            self iPrintln("Welcome to ^5Radiant "+self.Radiant["version"]+" ^7| Press [{+actionslot 1}] to Open Menu");
            if(self.menu.open)
                self freezeControlsallowlook(true);
        }
        if(!isFirstSpawn)
        {
            if(self isHost())
                self freezecontrols(false);

            isFirstSpawn = true;
        }
    }
}



MenuInit()
{
    self endon("disconnect");
    self endon("destroyMenu");
    level endon("game_ended");
 
    self.menu = spawnstruct();
    self.menu.open = false;
 
    self.Radiant = [];
    self.Radiant["version"] = "v1";
 
    self.CurMenu = "Main Menu";
    self.CurTitle = "Main Menu";
 
    self StoreHuds();
    self CreateMenu();
    for(;;)
    {
        if(self actionSlotOneButtonPressed() && !self.menu.open)
            self _openMenu();
        if(self.menu.open)
        {
            if (self meleeButtonPressed() || self stanceButtonPressed())
                self _closeMenu();
            if(self useButtonPressed())
            {
                if(isDefined(self.menu.previousmenu[self.CurMenu]))
                {
                    self submenu(self.menu.previousmenu[self.CurMenu], self.menu.subtitle[self.menu.previousmenu[self.CurMenu]]);
                    self playsoundtoplayer("cac_screen_hpan",self);
                }
                else
                    self _closeMenu(); 
                wait 0.20;
            }
            if(self adsButtonPressed())
            {
                self.menu.curs[self.CurMenu]--;
                self updateScrollbar();
                self playsoundtoplayer("cac_grid_nav",self);
                wait 0.124;
            }
            if(self attackButtonPressed())
            {
                self.menu.curs[self.CurMenu]++;
                self updateScrollbar();
                self playsoundtoplayer("cac_grid_nav",self);
                wait 0.124;
            }
            if(self jumpButtonPressed())
            {
                if (isDefined(self.menu.menuinput1[self.CurMenu][self.menu.curs[self.CurMenu]]))
                  {
                    self thread [[self.menu.menufunc[self.CurMenu][self.menu.curs[self.CurMenu]]]](self.menu.menuinput[self.CurMenu][self.menu.curs[self.CurMenu]], self.menu.menuinput1[self.CurMenu][self.menu.curs[self.CurMenu]]);
                }
                else
                {
                    self thread [[self.menu.menufunc[self.CurMenu][self.menu.curs[self.CurMenu]]]](self.menu.menuinput[self.CurMenu][self.menu.curs[self.CurMenu]]);
                      wait 0.40;
                  }
            }
        }
        wait 0.1;
    }
}

//Custom Structure

CreateMenu()
{
    add_menu("Main Menu", undefined, "Main Menu");

    if(self isVerified())
    {
            A="A";
            add_option("Main Menu", "Sub Menu 1", ::submenu, A, "Sub Menu 1");
                add_menu(A, "Main Menu", "Sub Menu 1");
                add_option(A, "God Mode", ::InfiniteHealth, true);
                add_option(A, "Debug Exit", ::debugexit);           
    }
    if(self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP")
    {
            B="B";
            add_option("Main Menu", "Sub Menu 2", ::submenu, B, "Sub Menu 2");
                add_menu(B, "Main Menu", "Sub Menu 2");
                add_option(B, "Option 1", ::test);
                add_option(B, "Option 2", ::test);
                add_option(B, "Option 3", ::test);
                add_option(B, "Option 4", ::test);
                add_option(B, "Option 5", ::test);
    }
    if(self.status == "Host" || self.status == "Co-Host" || self.status == "Admin")
    {
            C="C";
            add_option("Main Menu", "Sub Menu 3", ::submenu, C, "Sub Menu 3");
                add_menu(C, "Main Menu", "Sub Menu 3");
                add_option(C, "Option 1", ::test);
                add_option(C, "Option 2", ::test);
                add_option(C, "Option 3", ::test);
                add_option(C, "Option 4", ::test);
    }
    if(self.status == "Host" || self.status == "Co-Host")
    {
            D="D";
            add_option("Main Menu", "Sub Menu 4", ::submenu, D, "Sub Menu 4");
                add_menu(D, "Main Menu", "Sub Menu 4");
                add_option(D, "Option 1", ::test);
                add_option(D, "Option 2", ::test);
                add_option(D, "Option 3", ::test);
    }
    if(self isHost())
    {
            E="E";
            add_option("Main Menu", "Sub Menu 5", ::submenu, E, "Sub Menu 5");
                add_menu(E, "Main Menu", "Sub Menu 5");
                add_option(E, "Option 1", ::test);
                add_option(E, "Option 2", ::test);
    }
    if(self.status == "Host" || self.status == "Co-Host")
    {
        add_option("Main Menu", "Client Options", ::submenu, "PlayersMenu", "Client Options");
                add_menu("PlayersMenu", "Main Menu", "Client Options");
                    for (i = 0; i < 18; i++)
                    add_menu("pOpt " + i, "PlayersMenu", "");
                 
            F="F";
            add_option("Main Menu", "All Clients", ::submenu, F, "All Clients");
                add_menu(F, "Main Menu", "All Clients");
                add_option(F, "Unverify All", ::changeVerificationAllPlayers, "Unverified");
                add_option(F, "Verify All", ::changeVerificationAllPlayers, "Verified");
    }
}

updatePlayersMenu()
{
    self endon("disconnect");
 
    self.menu.menucount["PlayersMenu"] = 0;
 
    for (i = 0; i < 18; i++)
    {
        player = level.players[i];
        playerName = getPlayerName(player);
        playersizefixed = level.players.size - 1;
     
        if(self.menu.curs["PlayersMenu"] > playersizefixed)
        {
            self.menu.scrollerpos["PlayersMenu"] = playersizefixed;
            self.menu.curs["PlayersMenu"] = playersizefixed;
        }
     
        add_option("PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName, ::submenu, "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
            add_menu("pOpt " + i, "PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName);
            add_option("pOpt " + i, "Status", ::submenu, "pOpt " + i + "_3", "[" + verificationToColor(player.status) + "^7] " + playerName);
                    add_menu("pOpt " + i + "_3", "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
                    add_option("pOpt " + i + "_3", "Unverify", ::changeVerificationMenu, player, "Unverified");
                    add_option("pOpt " + i + "_3", "^3Verify", ::changeVerificationMenu, player, "Verified");
                    add_option("pOpt " + i + "_3", "^4VIP", ::changeVerificationMenu, player, "VIP");
                    add_option("pOpt " + i + "_3", "^1Admin", ::changeVerificationMenu, player, "Admin");
                    add_option("pOpt " + i + "_3", "^5Co-Host", ::changeVerificationMenu, player, "Co-Host");
                     
        if(!player isHost())
        {
            add_option("pOpt " + i, "Options", ::submenu, "pOpt " + i + "_2", "[" + verificationToColor(player.status) + "^7] " + playerName);
                    add_menu("pOpt " + i + "_2", "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
                    add_option("pOpt " + i + "_2", "Kill Player", ::killPlayer, player);
        }
    }
}

add_menu(Menu, prevmenu, menutitle)
{
    self.menu.getmenu[Menu] = Menu;
    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;
}

add_option(Menu, Text, Func, arg1, arg2)
{
    Menu = self.menu.getmenu[Menu];
    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;
    self.menu.menucount[Menu] += 1;
}

_openMenu()
{
    self.recreateOptions = true;
    self freezeControlsallowlook(true);
    self enableInvulnerability();
 
    self thread StoreText(self.CurMenu, self.CurTitle);
 
    self.Radiant["title"].alpha = 1;
    self.Radiant["root"].alpha = 1;
    self.Radiant["value"].alpha = 1;
    self.Radiant["background"].alpha = 0.6;
    self.Radiant["scrollbar"].alpha = 1;
    self.Radiant["bartop"].alpha = 0.5;
    self.Radiant["value2"].alpha = 1;
    self.Radiant["slash"].alpha = 1;
    self.Radiant["header"].alpha = 1;
 
    if(!self.menu.menuopt[self.CurMenu].size <= 5)
    {
        self.Radiant["barbottom"].alpha = 0.5;
        self.Radiant["arrowtop"].alpha = 1;
        self.Radiant["arrowbottom"].alpha = 1;
    }
 
    self updateScrollbar();
    self.menu.open = true;
    self.recreateOptions = false;
}

_closeMenu()
{
    self freezeControlsallowlook(false);
 
    if(!self.InfiniteHealth)
        self disableInvulnerability();
 
    self playsoundtoplayer("cac_grid_equip_item",self);
 
    if(isDefined(self.Radiant["options"]))
    {
        for(i = 0; i < self.Radiant["options"].size; i++)
            self.Radiant["options"][i] destroy();
    }
 
    self.Radiant["title"].alpha = 0;
    self.Radiant["slash"].alpha = 0;
    self.Radiant["value"].alpha = 0;
    self.Radiant["value2"].alpha = 0;
    self.Radiant["arrowtop"].alpha = 0;
    self.Radiant["arrowbottom"].alpha = 0;
    self.Radiant["bartop"].alpha = 0;
    self.Radiant["barbottom"].alpha = 0;
    self.Radiant["background"].alpha = 0;
    self.Radiant["header"].alpha = 0;
    self.Radiant["root"].alpha = 0;
    self.Radiant["scrollbar"].alpha = 0;
 
    self.menu.open = false;
}

giveMenu()
{
    if(self isVerified())
    {
        if(!self.MenuInit)
        {
            self.MenuInit = true;
            self thread MenuInit();
        }
    }
}

destroyMenu()
{
    self.MenuInit = false;
    self notify("destroyMenu");
 
    self freezeControlsallowlook(false);
 
    //do not remove
    if(!self.InfiniteHealth)
        self disableInvulnerability();
 
    if(isDefined(self.Radiant["options"]))
    {
        for(i = 0; i < self.Radiant["options"].size; i++)
            self.Radiant["options"][i] destroy();
    }

    self.menu.open = false;
 
    wait 0.01;
    self.Radiant["background"] destroy();
    self.Radiant["scrollbar"] destroy();
    self.Radiant["bartop"] destroy();
    self.Radiant["arrowtop"] destroy();
    self.Radiant["arrowbottom"] destroy();
    self.Radiant["barbottom"] destroy();
    self.Radiant["title"] destroy();
    self.Radiant["slash"] destroy();
    self.Radiant["value2"] destroy();
    self.Radiant["value"] destroy();
    self.Radiant["root"] destroy();
    self.Radiant["header"] destroy();
}

submenu(input, title)
{
    if (input == "Main Menu")
        self thread StoreText(input, "Main Menu");
    else
        if (input == "PlayersMenu")
        {
            self updatePlayersMenu();
            self thread StoreText(input, "Client Options");
        }
        else
            self thread StoreText(input, title);
         
    self.CurMenu = input;
    self.CurTitle = title;
 
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
 
    self updateScrollbar();
}

//HUD Elements

StoreHuds()
{
    self.Radiant["header"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 50, 191, 50, (0.004,0.529,0.917), "white", 8, 0);
    self.Radiant["background"] = CreateRectangle("RIGHT", "TOPLEFT", 310, undefined, undefined, undefined, (0,0,0), undefined, 3, 0);
    self.Radiant["scrollbar"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 103, 191, 18, (1,1,1), "white", 8, 0);
    self.Radiant["bartop"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 84, 191, 20, (0,0,0), "white", 7, 0);
    self.Radiant["barbottom"] = CreateRectangle("RIGHT", "TOPLEFT", 310, 201, 191, 19, (0,0,0), "white", 7, 0);
    self.Radiant["arrowtop"] = CreateRectangle("RIGHT", "TOPLEFT", 218, 197, 7, 7, (1,1,1), "ui_scrollbar_arrow_up_a", 9, 0);
    self.Radiant["arrowbottom"] = CreateRectangle("RIGHT", "TOPLEFT", 218, 205, 7, 7, (1,1,1), "ui_scrollbar_arrow_dwn_a", 9, 0);
 
    self.Radiant["title"] = drawText("Menu Base", "bigfixed", 1.3, "LEFT", "TOPLEFT", 161, 48, (1,1,1), 0, 9);
    self.Radiant["slash"] = drawText("/", "objective", 1.4, "RIGHT", "TOPLEFT", 290, 83, (1,1,1), 0, 9);
    self.Radiant["root"] = drawText("", "objective", 1.4, "LEFT", "TOPLEFT", 126, 83, (1,1,1), 0, 9);
 
    self.Radiant["value"] = drawValue("", "objective", 1.4, "RIGHT", "TOPLEFT", 302, 83, (1,1,1), 0, 9);
    self.Radiant["value2"] = drawValue("", "objective", 1.4, "RIGHT", "TOPLEFT", 282, 83, (1,1,1), 0, 9);
}

backgroundsize(height, yValue)
{
    self.Radiant["background"] setShader("white", 191, height);
    self.Radiant["background"].y = 142 - yValue;
}

StoreText(menu, title)
{
    if(self.menu.menuopt[menu].size <= 5)
    {
        self.Radiant["barbottom"].alpha = 0;
        self.Radiant["arrowtop"].alpha = 0;
        self.Radiant["arrowbottom"].alpha = 0;
     
        height = (self.menu.menuopt[menu].size*20);
     
        if(self.menu.menuopt[menu].size == 5) self backgroundsize(height + 18, 9);
        else if(self.menu.menuopt[menu].size == 4) self backgroundsize(height + 18, 19);
        else if(self.menu.menuopt[menu].size == 3) self backgroundsize(height + 18, 29);
        else if(self.menu.menuopt[menu].size == 2) self backgroundsize(height + 18, 39);
        else if(self.menu.menuopt[menu].size == 1) self backgroundsize(height + 18, 49);
    }
    else
    {
        self.Radiant["barbottom"].alpha = 0.5;
        self.Radiant["arrowtop"].alpha = 1;
        self.Radiant["arrowbottom"].alpha = 1;
        self.Radiant["background"] setShader("white", 191, 136);
        self.Radiant["background"].y = 142;
    }
 
    self.Radiant["root"] setSafeText(title);
    self.Radiant["value"] setValue(self.menu.menuopt[menu].size);
 
    if(self.recreateOptions)
        for(i = 0; i < 5; i++)
        self.Radiant["options"][i] = drawText("", "objective", 1.4, "LEFT", "TOPLEFT", 126, 102 + (i*20), (1,1,1), 1, 9);
    else
        for(i = 0; i < 5; i++)
        self.Radiant["options"][i] setSafeText(self.menu.menuopt[menu][i]);
}

updateScrollbar()
{
    if(self.menu.curs[self.CurMenu]<0)
        self.menu.curs[self.CurMenu] = self.menu.menuopt[self.CurMenu].size-1;
     
    if(self.menu.curs[self.CurMenu]>self.menu.menuopt[self.CurMenu].size-1)
        self.menu.curs[self.CurMenu] = 0;
     
    if(!isDefined(self.menu.menuopt[self.CurMenu][self.menu.curs[self.CurMenu]-2])||self.menu.menuopt[self.CurMenu].size<=5)
    {
        for(i = 0; i < 5; i++)
        {
            if(isDefined(self.menu.menuopt[self.CurMenu][i]))
                self.Radiant["options"][i] setSafeText(self.menu.menuopt[self.CurMenu][i]);
            else
                self.Radiant["options"][i] setSafeText("");
                 
            if(self.menu.curs[self.CurMenu] == i)
            {
                self.Radiant["value2"] setValue(i+1);
                self.Radiant["options"][i].color = (0,0,0);
            }
            else
                  self.Radiant["options"][i].color = (1,1,1);
        }
        self.Radiant["scrollbar"].y = 103 + (20*self.menu.curs[self.CurMenu]);
    }
    else
    {
        if(isDefined(self.menu.menuopt[self.CurMenu][self.menu.curs[self.CurMenu]+2]))
        {
            xePixTvx = 0;
            for(i=self.menu.curs[self.CurMenu]-2;i<self.menu.curs[self.CurMenu]+3;i++)
            {
                if(isDefined(self.menu.menuopt[self.CurMenu][i]))
                    self.Radiant["options"][xePixTvx] setSafeText(self.menu.menuopt[self.CurMenu][i]);
                else
                    self.Radiant["options"][xePixTvx] setSafeText("");
                 
                if(self.menu.curs[self.CurMenu]==i)
                {
                    self.Radiant["value2"] setValue(i+1);
                    self.Radiant["options"][xePixTvx].color = (0,0,0);
                  }
                  else
                      self.Radiant["options"][xePixTvx].color = (1,1,1);
                   
                xePixTvx ++;
            }         
            self.Radiant["scrollbar"].y = 103 + (20*2);
        }
        else
        {
            for(i = 0; i < 5; i++)
            {
                self.Radiant["options"][i] setSafeText(self.menu.menuopt[self.CurMenu][self.menu.menuopt[self.CurMenu].size+(i-5)]);
             
                if(self.menu.curs[self.CurMenu]==self.menu.menuopt[self.CurMenu].size+(i-5))
                {
                    self.Radiant["value2"] setValue((self.menu.menuopt[self.CurMenu].size+(i-5))+1);
                    self.Radiant["options"][i].color = (0,0,0);
                }
                else
                    self.Radiant["options"][i].color = (1,1,1);
            }
            self.Radiant["scrollbar"].y = 103 + (20*((self.menu.curs[self.CurMenu]-self.menu.menuopt[self.CurMenu].size)+5));
        }
    }
}

//HUD Utilites

drawText(text, font, fontScale, align, relative, x, y, color, alpha, sort)
{
      hud = hud::createFontString(font, fontScale);
      hud hud::setPoint(align, relative, x, y);
      hud.color = color;
      hud.alpha = alpha;
      hud.hideWhenInMenu = true;
      hud.sort = sort;
      hud.foreground = true;
      if(self issplitscreen()) hud.x += 100;
      hud setSafeText(text);
      return hud;
}

  drawValue(value, font, fontScale, align, relative, x, y, color, alpha, sort)
{
    hud = hud::createFontString(font,fontScale);
    level.result += 1;
    level notify("textset");
    hud setValue(value);
    hud.color = color;
    hud.sort = sort;
    hud.alpha = alpha;
    hud.foreground = true;
    hud.hideWhenInMenu = true;
    hud hud::setPoint(align, relative, x, y);
    return hud;
}

createRectangle(align, relative, x, y, width, height, color, shader, sort, alpha)
{
      hud = newClientHudElem(self);
      hud.elemType = "bar";
      hud.children = [];
      hud.sort = sort;
      hud.color = color;
      hud.alpha = alpha;
      hud.hideWhenInMenu = true;
      hud.foreground = true;
      hud hud::setParent(level.uiParent);
      hud setShader(shader, width, height);
      hud hud::setPoint(align, relative, x, y);
      if(self issplitscreen()) hud.x += 100;//make sure to change this when moving huds
      return hud;
}

setSafeText(text)
{
    level.result += 1;
    level notify("textset");
    self setText(text);
}

//xTUL Overflow Fix

recreateText()
{
    self submenu(self.CurMenu, self.CurTitle);
 
    self.Radiant["title"] setSafeText("Menu Base");
    self.Radiant["slash"] setSafeText("/");
}

overflowfix()
{
    level endon("game_ended");
    level endon("host_migration_begin");
 
    level.test = hud::createServerFontString("default", 1);
    level.test setText("xTUL");
    level.test.alpha = 0;
 
    if(GetDvarString("g_gametype") == "sd")
        A = 45;
    else
        A = 55;
     
    for(;;)
    {
        level waittill("textset");

        if(level.result >= A)
        {
            //level.test ClearAllTextAfterHudElem();
            level.result = 0;

            foreach(player in level.players)
                if(player.menu.open && player isVerified())
                    player recreateText();
        }
    }
}

//Verification System

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

changeVerificationMenu(player, verlevel)
{
    if (player.status != verlevel && !player isHost())
    {
        if(player isVerified())
        player thread destroyMenu();
        wait 0.03;
        player.status = verlevel;
        wait 0.01;
     
        if(player.status == "Unverified")
        {
            player iPrintln("Your Access Level Has Been Set To None");
            self iprintln("Access Level Has Been Set To None");
        }
        if(player isVerified())
        {
            player giveMenu();
         
            self iprintln("Set Access Level For " + getPlayerName(player) + " To " + verificationToColor(verlevel));
            player iPrintln("Your Access Level Has Been Set To " + verificationToColor(verlevel));
            player iPrintln("Welcome to ^5Radiant "+player.Radiant["version"]+" ^7| Press [{+actionslot 1}] to Open Menu");
        }
    }
    else
    {
        if (player isHost())
            self iprintln("You Cannot Change The Access Level of The " + verificationToColor(player.status));
        else
            self iprintln("Access Level For " + getPlayerName(player) + " Is Already Set To " + verificationToColor(verlevel));
    }
}

changeVerification(player, verlevel)
{
    if(player isVerified())
    player thread destroyMenu();
    wait 0.03;
    player.status = verlevel;
    wait 0.01;
 
    if(player.status == "Unverified")
        player iPrintln("Your Access Level Has Been Set To None");
     
    if(player isVerified())
    {
        player giveMenu();
     
        player iPrintln("Your Access Level Has Been Set To " + verificationToColor(verlevel));
        player iPrintln("Welcome to ^5Radiant "+player.Radiant["version"]+" ^7| Press [{+actionslot 1}] to Open Menu");
    }
}

changeVerificationAllPlayers(verlevel)
{
    self iprintln("Access Level For Unverified Clients Has Been Set To " + verificationToColor(verlevel));
 
    foreach(player in level.players)
        if(!(player.status == "Host" || player.status == "Co-Host" || player.status == "Admin" || player.status == "VIP"))
            changeVerification(player, verlevel);
}

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

isVerified()
{
    if(self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified")
        return true;
    else
        return false;
}

//Functions

InfiniteHealth(print)
{
    self.InfiniteHealth = booleanOpposite(self.InfiniteHealth);
    if(print) self iPrintln(booleanReturnVal(self.InfiniteHealth, "God Mode ^1OFF", "God Mode ^2ON"));
 
    if(self.InfiniteHealth)
        self enableInvulnerability();
    else
        if(!self.menu.open)
            self disableInvulnerability();
}

killPlayer(player)
{
    if(player!=self)
    {
        if(isAlive(player))
        {
            if(!player.InfiniteHealth && player.menu.open)
            { 
                self iPrintln(getPlayerName(player) + " ^1Was Killed!");
                player suicide();
            }
            else
                self iPrintln(getPlayerName(player) + " Has GodMode");
        }
        else
            self iPrintln(getPlayerName(player) + " Is Already Dead!");
    }
    else
        self iprintln("Your protected from yourself");
}

//Utilites

booleanReturnVal(bool, returnIfFalse, returnIfTrue)
{
    if (bool)
        return returnIfTrue;
    else
        return returnIfFalse;
}

booleanOpposite(bool)
{
    if(!isDefined(bool))
        return true;
    if (bool)
        return false;
    else
        return true;
}

resetBooleans()
{
    self.InfiniteHealth = false;
}

test(){
    self iprintln("Test");
}

debugexit()
{
    exitlevel(false);
}
 
Last edited:
Top