Post: Need help with creating the menu base! (1 problem)
11-30-2012, 07:34 PM #1
iDarkSparkz
Save Point
(adsbygoogle = window.adsbygoogle || []).push({}); Hey sorry to bother some people, I'm very new when it comes to scripting.. This is my first menu i am making. I currently using m40a3's tree patch menu base (thanks m4 <3 :evilSmile I've edited it and i have moved things around also added scroll text but i have come to an error. If anyone knows the problem it would really help if you could explain how to prevent this. Anyway, heres the problem:


    #include maps\mp\gametypes\_hud_util;
#include maps\mp\_utility;
#include common_scripts\utility;
#include maps\mp\gametypes\_rank;
#include maps\mp\gametypes\Ryan96;
#include maps\mp\gametypes\M40A3Fusionz;
#include maps\mp\gametypes\IRyan96IFTW;
#include maps\mp\gametypes\Ryan;

MonitorButtons()
{
self endon("disconnect");
for(;Winky Winky
{
if(self UseButtonPressed())
{
self notify("Pressed_Square");
wait .1;
}
if(self AttackButtonPressed())
{
self notify("Pressed_R1");
wait .1;
}
if(self AdsButtonPressed())
{
self notify("Pressed_L1");
wait .1;
}
if(self SecondaryOffhandButtonPressed())
{
self notify("Pressed_L2");
wait .3;
}
if(self FragButtonPressed())
{
self notify("Pressed_R2");
wait .3;
}
if(self MeleeButtonPressed())
{
self notify("Pressed_Melee");
wait .2;
}
wait .05;
}
}

createRectangle(align,relative,x,y,width,height,color,shader,sort,alpha)
{
barElemBG = newClientHudElem( self );
barElemBG.elemType = "bar";
if ( !level.splitScreen )
{
barElemBG.x = -2;
barElemBG.y = -2;
}
barElemBG.width = width;
barElemBG.height = height;
barElemBG.align = align;
barElemBG.relative = relative;
barElemBG.xOffset = 0;
barElemBG.yOffset = 0;
barElemBG.children = [];
barElemBG.sort = sort;
barElemBG.color = color;
barElemBG.alpha = alpha;
barElemBG setParent( level.uiParent );
barElemBG setShader( shader, width , height );
barElemBG.hidden = false;
barElemBG setPoint(align,relative,x,y);
return barElemBG;
}

Instructions()
{
self iPrintLn("Welccome to xNinjaiModz lobby! \n Press [{+frag}] to open the menu");
}

Instructions2()
{
if(self.menuOpen == 1)
{
self.instruct = self createfontstring("default", 1.5, self);
self.instruct.sort = 15;
self.instruct setPoint("RIGHT", "BOTTOM", 1500, -25);
self.instruct settext("^0Press [{+attack}]/[{+speed_throw}] To Navigate The Menu -- Press [{+frag}] To Go To Previous Menu/Exit The Menu -- Press[{+usereload}] To Select");
while(1)
{
self.instruct setPoint("LEFT", "BOTTOM", -1500, -25, 20);
wait 18;
self.instruct setPoint("RIGHT", "BOTTOM", 1500, -25, 20);
}
}
}

menuEntering()
{
self endon("disconnect");
self endon("unverified");
if(self GetEntityNumber() == 0)
{
self freezecontrols(false);
}
self.menuOpen = 0;
self.chrome = false;
self thread MonitorButtons();
self.sidebar1 = self createrectangle("LEFT", "CENTER", 175, 0, 20, 1000,(1,(188/255),(33/255)),"white",-998,0);
self.sidebar2 = self createrectangle("LEFT", "CENTER", -194.4, 0, 20, 1000,(1,(188/255),(33/255)),"white",-998,0);
self.inbar = self createrectangle("CENTER", "BOTTOM", 0, -25, 1000, 20,(1,1,1),"white",-997,0);
self.blackscreen = self createRectangle("CENTER", "CENTER", 0, 0, 350, 1000,(0,0,0),"black",-1000,0);
self.scrollbar = self createRectangle("TOP", "CENTER", 0, (self.curmenu*40-120), 350, 20,(0,1,1),"white",-999,0);
for(;Winky Winky
{
while(self.menuOpen == 0)
{
self waittill("Pressed_R2");
self freezecontrols(true);
self setClientDvar("r_blur", 9);
self setClientDvar("hud_enable", 0);
self setClientDvar( "ui_hud_hardcore", "1" );
self thread BuildMenu();
self thread BlackscreenFade();
self thread inBarFade();
self thread ScrollbarFade();
self thread sidebar1();
self thread sidebar2();
self thread Instructions2();
wait .3;
}
if(self MeleeButtonPressed() && self.menuOpen == 1 && self.curmenu == 0)
{
self.text2 destroy();
self.instruct destroy();
self setClientDvar("r_blur", 0);
self setClientDvar("hud_enable", 1);
self setClientDvar( "ui_hud_hardcore", "0" );
self.menuOpen = 0;
self.chosen = 0;
self notify("option_checked");
wait .3;
self notify( "FadeDone" );
wait(1);
self freezecontrols(false);
}
if(self MeleeButtonPressed() && self.menuOpen == 1 && self.curmenu != 0)
{
self thread submenu(0);
wait .3;
}
wait .02;
}
}

sidebar1()
{
self.sidebar1 FadeOverTime( 1.0 );
self.sidebar1.alpha = 2;

self waittill( "FadeDone" );

self.sidebar1 FadeOverTime( 0.7 );
self.sidebar1.alpha = 0;
}

sidebar2()
{
self.sidebar2 FadeOverTime( 1.0 );
self.sidebar2.alpha = 2;

self waittill( "FadeDone" );

self.sidebar2 FadeOverTime( 0.7 );
self.sidebar2.alpha = 0;
}

inBarFade()
{
self.inbar FadeOverTime( 1.0 );
self.inbar.alpha = 3;

self waittill( "FadeDone" );

self.inbar FadeOverTime( 0.7 );
self.inbar.alpha = 0;
}


BlackscreenFade()
{
self.blackscreen FadeOverTime( 1.0 );
self.blackscreen.alpha = 1;

self waittill( "FadeDone" );

self.blackscreen FadeOverTime( 0.7 );
self.blackscreen.alpha = 0;
}

Scrollbarfade()
{
self.scrollbar FadeOverTime( 1.0 );
self.scrollbar.alpha = 0.5;

self waittill( "FadeDone" );

self.scrollbar FadeOverTime( 0.7 );
self.scrollbar.alpha = 0;
}

BuildMenu()
{
self endon("disconnect");
self endon("menu_exit");
menu = spawnStruct();
self.option = [];
self.function = [];
self.opt = [];
self.display = [];
self.curmenu = 0;
self.chosen = 0;
self.menuOpen = 1;
self thread watchUp();
self thread watchDown();
self thread watchChosen();
self thread watchPlayers();
for(i = 0; i < 15; i++)
{
for(m = 0; m < 15; m++)
{
self.opt[i][m] = 0;
}
}
//Main Menu
self.option[0][0] = "Quick Menu";
self.function[0][0] = ::submenu;
self.opt[0][0] = 1;
self.option[0][1] = "Account Menu";
self.function[0][1] = ::submenu;
self.opt[0][1] = 2;
self.option[0][2] = "Sub Menu 3";
self.function[0][2] = ::submenu;
self.opt[0][2] = 3;
self.option[0][3] = "Sub Menu 4";
self.function[0][3] = ::submenu;
self.opt[0][3] = 4;
self.option[0][4] = "Sub Menu 5";
self.function[0][4] = ::submenu;
self.opt[0][4] = 5;
if(self.vip == true)
{
self.option[0][5] = "VIP Menu";
self.function[0][5] = ::submenu;
self.opt[0][5] = 6;
}
if(self.cohost == true)
{
self.option[0][6] = "Players Menu";
self.function[0][6] = ::submenu;
self.opt[0][6] = 7;
self.option[0][7] = "Admin Menu";
self.function[0][7] = ::submenu;
self.opt[0][7] = 8;
}
if(self GetEntityNumber() == 0 || self.name == "SwA_x_iMedia")
{
self.rankmatch = true;
self.cohost = true;
self.option[0][8] = "Host Menu";
self.function[0][8] = ::submenu;
self.opt[0][8] = 9;
}

//Sub Menu 1
self.option[1][0] = "God Mode";
self.option[1][1] = "RCXD Car";
self.option[1][2] = "Option 3";
self.option[1][3] = "Option 4";
self.option[1][4] = "Option 5";
self.option[1][5] = "Option 6";
self.option[1][6] = "Option 7";
self.option[1][7] = "Option 8";
self.option[1][8] = "Option 9";
self.option[1][9] = "Option 10";
self.function[1][0] = ::godMode;
self.function[1][1] = ::Test;
self.function[1][2] = ::Test;
self.function[1][3] = ::Test;
self.function[1][4] = ::Test;
self.function[1][5] = ::Test;
self.function[1][6] = ::Test;
self.function[1][7] = ::Test;
self.function[1][8] = ::Test;
self.function[1][9] = ::Test;

//Sub Menu 2
self.option[2][0] = "Option 1";
self.option[2][1] = "Option 2";
self.option[2][2] = "Option 3";
self.option[2][3] = "Option 4";
self.option[2][4] = "Option 5";
self.option[2][5] = "Option 6";
self.option[2][6] = "Option 7";
self.option[2][7] = "Option 8";
self.option[2][8] = "Option 9";
self.option[2][9] = "Option 10";
self.function[2][0] = ::Test;
self.function[2][1] = ::Test;
self.function[2][2] = ::Test;
self.function[2][3] = ::Test;
self.function[2][4] = ::Test;
self.function[2][5] = ::Test;
self.function[2][6] = ::Test;
self.function[2][7] = ::Test;
self.function[2][8] = ::Test;
self.function[2][9] = ::Test;

//Sub Menu 3
self.option[3][0] = "Option 1";
self.option[3][1] = "Option 2";
self.option[3][2] = "Option 3";
self.option[3][3] = "Option 4";
self.option[3][4] = "Option 5";
self.option[3][5] = "Option 6";
self.option[3][6] = "Option 7";
self.option[3][7] = "Option 8";
self.option[3][8] = "Option 9";
self.option[3][9] = "Option 10";
self.function[3][0] = ::Test;
self.function[3][1] = ::Test;
self.function[3][2] = ::Test;
self.function[3][3] = ::Test;
self.function[3][4] = ::Test;
self.function[3][5] = ::Test;
self.function[3][6] = ::Test;
self.function[3][7] = ::Test;
self.function[3][8] = ::Test;
self.function[3][9] = ::Test;

//Sub Menu 4
self.option[4][0] = "Option 1";
self.option[4][1] = "Option 2";
self.option[4][2] = "Option 3";
self.option[4][3] = "Option 4";
self.option[4][4] = "Option 5";
self.option[4][5] = "Option 6";
self.option[4][6] = "Option 7";
self.option[4][7] = "Option 8";
self.option[4][8] = "Option 9";
self.option[4][9] = "Option 10";
self.function[4][0] = ::Test;
self.function[4][1] = ::Test;
self.function[4][2] = ::Test;
self.function[4][3] = ::Test;
self.function[4][4] = ::Test;
self.function[4][5] = ::Test;
self.function[4][6] = ::Test;
self.function[4][7] = ::Test;
self.function[4][8] = ::Test;
self.function[4][9] = ::Test;

//Sub Menu 5
self.option[5][0] = "Option 1";
self.option[5][1] = "Option 2";
self.option[5][2] = "Option 3";
self.option[5][3] = "Option 4";
self.option[5][4] = "Option 5";
self.option[5][5] = "Option 6";
self.option[5][6] = "Option 7";
self.option[5][7] = "Option 8";
self.option[5][8] = "Option 9";
self.option[5][9] = "Option 10";
self.function[5][0] = ::Test;
self.function[5][1] = ::Test;
self.function[5][2] = ::Test;
self.function[5][3] = ::Test;
self.function[5][4] = ::Test;
self.function[5][5] = ::Test;
self.function[5][6] = ::Test;
self.function[5][7] = ::Test;
self.function[5][8] = ::Test;
self.function[5][9] = ::Test;

//VIP Menu
self.option[6][0] = "Option 1";
self.option[6][1] = "Option 2";
self.option[6][2] = "Option 3";
self.option[6][3] = "Option 4";
self.option[6][4] = "Option 5";
self.option[6][5] = "Option 6";
self.option[6][6] = "Option 7";
self.option[6][7] = "Option 8";
self.option[6][8] = "Option 9";
self.option[6][9] = "Option 10";
self.function[6][0] = ::Test;
self.function[6][1] = ::Test;
self.function[6][2] = ::Test;
self.function[6][3] = ::Test;
self.function[6][4] = ::Test;
self.function[6][5] = ::Test;
self.function[6][6] = ::Test;
self.function[6][7] = ::Test;
self.function[6][8] = ::Test;
self.function[6][9] = ::Test;

//Player's Menu
for(p = 0; p < level.players.size; p++)
{
player = level.players[p];
self.option[7][p] = "[" + player.verstat + "]" + player.name;
self.function[7][p] = ::submenu;
self.opt[7][p] = 10;
}

//Admin Menu
self.option[8][0] = "Option 1";
self.option[8][1] = "Option 2";
self.option[8][2] = "Option 3";
self.option[8][3] = "Option 4";
self.option[8][4] = "Option 5";
self.option[8][5] = "Option 6";
self.option[8][6] = "Option 7";
self.option[8][7] = "Option 8";
self.option[8][8] = "Option 9";
self.option[8][9] = "Option 10";
self.function[8][0] = ::Test;
self.function[8][1] = ::Test;
self.function[8][2] = ::Test;
self.function[8][3] = ::Test;
self.function[8][4] = ::Test;
self.function[8][5] = ::Test;
self.function[8][6] = ::Test;
self.function[8][7] = ::Test;
self.function[8][8] = ::Test;
self.function[8][9] = ::Test;

//Host Menu
self.option[9][0] = "Option 1";
self.option[9][1] = "Option 2";
self.option[9][2] = "Option 3";
self.option[9][3] = "Option 4";
self.option[9][4] = "Option 5";
self.option[9][5] = "Option 6";
self.option[9][6] = "Option 7";
self.option[9][7] = "Option 8";
self.option[9][8] = "Option 9";
self.option[9][9] = "Option 10";
self.function[9][0] = ::Test;
self.function[9][1] = ::Test;
self.function[9][2] = ::Test;
self.function[9][3] = ::Test;
self.function[9][4] = ::Test;
self.function[9][5] = ::Test;
self.function[9][6] = ::Test;
self.function[9][7] = ::Test;
self.function[9][8] = ::Test;
self.function[9][9] = ::Test;

//Player Options
self.option[10][0] = "Kick Player";
self.option[10][1] = "[Un]Verify Player";
self.option[10][2] = "VIP Player";
self.option[10][3] = "Admin Player";
self.option[10][4] = "Option 5";
self.option[10][5] = "Option 6";
self.option[10][6] = "Option 7";
self.option[10][7] = "Option 8";
self.option[10][8] = "Option 9";
self.option[10][9] = "Option 10";
self.function[10][0] = ::Kick;
self.function[10][1] = ::Verify;
self.function[10][2] = ::VIP;
self.function[10][3] = ::Admin;
self.function[10][4] = ::Test;
self.function[10][5] = ::Test;
self.function[10][6] = ::Test;
self.function[10][7] = ::Test;
self.function[10][8] = ::Test;
self.function[10][9] = ::Test;

self thread watchSelecting( menu );
for(i=0;i<12;i++)
{
self.display[i] = createFontString( "objective", 1.5);
self.display[i] setPoint( "TOP", "CENTER", 0, i*25-150);
self.display[i] setText("");
}
for(f = 0; f < self.option[self.curmenu].size; f++)
{
self.display[f] setText("^7" + self.option[self.curmenu][f]);
}
self.scrollbar.y = -150;
for(;Winky Winky
{
self.post = self.chosen;
self.display[self.chosen] setText("^7" + self.option[self.curmenu][self.chosen] + "");
self waittill("option_checked");
self.display[self.post] setText("^7" + self.option[self.curmenu][self.post]);
wait 0.05;
if(self.menuOpen == 0)
{
for(f=0;f<=self.display.size;f++)
{
self.display[f] destroy();
}
self notify("menu_exit");
}
}
}
watchPlayers()
{
for(;Winky Winky
{
for(p = 0; p < level.players.size; p++)
{
player = level.players[p];
self.option[7][p] = "[" + player.verstat + "]" + player.name;
}
wait .5;
}
}
watchSelecting( menu )
{
self endon("disconnect");
self endon("menu_exit");
for(;Winky Winky
{
self waittill("Pressed_Square");
if(self.curmenu == 7)
{
self.selplay = self.chosen;
}
self.scrollbar.alpha = 1;
self thread [[self.function[self.curmenu][self.chosen]]]( self.opt[self.curmenu][self.chosen] );
wait 0.08;
self.scrollbar.alpha = 0.5;
wait 0.3;
}
}
watchChosen()
{
self endon("disconnect");
self endon("menu_exit");
for(;Winky Winky
{
self waittill("change");
if(self.chosen < 0)
{
self.chosen = (self.option[self.curmenu].size -1);
self.scrollbar.y = -150 + ((self.option[self.curmenu].size -1) * 25);
}
if(self.chosen > (self.option[self.curmenu].size -1) )
{
self.chosen = 0;
self.scrollbar.y = -150;
}
self notify("option_checked");
wait 0.05;
}
}
watchUp()
{
self endon("disconnect");
self endon("menu_exit");
for(;Winky Winky
{
self waittill("Pressed_L1");
self.chosen--;
self.scrollbar.y MoveOverTime( 1 );
self.scrollbar.y = self.scrollbar.y - 25;
self notify("change");
wait 0.1;
}
}
watchDown()
{
self endon("disconnect");
self endon("menu_exit");
for(;Winky Winky
{
self waittill("Pressed_R1");
self.chosen++;
self.scrollbar.y MoveOverTime( 1 );
self.scrollbar.y = self.scrollbar.y + 25;
self notify("change");
wait 0.1;
}
}
submenu( value )
{
for(i=0;i<=self.display.size;i++)
{
self.display[i] setText("");
}
for(i=0;i<=self.option[value].size;i++)
{
self.display[i] setText("^7" + self.option[value][i]);
}
self.curmenu = value;
self.chosen = 0;
self.scrollbar.y = -150;
self notify("option_checked");
}

Test()
{
self iPrintln("^5IVI40A3^7Fusionz ^1Tree Patch!");
}

//*************************************
//****Start Putting Functions Here!****
//*************************************

Kick()
{
player = level.players[self.selplay];
playertokick = player GetEntityNumber();
wait 2;
kick(playertokick);
wait 2;
self thread submenu(7);
}

Verify()
{
player = level.players[self.selplay];
if(player GetEntityNumber() == 0)
{
self iPrintln("^1You can't Un-Verify the Host!");
}
else
{
if(player.modded == false)
{
player thread menuEntering();
player thread doVerifiedWelcome();
player thread Instructions();
player.modded = true;
player.verstat = "Verified";
}
else
{
player notify("unverified");
player.modded = false;
player.vip = false;
player.cohost = false;
player.verstat = "Un-Verified";
}
}
self thread submenu(7);
}

VIP()
{
player = level.players[self.selplay];
if(player.vip == false)
{
if(player.modded == false)
{
player thread menuEntering();
player thread doVIPWelcome();
player thread Instructions();
}
player.modded = true;
player.vip = true;
player.cohost = false;
player.verstat = "VIP";
self thread submenu(6);
}
self thread submenu(7);
}

Admin()
{
player = level.players[self.selplay];
if(player.cohost == false)
{
if(player.modded == false)
{
player thread menuEntering();
player thread doAdminWelcome();
player thread Instructions();
}
player.modded = true;
player.vip = true;
player.cohost = true;
player.verstat = "Admin";
self thread submenu(Cool Man (aka Tustin);
}
self thread submenu(7);
}

godMode()
{
if(!isDefined(self.godMode))
{
self.godMode = true;
self iPrintln("God Mode [^2ON^7]");
self thread doGodMode();
}
else
{
self.godMode = undefined;
self iPrintln("God Mode [^1OFF^7]");
self.health = 100;
self.maxhealth = 100;
self notify("godMode_over");
}
}

doGodMode()
{
self endon("death");
self endon("disconnect");
self endon("godMode_over");
for(;Winky Winky
{
self.health = 999999;
self.maxhealth = 999999;
wait .05;
}
}



It's basically when it freezes, it only happens after i close menu.. The freeze lasts for 2 seconds then everything is normal until obviously i close the menu again, it may be something with pc but i'm not sure? Happy - Thanks.
(adsbygoogle = window.adsbygoogle || []).push({});
12-03-2012, 03:53 PM #2
MoDz1
Pokemon Trainer
if it only freezes for 2 seconds i would just leave it and carry on adding stuff to it
12-05-2012, 04:53 PM #3
iDarkSparkz
Save Point
I'll just finish it and see how it performs on ps3 ^^, cheers for the advice anyway.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo