Aspire

Known Member
Messages
31
Reaction score
14
Points
118
Can somebody tell me if there's something wrong with this since I can't test it myself?
Code:
#using scripts\codescripts\struct;
#using scripts\mp\_util;
#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_shared;
#using scripts\shared\_hud_util_shared;
#using scripts\shared\_hud_message_shared;
#insert scripts\shared\shared.gsh;

#namespace test_map;

function main()
{
    precache();

    level thread onPlayerConnect();
    level thread removeSkyBarrier();
    level thread onConnect();
    enableDebugMode(true);
}

function precache()
{
    // DO ALL PRECACHING HERE
}

function onConnect()
{
    level waittill("connected", player);
    if(player IsHost())
        player thread homefront();

    player thread onSpawn();
    player thread setVariables();
}

function onSpawn()
{
    self endon("disconnect");
    level endon("game_ended");

    self.MenuOpen = false;
    self.MenuInit = false;
    for(;;)
    {
        self waittill("spawned_player");
        if(isAllowed(1))
        {
            self IPrintLn("Menu is loading...");
            self thread welcome();
            if(!self.MenuInit)
            {
                self.MenuInit = true;
                self thread MenuInit();
                self thread closeOnDeath();
            }
        }
    }
}

function closeOnDeath()
{
    self endon( "destroyMenu" );
    self endon("disconnect");
    level endon("game_ended");

    for(;;)
    {
        self waittill("death"); //downed
        self.menu.closeondeath = true;
        submenu("Main Menu", "Main Menu");
        self closeMenu();
        self.menu.closeondeath = false;
        //downed true
    }
}

function MenuInit()
{
    self endon("disconnect");
    level endon("game_ended");
   
    self.menu = SpawnStruct();
    self.toggles = SpawnStruct();
   
    self.MenuOpen = false;
   
    self StoreShaders();
    self CreateMenu();
   
    for(;;)
    {  
        if(!self.MenuOpen && !self.downed)
        {
            if(self MeleeButtonPressed() && self AdsButtonPressed())
            {
                openMenu();
            }
        }
        if(self.MenuOpen)
        {
            if(self UseButtonPressed())
            {
                if(isDefined(self.menu.previousmenu[self.menu.currentmenu]))
                {
                    self submenu(self.menu.previousmenu[self.menu.currentmenu]);
                }
                else
                {
                    closeMenu();
                }
                self PlayLocalSound("");
                wait 0.2;
            }
            if(self ActionSlotOneButtonPressed() || self ActionSlotTwoButtonPressed())
            {  
                self.menu.curs[self.menu.currentmenu] += (Iif(self ActionSlotTwoButtonPressed(), 1, -1));
                self.menu.curs[self.menu.currentmenu] = (Iif(self.menu.curs[self.menu.currentmenu] < 0, self.menu.menuopt[self.menu.currentmenu].size-1, Iif(self.menu.curs[self.menu.currentmenu] > self.menu.menuopt[self.menu.currentmenu].size-1, 0, self.menu.curs[self.menu.currentmenu])));
               
                self.menu.scroller MoveOverTime(0.15);
                self.menu.scroller.y = self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1;
                //self.menu.scroller elemMove(0.15, "y", self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1);
                self PlayLocalSound("");
            }
            if(self JumpButtonPressed())
            {
                self thread [[self.menu.menufunc[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]]](self.menu.menuinput[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]], self.menu.menuinput1[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]);
                self PlayLocalSound("");
                wait 0.2;
            }
        }
        wait 0.05;
    }
}

function openMenu()
{
    self StoreText("Main Menu", "Main Menu");
    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0.65;

    self.menu.line MoveOverTime(0.15);
    self.menu.line.y = -50;
   
    self.menu.scroller MoveOverTime(0.15);
    self.menu.scroller.y = self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1;
    self.MenuOpen = true;
}

function closeMenu()
{
    if(!isDefined(self.vars["god"]) || !self.vars["god"])
        DisableInvulnerability();


    for(i = 0; i < self.menu.opt.size; i++)
    {
        self.menu.opt[i] FadeOverTime(0.3);
        self.menu.opt[i].alpha = 0;
    }

    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0;

    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 0;

    self.menu.line MoveOverTime(0.15);
    self.menu.line.y = -550;

    self.menu.scroller MoveOverTime(0.15);
    self.menu.scroller.y = -500;
    self.MenuOpen = false;
    self notify("menu_exit");
}

function StoreShaders()
{
    self.menu.background = self drawShader("white", 320, -50, 300, 500, (0, 0, 0), 0, 0);
    self.menu.scroller = self drawShader("white", 320, -500, 300, 17, (0, 0, 0), 255, 1);
    self.menu.line = self drawShader("white", 170, -550, 2, 500, (0, 0, 0), 255, 2);
    self.menu.line = self drawShader("white", 170, -550, 2, 500, (0, 0, 0), 255, 2);
}

function StoreText(menu, title)
{
    self.menu.currentmenu = menu;
    self.menu.title destroy();
    self.menu.title = drawText(title, "default", 2, 280, 30, (1, 1, 1), 0, (0, 0.58, 1), 1, 3);
    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 1;
   
    for(i=0; i < self.menu.menuopt[menu].size; i++)
    {
        self.menu.opt[i] destroy();
        self.menu.opt[i] = drawText(self.menu.menuopt[menu][i], "default", 1.6, 280, 68 + (i*20), (1, 1, 1), 0, (0, 0, 0), 0, 4);
        self.menu.opt[i] FadeOverTime(0.3);
        self.menu.opt[i].alpha = 1;
    }
}

function welcome()
{
    self endon("death");
    notifyData = SpawnStruct();
    notifyData.titleText = "Welcome " + self.name + " To Menu";
    notifyData.notifyText = "You Have " + self.AccessLevel;
    notifyData.glowColor = (.2, 0, 0);
    notifyData.duration = 7;
    notifyData.font = "default";
    notifyData.hideWhenInMenu = true;
    self thread hud_message::notifyMessage(notifyData);
}

function drawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort)
{
    hud = hud::createFontString(font, fontScale);
    hud setSafeText(text);
    hud.x = x;
    hud.y = y;
    hud.color = color;
    hud.alpha = alpha;
    hud.glowColor = glowColor;
    hud.glowAlpha = glowAlpha;
    hud.sort = sort;
    hud.alpha = alpha;
    hud.hidewheninmenu = true;
    return hud;
}

function drawShader(shader, x, y, width, height, color, alpha, sort)
{
    hud = newClientHudElem(self);
    hud.elemtype = "icon";
    hud.color = color;
    hud.alpha = alpha;
    hud.sort = sort;
    hud.children = [];
    hud hud::setParent(level.uiParent);
    hud setShader(shader, width, height);
    hud.x = x;
    hud.y = y;
    hud.hidewheninmenu = true;
    return hud;
}

function drawValue(fontSize, sort, value, align, relative, x, y, alpha, color)
{
    hud = hud::createFontString("default", fontSize);
    hud hud::setPoint(align, relative, x, y);
    hud setvalue(value);
    hud.sort = sort;
    hud.hidewheninmenu = true;
    hud.alpha = alpha;
    hud.color = color;
    return hud;
}

function elemMoveX(time, x)
{
    self MoveOverTime(time);
    self.x = x;
}

function elemMoveY(time, y)
{
    self MoveOverTime(time);
    self.y = y;
}

function elemFade(time, alpha)
{
    self FadeOverTime(time);
    self.alpha = alpha;
}

function elemFontScale(time, fontscale)
{
    self changefontscaleovertime(time);
    self.fontscale = fontscale;
}

function elemMoveYWait(time, y)
{
    self MoveOverTime(time);
    self.y = y;
    wait time;
}

function elemMoveXWait(time, x)
{
    self MoveOverTime(time);
    self.x = x;
    wait time;
}

function elemFadeWait(time, alpha)
{
    self FadeOverTime(time);
    self.alpha = alpha;
    wait time;
}

function elemScaleWait(time, width, height)
{
    self scaleOverTime(time, width, height);
    wait time;
}

function elemFontScaleWait(time, fontscale)
{
    self changefontscaleovertime(time);
    self.fontscale = fontscale;
    wait time;
}

function CreateMenu()
{
    //self SubMenus();

    self addMenu(undefined, "Main Menu");
    self addOption("Main Menu", "SubMenu 1", &submenu, "SubMenu 1", "SubMenu 1");
    self addOption("Main Menu", "SubMenu 2", &submenu, "SubMenu 2", "SubMenu 2");
    self addOption("Main Menu", "SubMenu 3", &submenu, "SubMenu 3", "SubMenu 3");

    self addMenu("Main Menu", "SubMenu 1");
    self addOption("SubMenu 1", "Option 1", &test);
    self addOption("SubMenu 1", "Option 2", &test);
    self addOption("SubMenu 1", "Option 3", &test);

    self addMenu("Main Menu", "SubMenu 2");
    self addOption("SubMenu 2", "Option 1", &test);
    self addOption("SubMenu 2", "Option 2", &test);
    self addOption("SubMenu 2", "Option 3", &test);

    self addMenu("Main Menu", "SubMenu 3");
    self addOption("SubMenu 3", "Option 1", &test);
    self addOption("SubMenu 3", "Option 2", &test);
    self addOption("SubMenu 3", "Option 3", &test);
}

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

function addOption(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 getCurrentMenu()
{
    return self.menu.currentmenu;
    //return self.CurMenu;
}

function submenu(input, title)
{

    for(i = 0; i < self.menu.opt.size; i++)
    { self.menu.opt[i] destroy(); }
     
    if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
    else
         self thread StoreText(input, title);
       
    self.CurMenu = input;
     
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
       
    if (!self.menu.closeondeath)
    {
        self.menu.scroller MoveOverTime(0.15);
        self.menu.scroller.y = self.menu.opt[self.menu.curs[self.CurMenu]].y+1;
    }
}

function setVar(name, value)
{
   self.vars[name] = value;
}

function getVar(name)
{
   return self.vars[name];
}

function toggle(var, state)
{
    if(isEmpty("state", state))
        setVar(var, !getVar(var));
    else
        setVar(var, state);
       
    if(getVar(var) == true)
        status = "^2Enabled";
    else
        status = "^1Disabled";
   
    // God mode
    if(var == "god")
    {
        self iprintln("God Mode: " + status);
       
        if(getVar(var) == true)
            self EnableInvulnerability();
        else
        {
            self DisableInvulnerability();
        }
    }
}

function isEmpty(type, var)
{
    if(type == "state")
    {
        if(var == "" || !isDefined(var))
            return true;
        else
            return false;
    }
    else if(type == "var")
    {
        if(var == "" || !isDefined(var))
            self.var = true;
        else
            self.var = false;
    }
}

function getName(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 getClan()
{
    cT = getSubStr(self.name, 0, self.name.size);
    if(cT[0] != "[")
        return "";
    for(i = 0; i < cT.size; i++)
    {
        if(cT[i] == "]")
            break;
    }
    cT=getSubStr(cT, 1, i);
    return cT;
}

function Iif(bool, rTrue, rFalse)
{
   if(bool)
     return rTrue;
   else
     return rFalse;
}

function enableDebugMode(toggle)
{
    level.debug = toggle;
}

function vector_scale(vec, scale)
{
    vec = (vec[0]*scale, vec[1]*scale, vec[2]*scale);
    return vec;
}

function setVariables()
{
    self.vars = [];
    setVar("god", false);
    setVar("invisible", false); //just an example
}

/* //IGNORE
function random(var, state)
{
    if(!isEmpty("state", state))
        state = true;

    if(!isInArray(self.vars, var))
        self.vars[self.vars.size] = var;

    setVar(var, state);
}

function submenu(input, menu)
{
    if(!isEmpty("state", menu))
        currentMenu = getCurrentMenu();
        addMenu(currentMenu, menu);
   

    for(i = 0; i < self.menu.opt.size; i++)
    { self.menu.opt[i] destroy(); }
     
    if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
    else
         self thread StoreText(input, input);
       
    self.CurMenu = input;
     
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
       
    if (!self.menu.closeondeath)
    {
        self.menu.scroller MoveOverTime(0.15);
        self.menu.scroller.y = self.menu.opt[self.menu.curs[self.CurMenu]].y+1;
    }
}
*/
 

Encryption

Co-Leader of SM|T
Messages
27
Reaction score
12
Points
3
Can somebody tell me if there's something wrong with this since I can't test it myself?
Code:
#using scripts\codescripts\struct;
#using scripts\mp\_util;
#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_shared;
#using scripts\shared\_hud_util_shared;
#using scripts\shared\_hud_message_shared;
#insert scripts\shared\shared.gsh;

#namespace test_map;

function main()
{
    precache();

    level thread onPlayerConnect();
    level thread removeSkyBarrier();
    level thread onConnect();
    enableDebugMode(true);
}

function precache()
{
    // DO ALL PRECACHING HERE
}

function onConnect()
{
    level waittill("connected", player);
    if(player IsHost())
        player thread homefront();

    player thread onSpawn();
    player thread setVariables();
}

function onSpawn()
{
    self endon("disconnect");
    level endon("game_ended");

    self.MenuOpen = false;
    self.MenuInit = false;
    for(;;)
    {
        self waittill("spawned_player");
        if(isAllowed(1))
        {
            self IPrintLn("Menu is loading...");
            self thread welcome();
            if(!self.MenuInit)
            {
                self.MenuInit = true;
                self thread MenuInit();
                self thread closeOnDeath();
            }
        }
    }
}

function closeOnDeath()
{
    self endon( "destroyMenu" );
    self endon("disconnect");
    level endon("game_ended");

    for(;;)
    {
        self waittill("death"); //downed
        self.menu.closeondeath = true;
        submenu("Main Menu", "Main Menu");
        self closeMenu();
        self.menu.closeondeath = false;
        //downed true
    }
}

function MenuInit()
{
    self endon("disconnect");
    level endon("game_ended");
  
    self.menu = SpawnStruct();
    self.toggles = SpawnStruct();
  
    self.MenuOpen = false;
  
    self StoreShaders();
    self CreateMenu();
  
    for(;;)
    { 
        if(!self.MenuOpen && !self.downed)
        {
            if(self MeleeButtonPressed() && self AdsButtonPressed())
            {
                openMenu();
            }
        }
        if(self.MenuOpen)
        {
            if(self UseButtonPressed())
            {
                if(isDefined(self.menu.previousmenu[self.menu.currentmenu]))
                {
                    self submenu(self.menu.previousmenu[self.menu.currentmenu]);
                }
                else
                {
                    closeMenu();
                }
                self PlayLocalSound("");
                wait 0.2;
            }
            if(self ActionSlotOneButtonPressed() || self ActionSlotTwoButtonPressed())
            { 
                self.menu.curs[self.menu.currentmenu] += (Iif(self ActionSlotTwoButtonPressed(), 1, -1));
                self.menu.curs[self.menu.currentmenu] = (Iif(self.menu.curs[self.menu.currentmenu] < 0, self.menu.menuopt[self.menu.currentmenu].size-1, Iif(self.menu.curs[self.menu.currentmenu] > self.menu.menuopt[self.menu.currentmenu].size-1, 0, self.menu.curs[self.menu.currentmenu])));
              
                self.menu.scroller MoveOverTime(0.15);
                self.menu.scroller.y = self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1;
                //self.menu.scroller elemMove(0.15, "y", self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1);
                self PlayLocalSound("");
            }
            if(self JumpButtonPressed())
            {
                self thread [[self.menu.menufunc[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]]](self.menu.menuinput[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]], self.menu.menuinput1[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]);
                self PlayLocalSound("");
                wait 0.2;
            }
        }
        wait 0.05;
    }
}

function openMenu()
{
    self StoreText("Main Menu", "Main Menu");
    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0.65;

    self.menu.line MoveOverTime(0.15);
    self.menu.line.y = -50;
  
    self.menu.scroller MoveOverTime(0.15);
    self.menu.scroller.y = self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1;
    self.MenuOpen = true;
}

function closeMenu()
{
    if(!isDefined(self.vars["god"]) || !self.vars["god"])
        DisableInvulnerability();


    for(i = 0; i < self.menu.opt.size; i++)
    {
        self.menu.opt[i] FadeOverTime(0.3);
        self.menu.opt[i].alpha = 0;
    }

    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0;

    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 0;

    self.menu.line MoveOverTime(0.15);
    self.menu.line.y = -550;

    self.menu.scroller MoveOverTime(0.15);
    self.menu.scroller.y = -500;
    self.MenuOpen = false;
    self notify("menu_exit");
}

function StoreShaders()
{
    self.menu.background = self drawShader("white", 320, -50, 300, 500, (0, 0, 0), 0, 0);
    self.menu.scroller = self drawShader("white", 320, -500, 300, 17, (0, 0, 0), 255, 1);
    self.menu.line = self drawShader("white", 170, -550, 2, 500, (0, 0, 0), 255, 2);
    self.menu.line = self drawShader("white", 170, -550, 2, 500, (0, 0, 0), 255, 2);
}

function StoreText(menu, title)
{
    self.menu.currentmenu = menu;
    self.menu.title destroy();
    self.menu.title = drawText(title, "default", 2, 280, 30, (1, 1, 1), 0, (0, 0.58, 1), 1, 3);
    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 1;
  
    for(i=0; i < self.menu.menuopt[menu].size; i++)
    {
        self.menu.opt[i] destroy();
        self.menu.opt[i] = drawText(self.menu.menuopt[menu][i], "default", 1.6, 280, 68 + (i*20), (1, 1, 1), 0, (0, 0, 0), 0, 4);
        self.menu.opt[i] FadeOverTime(0.3);
        self.menu.opt[i].alpha = 1;
    }
}

function welcome()
{
    self endon("death");
    notifyData = SpawnStruct();
    notifyData.titleText = "Welcome " + self.name + " To Menu";
    notifyData.notifyText = "You Have " + self.AccessLevel;
    notifyData.glowColor = (.2, 0, 0);
    notifyData.duration = 7;
    notifyData.font = "default";
    notifyData.hideWhenInMenu = true;
    self thread hud_message::notifyMessage(notifyData);
}

function drawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort)
{
    hud = hud::createFontString(font, fontScale);
    hud setSafeText(text);
    hud.x = x;
    hud.y = y;
    hud.color = color;
    hud.alpha = alpha;
    hud.glowColor = glowColor;
    hud.glowAlpha = glowAlpha;
    hud.sort = sort;
    hud.alpha = alpha;
    hud.hidewheninmenu = true;
    return hud;
}

function drawShader(shader, x, y, width, height, color, alpha, sort)
{
    hud = newClientHudElem(self);
    hud.elemtype = "icon";
    hud.color = color;
    hud.alpha = alpha;
    hud.sort = sort;
    hud.children = [];
    hud hud::setParent(level.uiParent);
    hud setShader(shader, width, height);
    hud.x = x;
    hud.y = y;
    hud.hidewheninmenu = true;
    return hud;
}

function drawValue(fontSize, sort, value, align, relative, x, y, alpha, color)
{
    hud = hud::createFontString("default", fontSize);
    hud hud::setPoint(align, relative, x, y);
    hud setvalue(value);
    hud.sort = sort;
    hud.hidewheninmenu = true;
    hud.alpha = alpha;
    hud.color = color;
    return hud;
}

function elemMoveX(time, x)
{
    self MoveOverTime(time);
    self.x = x;
}

function elemMoveY(time, y)
{
    self MoveOverTime(time);
    self.y = y;
}

function elemFade(time, alpha)
{
    self FadeOverTime(time);
    self.alpha = alpha;
}

function elemFontScale(time, fontscale)
{
    self changefontscaleovertime(time);
    self.fontscale = fontscale;
}

function elemMoveYWait(time, y)
{
    self MoveOverTime(time);
    self.y = y;
    wait time;
}

function elemMoveXWait(time, x)
{
    self MoveOverTime(time);
    self.x = x;
    wait time;
}

function elemFadeWait(time, alpha)
{
    self FadeOverTime(time);
    self.alpha = alpha;
    wait time;
}

function elemScaleWait(time, width, height)
{
    self scaleOverTime(time, width, height);
    wait time;
}

function elemFontScaleWait(time, fontscale)
{
    self changefontscaleovertime(time);
    self.fontscale = fontscale;
    wait time;
}

function CreateMenu()
{
    //self SubMenus();

    self addMenu(undefined, "Main Menu");
    self addOption("Main Menu", "SubMenu 1", &submenu, "SubMenu 1", "SubMenu 1");
    self addOption("Main Menu", "SubMenu 2", &submenu, "SubMenu 2", "SubMenu 2");
    self addOption("Main Menu", "SubMenu 3", &submenu, "SubMenu 3", "SubMenu 3");

    self addMenu("Main Menu", "SubMenu 1");
    self addOption("SubMenu 1", "Option 1", &test);
    self addOption("SubMenu 1", "Option 2", &test);
    self addOption("SubMenu 1", "Option 3", &test);

    self addMenu("Main Menu", "SubMenu 2");
    self addOption("SubMenu 2", "Option 1", &test);
    self addOption("SubMenu 2", "Option 2", &test);
    self addOption("SubMenu 2", "Option 3", &test);

    self addMenu("Main Menu", "SubMenu 3");
    self addOption("SubMenu 3", "Option 1", &test);
    self addOption("SubMenu 3", "Option 2", &test);
    self addOption("SubMenu 3", "Option 3", &test);
}

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

function addOption(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 getCurrentMenu()
{
    return self.menu.currentmenu;
    //return self.CurMenu;
}

function submenu(input, title)
{

    for(i = 0; i < self.menu.opt.size; i++)
    { self.menu.opt[i] destroy(); }
    
    if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
    else
         self thread StoreText(input, title);
      
    self.CurMenu = input;
    
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
      
    if (!self.menu.closeondeath)
    {
        self.menu.scroller MoveOverTime(0.15);
        self.menu.scroller.y = self.menu.opt[self.menu.curs[self.CurMenu]].y+1;
    }
}

function setVar(name, value)
{
   self.vars[name] = value;
}

function getVar(name)
{
   return self.vars[name];
}

function toggle(var, state)
{
    if(isEmpty("state", state))
        setVar(var, !getVar(var));
    else
        setVar(var, state);
      
    if(getVar(var) == true)
        status = "^2Enabled";
    else
        status = "^1Disabled";
  
    // God mode
    if(var == "god")
    {
        self iprintln("God Mode: " + status);
      
        if(getVar(var) == true)
            self EnableInvulnerability();
        else
        {
            self DisableInvulnerability();
        }
    }
}

function isEmpty(type, var)
{
    if(type == "state")
    {
        if(var == "" || !isDefined(var))
            return true;
        else
            return false;
    }
    else if(type == "var")
    {
        if(var == "" || !isDefined(var))
            self.var = true;
        else
            self.var = false;
    }
}

function getName(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 getClan()
{
    cT = getSubStr(self.name, 0, self.name.size);
    if(cT[0] != "[")
        return "";
    for(i = 0; i < cT.size; i++)
    {
        if(cT[i] == "]")
            break;
    }
    cT=getSubStr(cT, 1, i);
    return cT;
}

function Iif(bool, rTrue, rFalse)
{
   if(bool)
     return rTrue;
   else
     return rFalse;
}

function enableDebugMode(toggle)
{
    level.debug = toggle;
}

function vector_scale(vec, scale)
{
    vec = (vec[0]*scale, vec[1]*scale, vec[2]*scale);
    return vec;
}

function setVariables()
{
    self.vars = [];
    setVar("god", false);
    setVar("invisible", false); //just an example
}

/* //IGNORE
function random(var, state)
{
    if(!isEmpty("state", state))
        state = true;

    if(!isInArray(self.vars, var))
        self.vars[self.vars.size] = var;

    setVar(var, state);
}

function submenu(input, menu)
{
    if(!isEmpty("state", menu))
        currentMenu = getCurrentMenu();
        addMenu(currentMenu, menu);
  

    for(i = 0; i < self.menu.opt.size; i++)
    { self.menu.opt[i] destroy(); }
    
    if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
    else
         self thread StoreText(input, input);
      
    self.CurMenu = input;
    
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
      
    if (!self.menu.closeondeath)
    {
        self.menu.scroller MoveOverTime(0.15);
        self.menu.scroller.y = self.menu.opt[self.menu.curs[self.CurMenu]].y+1;
    }
}
*/
homefront doesn't seem to be a function
 

JayCoder

Veteran
Staff member
Messages
375
Reaction score
148
Points
903
Can somebody tell me if there's something wrong with this since I can't test it myself?
Code:
#using scripts\codescripts\struct;
#using scripts\mp\_util;
#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_shared;
#using scripts\shared\_hud_util_shared;
#using scripts\shared\_hud_message_shared;
#insert scripts\shared\shared.gsh;

#namespace test_map;

function main()
{
    precache();

    level thread onPlayerConnect();
    level thread removeSkyBarrier();
    level thread onConnect();
    enableDebugMode(true);
}

function precache()
{
    // DO ALL PRECACHING HERE
}

function onConnect()
{
    level waittill("connected", player);
    if(player IsHost())
        player thread homefront();

    player thread onSpawn();
    player thread setVariables();
}

function onSpawn()
{
    self endon("disconnect");
    level endon("game_ended");

    self.MenuOpen = false;
    self.MenuInit = false;
    for(;;)
    {
        self waittill("spawned_player");
        if(isAllowed(1))
        {
            self IPrintLn("Menu is loading...");
            self thread welcome();
            if(!self.MenuInit)
            {
                self.MenuInit = true;
                self thread MenuInit();
                self thread closeOnDeath();
            }
        }
    }
}

function closeOnDeath()
{
    self endon( "destroyMenu" );
    self endon("disconnect");
    level endon("game_ended");

    for(;;)
    {
        self waittill("death"); //downed
        self.menu.closeondeath = true;
        submenu("Main Menu", "Main Menu");
        self closeMenu();
        self.menu.closeondeath = false;
        //downed true
    }
}

function MenuInit()
{
    self endon("disconnect");
    level endon("game_ended");
  
    self.menu = SpawnStruct();
    self.toggles = SpawnStruct();
  
    self.MenuOpen = false;
  
    self StoreShaders();
    self CreateMenu();
  
    for(;;)
    { 
        if(!self.MenuOpen && !self.downed)
        {
            if(self MeleeButtonPressed() && self AdsButtonPressed())
            {
                openMenu();
            }
        }
        if(self.MenuOpen)
        {
            if(self UseButtonPressed())
            {
                if(isDefined(self.menu.previousmenu[self.menu.currentmenu]))
                {
                    self submenu(self.menu.previousmenu[self.menu.currentmenu]);
                }
                else
                {
                    closeMenu();
                }
                self PlayLocalSound("");
                wait 0.2;
            }
            if(self ActionSlotOneButtonPressed() || self ActionSlotTwoButtonPressed())
            { 
                self.menu.curs[self.menu.currentmenu] += (Iif(self ActionSlotTwoButtonPressed(), 1, -1));
                self.menu.curs[self.menu.currentmenu] = (Iif(self.menu.curs[self.menu.currentmenu] < 0, self.menu.menuopt[self.menu.currentmenu].size-1, Iif(self.menu.curs[self.menu.currentmenu] > self.menu.menuopt[self.menu.currentmenu].size-1, 0, self.menu.curs[self.menu.currentmenu])));
              
                self.menu.scroller MoveOverTime(0.15);
                self.menu.scroller.y = self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1;
                //self.menu.scroller elemMove(0.15, "y", self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1);
                self PlayLocalSound("");
            }
            if(self JumpButtonPressed())
            {
                self thread [[self.menu.menufunc[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]]](self.menu.menuinput[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]], self.menu.menuinput1[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]);
                self PlayLocalSound("");
                wait 0.2;
            }
        }
        wait 0.05;
    }
}

function openMenu()
{
    self StoreText("Main Menu", "Main Menu");
    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0.65;

    self.menu.line MoveOverTime(0.15);
    self.menu.line.y = -50;
  
    self.menu.scroller MoveOverTime(0.15);
    self.menu.scroller.y = self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1;
    self.MenuOpen = true;
}

function closeMenu()
{
    if(!isDefined(self.vars["god"]) || !self.vars["god"])
        DisableInvulnerability();


    for(i = 0; i < self.menu.opt.size; i++)
    {
        self.menu.opt[i] FadeOverTime(0.3);
        self.menu.opt[i].alpha = 0;
    }

    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0;

    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 0;

    self.menu.line MoveOverTime(0.15);
    self.menu.line.y = -550;

    self.menu.scroller MoveOverTime(0.15);
    self.menu.scroller.y = -500;
    self.MenuOpen = false;
    self notify("menu_exit");
}

function StoreShaders()
{
    self.menu.background = self drawShader("white", 320, -50, 300, 500, (0, 0, 0), 0, 0);
    self.menu.scroller = self drawShader("white", 320, -500, 300, 17, (0, 0, 0), 255, 1);
    self.menu.line = self drawShader("white", 170, -550, 2, 500, (0, 0, 0), 255, 2);
    self.menu.line = self drawShader("white", 170, -550, 2, 500, (0, 0, 0), 255, 2);
}

function StoreText(menu, title)
{
    self.menu.currentmenu = menu;
    self.menu.title destroy();
    self.menu.title = drawText(title, "default", 2, 280, 30, (1, 1, 1), 0, (0, 0.58, 1), 1, 3);
    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 1;
  
    for(i=0; i < self.menu.menuopt[menu].size; i++)
    {
        self.menu.opt[i] destroy();
        self.menu.opt[i] = drawText(self.menu.menuopt[menu][i], "default", 1.6, 280, 68 + (i*20), (1, 1, 1), 0, (0, 0, 0), 0, 4);
        self.menu.opt[i] FadeOverTime(0.3);
        self.menu.opt[i].alpha = 1;
    }
}

function welcome()
{
    self endon("death");
    notifyData = SpawnStruct();
    notifyData.titleText = "Welcome " + self.name + " To Menu";
    notifyData.notifyText = "You Have " + self.AccessLevel;
    notifyData.glowColor = (.2, 0, 0);
    notifyData.duration = 7;
    notifyData.font = "default";
    notifyData.hideWhenInMenu = true;
    self thread hud_message::notifyMessage(notifyData);
}

function drawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort)
{
    hud = hud::createFontString(font, fontScale);
    hud setSafeText(text);
    hud.x = x;
    hud.y = y;
    hud.color = color;
    hud.alpha = alpha;
    hud.glowColor = glowColor;
    hud.glowAlpha = glowAlpha;
    hud.sort = sort;
    hud.alpha = alpha;
    hud.hidewheninmenu = true;
    return hud;
}

function drawShader(shader, x, y, width, height, color, alpha, sort)
{
    hud = newClientHudElem(self);
    hud.elemtype = "icon";
    hud.color = color;
    hud.alpha = alpha;
    hud.sort = sort;
    hud.children = [];
    hud hud::setParent(level.uiParent);
    hud setShader(shader, width, height);
    hud.x = x;
    hud.y = y;
    hud.hidewheninmenu = true;
    return hud;
}

function drawValue(fontSize, sort, value, align, relative, x, y, alpha, color)
{
    hud = hud::createFontString("default", fontSize);
    hud hud::setPoint(align, relative, x, y);
    hud setvalue(value);
    hud.sort = sort;
    hud.hidewheninmenu = true;
    hud.alpha = alpha;
    hud.color = color;
    return hud;
}

function elemMoveX(time, x)
{
    self MoveOverTime(time);
    self.x = x;
}

function elemMoveY(time, y)
{
    self MoveOverTime(time);
    self.y = y;
}

function elemFade(time, alpha)
{
    self FadeOverTime(time);
    self.alpha = alpha;
}

function elemFontScale(time, fontscale)
{
    self changefontscaleovertime(time);
    self.fontscale = fontscale;
}

function elemMoveYWait(time, y)
{
    self MoveOverTime(time);
    self.y = y;
    wait time;
}

function elemMoveXWait(time, x)
{
    self MoveOverTime(time);
    self.x = x;
    wait time;
}

function elemFadeWait(time, alpha)
{
    self FadeOverTime(time);
    self.alpha = alpha;
    wait time;
}

function elemScaleWait(time, width, height)
{
    self scaleOverTime(time, width, height);
    wait time;
}

function elemFontScaleWait(time, fontscale)
{
    self changefontscaleovertime(time);
    self.fontscale = fontscale;
    wait time;
}

function CreateMenu()
{
    //self SubMenus();

    self addMenu(undefined, "Main Menu");
    self addOption("Main Menu", "SubMenu 1", &submenu, "SubMenu 1", "SubMenu 1");
    self addOption("Main Menu", "SubMenu 2", &submenu, "SubMenu 2", "SubMenu 2");
    self addOption("Main Menu", "SubMenu 3", &submenu, "SubMenu 3", "SubMenu 3");

    self addMenu("Main Menu", "SubMenu 1");
    self addOption("SubMenu 1", "Option 1", &test);
    self addOption("SubMenu 1", "Option 2", &test);
    self addOption("SubMenu 1", "Option 3", &test);

    self addMenu("Main Menu", "SubMenu 2");
    self addOption("SubMenu 2", "Option 1", &test);
    self addOption("SubMenu 2", "Option 2", &test);
    self addOption("SubMenu 2", "Option 3", &test);

    self addMenu("Main Menu", "SubMenu 3");
    self addOption("SubMenu 3", "Option 1", &test);
    self addOption("SubMenu 3", "Option 2", &test);
    self addOption("SubMenu 3", "Option 3", &test);
}

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

function addOption(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 getCurrentMenu()
{
    return self.menu.currentmenu;
    //return self.CurMenu;
}

function submenu(input, title)
{

    for(i = 0; i < self.menu.opt.size; i++)
    { self.menu.opt[i] destroy(); }
    
    if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
    else
         self thread StoreText(input, title);
      
    self.CurMenu = input;
    
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
      
    if (!self.menu.closeondeath)
    {
        self.menu.scroller MoveOverTime(0.15);
        self.menu.scroller.y = self.menu.opt[self.menu.curs[self.CurMenu]].y+1;
    }
}

function setVar(name, value)
{
   self.vars[name] = value;
}

function getVar(name)
{
   return self.vars[name];
}

function toggle(var, state)
{
    if(isEmpty("state", state))
        setVar(var, !getVar(var));
    else
        setVar(var, state);
      
    if(getVar(var) == true)
        status = "^2Enabled";
    else
        status = "^1Disabled";
  
    // God mode
    if(var == "god")
    {
        self iprintln("God Mode: " + status);
      
        if(getVar(var) == true)
            self EnableInvulnerability();
        else
        {
            self DisableInvulnerability();
        }
    }
}

function isEmpty(type, var)
{
    if(type == "state")
    {
        if(var == "" || !isDefined(var))
            return true;
        else
            return false;
    }
    else if(type == "var")
    {
        if(var == "" || !isDefined(var))
            self.var = true;
        else
            self.var = false;
    }
}

function getName(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 getClan()
{
    cT = getSubStr(self.name, 0, self.name.size);
    if(cT[0] != "[")
        return "";
    for(i = 0; i < cT.size; i++)
    {
        if(cT[i] == "]")
            break;
    }
    cT=getSubStr(cT, 1, i);
    return cT;
}

function Iif(bool, rTrue, rFalse)
{
   if(bool)
     return rTrue;
   else
     return rFalse;
}

function enableDebugMode(toggle)
{
    level.debug = toggle;
}

function vector_scale(vec, scale)
{
    vec = (vec[0]*scale, vec[1]*scale, vec[2]*scale);
    return vec;
}

function setVariables()
{
    self.vars = [];
    setVar("god", false);
    setVar("invisible", false); //just an example
}

/* //IGNORE
function random(var, state)
{
    if(!isEmpty("state", state))
        state = true;

    if(!isInArray(self.vars, var))
        self.vars[self.vars.size] = var;

    setVar(var, state);
}

function submenu(input, menu)
{
    if(!isEmpty("state", menu))
        currentMenu = getCurrentMenu();
        addMenu(currentMenu, menu);
  

    for(i = 0; i < self.menu.opt.size; i++)
    { self.menu.opt[i] destroy(); }
    
    if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
    else
         self thread StoreText(input, input);
      
    self.CurMenu = input;
    
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
      
    if (!self.menu.closeondeath)
    {
        self.menu.scroller MoveOverTime(0.15);
        self.menu.scroller.y = self.menu.opt[self.menu.curs[self.CurMenu]].y+1;
    }
}
*/
PHP:
#namespace clientids;
REGISTER_SYSTEM( "clientids", &__init__, undefined )
    
function __init__()
{
    callback::on_start_gametype( &init );
    callback::on_connect( &on_player_connect );
    callback::on_spawned( &on_player_spawned );
}

you can't just take all this out thats not how it works you will get many errors and it will not load! u may want to look into your code and fix it!
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
5,093
Reaction score
2,881
Points
1,103
Can somebody tell me if there's something wrong with this since I can't test it myself?
Code:
#using scripts\codescripts\struct;
#using scripts\mp\_util;
#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_shared;
#using scripts\shared\_hud_util_shared;
#using scripts\shared\_hud_message_shared;
#insert scripts\shared\shared.gsh;

#namespace test_map;

function main()
{
    precache();

    level thread onPlayerConnect();
    level thread removeSkyBarrier();
    level thread onConnect();
    enableDebugMode(true);
}

function precache()
{
    // DO ALL PRECACHING HERE
}

function onConnect()
{
    level waittill("connected", player);
    if(player IsHost())
        player thread homefront();

    player thread onSpawn();
    player thread setVariables();
}

function onSpawn()
{
    self endon("disconnect");
    level endon("game_ended");

    self.MenuOpen = false;
    self.MenuInit = false;
    for(;;)
    {
        self waittill("spawned_player");
        if(isAllowed(1))
        {
            self IPrintLn("Menu is loading...");
            self thread welcome();
            if(!self.MenuInit)
            {
                self.MenuInit = true;
                self thread MenuInit();
                self thread closeOnDeath();
            }
        }
    }
}

function closeOnDeath()
{
    self endon( "destroyMenu" );
    self endon("disconnect");
    level endon("game_ended");

    for(;;)
    {
        self waittill("death"); //downed
        self.menu.closeondeath = true;
        submenu("Main Menu", "Main Menu");
        self closeMenu();
        self.menu.closeondeath = false;
        //downed true
    }
}

function MenuInit()
{
    self endon("disconnect");
    level endon("game_ended");
  
    self.menu = SpawnStruct();
    self.toggles = SpawnStruct();
  
    self.MenuOpen = false;
  
    self StoreShaders();
    self CreateMenu();
  
    for(;;)
    { 
        if(!self.MenuOpen && !self.downed)
        {
            if(self MeleeButtonPressed() && self AdsButtonPressed())
            {
                openMenu();
            }
        }
        if(self.MenuOpen)
        {
            if(self UseButtonPressed())
            {
                if(isDefined(self.menu.previousmenu[self.menu.currentmenu]))
                {
                    self submenu(self.menu.previousmenu[self.menu.currentmenu]);
                }
                else
                {
                    closeMenu();
                }
                self PlayLocalSound("");
                wait 0.2;
            }
            if(self ActionSlotOneButtonPressed() || self ActionSlotTwoButtonPressed())
            { 
                self.menu.curs[self.menu.currentmenu] += (Iif(self ActionSlotTwoButtonPressed(), 1, -1));
                self.menu.curs[self.menu.currentmenu] = (Iif(self.menu.curs[self.menu.currentmenu] < 0, self.menu.menuopt[self.menu.currentmenu].size-1, Iif(self.menu.curs[self.menu.currentmenu] > self.menu.menuopt[self.menu.currentmenu].size-1, 0, self.menu.curs[self.menu.currentmenu])));
              
                self.menu.scroller MoveOverTime(0.15);
                self.menu.scroller.y = self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1;
                //self.menu.scroller elemMove(0.15, "y", self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1);
                self PlayLocalSound("");
            }
            if(self JumpButtonPressed())
            {
                self thread [[self.menu.menufunc[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]]](self.menu.menuinput[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]], self.menu.menuinput1[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]);
                self PlayLocalSound("");
                wait 0.2;
            }
        }
        wait 0.05;
    }
}

function openMenu()
{
    self StoreText("Main Menu", "Main Menu");
    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0.65;

    self.menu.line MoveOverTime(0.15);
    self.menu.line.y = -50;
  
    self.menu.scroller MoveOverTime(0.15);
    self.menu.scroller.y = self.menu.opt[self.menu.curs[self.menu.currentmenu]].y+1;
    self.MenuOpen = true;
}

function closeMenu()
{
    if(!isDefined(self.vars["god"]) || !self.vars["god"])
        DisableInvulnerability();


    for(i = 0; i < self.menu.opt.size; i++)
    {
        self.menu.opt[i] FadeOverTime(0.3);
        self.menu.opt[i].alpha = 0;
    }

    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0;

    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 0;

    self.menu.line MoveOverTime(0.15);
    self.menu.line.y = -550;

    self.menu.scroller MoveOverTime(0.15);
    self.menu.scroller.y = -500;
    self.MenuOpen = false;
    self notify("menu_exit");
}

function StoreShaders()
{
    self.menu.background = self drawShader("white", 320, -50, 300, 500, (0, 0, 0), 0, 0);
    self.menu.scroller = self drawShader("white", 320, -500, 300, 17, (0, 0, 0), 255, 1);
    self.menu.line = self drawShader("white", 170, -550, 2, 500, (0, 0, 0), 255, 2);
    self.menu.line = self drawShader("white", 170, -550, 2, 500, (0, 0, 0), 255, 2);
}

function StoreText(menu, title)
{
    self.menu.currentmenu = menu;
    self.menu.title destroy();
    self.menu.title = drawText(title, "default", 2, 280, 30, (1, 1, 1), 0, (0, 0.58, 1), 1, 3);
    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 1;
  
    for(i=0; i < self.menu.menuopt[menu].size; i++)
    {
        self.menu.opt[i] destroy();
        self.menu.opt[i] = drawText(self.menu.menuopt[menu][i], "default", 1.6, 280, 68 + (i*20), (1, 1, 1), 0, (0, 0, 0), 0, 4);
        self.menu.opt[i] FadeOverTime(0.3);
        self.menu.opt[i].alpha = 1;
    }
}

function welcome()
{
    self endon("death");
    notifyData = SpawnStruct();
    notifyData.titleText = "Welcome " + self.name + " To Menu";
    notifyData.notifyText = "You Have " + self.AccessLevel;
    notifyData.glowColor = (.2, 0, 0);
    notifyData.duration = 7;
    notifyData.font = "default";
    notifyData.hideWhenInMenu = true;
    self thread hud_message::notifyMessage(notifyData);
}

function drawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort)
{
    hud = hud::createFontString(font, fontScale);
    hud setSafeText(text);
    hud.x = x;
    hud.y = y;
    hud.color = color;
    hud.alpha = alpha;
    hud.glowColor = glowColor;
    hud.glowAlpha = glowAlpha;
    hud.sort = sort;
    hud.alpha = alpha;
    hud.hidewheninmenu = true;
    return hud;
}

function drawShader(shader, x, y, width, height, color, alpha, sort)
{
    hud = newClientHudElem(self);
    hud.elemtype = "icon";
    hud.color = color;
    hud.alpha = alpha;
    hud.sort = sort;
    hud.children = [];
    hud hud::setParent(level.uiParent);
    hud setShader(shader, width, height);
    hud.x = x;
    hud.y = y;
    hud.hidewheninmenu = true;
    return hud;
}

function drawValue(fontSize, sort, value, align, relative, x, y, alpha, color)
{
    hud = hud::createFontString("default", fontSize);
    hud hud::setPoint(align, relative, x, y);
    hud setvalue(value);
    hud.sort = sort;
    hud.hidewheninmenu = true;
    hud.alpha = alpha;
    hud.color = color;
    return hud;
}

function elemMoveX(time, x)
{
    self MoveOverTime(time);
    self.x = x;
}

function elemMoveY(time, y)
{
    self MoveOverTime(time);
    self.y = y;
}

function elemFade(time, alpha)
{
    self FadeOverTime(time);
    self.alpha = alpha;
}

function elemFontScale(time, fontscale)
{
    self changefontscaleovertime(time);
    self.fontscale = fontscale;
}

function elemMoveYWait(time, y)
{
    self MoveOverTime(time);
    self.y = y;
    wait time;
}

function elemMoveXWait(time, x)
{
    self MoveOverTime(time);
    self.x = x;
    wait time;
}

function elemFadeWait(time, alpha)
{
    self FadeOverTime(time);
    self.alpha = alpha;
    wait time;
}

function elemScaleWait(time, width, height)
{
    self scaleOverTime(time, width, height);
    wait time;
}

function elemFontScaleWait(time, fontscale)
{
    self changefontscaleovertime(time);
    self.fontscale = fontscale;
    wait time;
}

function CreateMenu()
{
    //self SubMenus();

    self addMenu(undefined, "Main Menu");
    self addOption("Main Menu", "SubMenu 1", &submenu, "SubMenu 1", "SubMenu 1");
    self addOption("Main Menu", "SubMenu 2", &submenu, "SubMenu 2", "SubMenu 2");
    self addOption("Main Menu", "SubMenu 3", &submenu, "SubMenu 3", "SubMenu 3");

    self addMenu("Main Menu", "SubMenu 1");
    self addOption("SubMenu 1", "Option 1", &test);
    self addOption("SubMenu 1", "Option 2", &test);
    self addOption("SubMenu 1", "Option 3", &test);

    self addMenu("Main Menu", "SubMenu 2");
    self addOption("SubMenu 2", "Option 1", &test);
    self addOption("SubMenu 2", "Option 2", &test);
    self addOption("SubMenu 2", "Option 3", &test);

    self addMenu("Main Menu", "SubMenu 3");
    self addOption("SubMenu 3", "Option 1", &test);
    self addOption("SubMenu 3", "Option 2", &test);
    self addOption("SubMenu 3", "Option 3", &test);
}

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

function addOption(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 getCurrentMenu()
{
    return self.menu.currentmenu;
    //return self.CurMenu;
}

function submenu(input, title)
{

    for(i = 0; i < self.menu.opt.size; i++)
    { self.menu.opt[i] destroy(); }
    
    if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
    else
         self thread StoreText(input, title);
      
    self.CurMenu = input;
    
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
      
    if (!self.menu.closeondeath)
    {
        self.menu.scroller MoveOverTime(0.15);
        self.menu.scroller.y = self.menu.opt[self.menu.curs[self.CurMenu]].y+1;
    }
}

function setVar(name, value)
{
   self.vars[name] = value;
}

function getVar(name)
{
   return self.vars[name];
}

function toggle(var, state)
{
    if(isEmpty("state", state))
        setVar(var, !getVar(var));
    else
        setVar(var, state);
      
    if(getVar(var) == true)
        status = "^2Enabled";
    else
        status = "^1Disabled";
  
    // God mode
    if(var == "god")
    {
        self iprintln("God Mode: " + status);
      
        if(getVar(var) == true)
            self EnableInvulnerability();
        else
        {
            self DisableInvulnerability();
        }
    }
}

function isEmpty(type, var)
{
    if(type == "state")
    {
        if(var == "" || !isDefined(var))
            return true;
        else
            return false;
    }
    else if(type == "var")
    {
        if(var == "" || !isDefined(var))
            self.var = true;
        else
            self.var = false;
    }
}

function getName(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 getClan()
{
    cT = getSubStr(self.name, 0, self.name.size);
    if(cT[0] != "[")
        return "";
    for(i = 0; i < cT.size; i++)
    {
        if(cT[i] == "]")
            break;
    }
    cT=getSubStr(cT, 1, i);
    return cT;
}

function Iif(bool, rTrue, rFalse)
{
   if(bool)
     return rTrue;
   else
     return rFalse;
}

function enableDebugMode(toggle)
{
    level.debug = toggle;
}

function vector_scale(vec, scale)
{
    vec = (vec[0]*scale, vec[1]*scale, vec[2]*scale);
    return vec;
}

function setVariables()
{
    self.vars = [];
    setVar("god", false);
    setVar("invisible", false); //just an example
}

/* //IGNORE
function random(var, state)
{
    if(!isEmpty("state", state))
        state = true;

    if(!isInArray(self.vars, var))
        self.vars[self.vars.size] = var;

    setVar(var, state);
}

function submenu(input, menu)
{
    if(!isEmpty("state", menu))
        currentMenu = getCurrentMenu();
        addMenu(currentMenu, menu);
  

    for(i = 0; i < self.menu.opt.size; i++)
    { self.menu.opt[i] destroy(); }
    
    if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
    else
         self thread StoreText(input, input);
      
    self.CurMenu = input;
    
    self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
    self.menu.curs[input] = self.menu.scrollerpos[input];
      
    if (!self.menu.closeondeath)
    {
        self.menu.scroller MoveOverTime(0.15);
        self.menu.scroller.y = self.menu.opt[self.menu.curs[self.CurMenu]].y+1;
    }
}
*/
Could you upload your mods folder with this? Than I will take a look into it. :smile:
 

Aspire

Known Member
Messages
31
Reaction score
14
Points
118
Could you upload your mods folder with this? Than I will take a look into it. :grinning:
This is now for mp (has a verification sytem) and is a mod and
the one on the top was meant to be for a map and shouldt be loaded as a mod,
but if this one works the other one should work too.
 

Attachments

  • mp_startup_mod.rar
    5 KB · Views: 233

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
5,093
Reaction score
2,881
Points
1,103
This is now for mp (has a verification sytem) and is a mod and
the one on the top was meant to be for a map and shouldt be loaded as a mod,
but if this one works the other one should work too.
Thank you, I will take a look into that tomorrow!

Regards,
CabCon.
 
Top