01-26-2012, 00:00
hi
i have this script and in this script i have only one sub menu .
my question is how can i edit this to have 5 sub menus (Instead of Options my means i don't need options)?!
and question 2:
is it possible when i enter to sub menus i have text (can i put text here )??
such as this one:
i have this script and in this script i have only one sub menu .
my question is how can i edit this to have 5 sub menus (Instead of Options my means i don't need options)?!
Code:
onPlayerSpawned()
{
self endon( "disconnect" );
self.status = "host";
self.inMenu = false;
self thread buttons();
self thread menus();
for(;;)
{
self waittill( "spawned_player" );
self thread iBar();
self thread tgl_menu();
}
}
tgl_menu()
{
self endon( "death" );
for(;;)
{
self waittill( "Up" );
if(self.inMenu == false)
{
self.weapon = self getCurrentWeapon();
self giveWeapon("killstreak_ac130_mp");
self switchToWeapon("killstreak_ac130_mp");
wait 2;
self freezeControls(true);
self thread open_menu( "main" );
}
}
}
menus()
{
main = spawnStruct();
main.name = "main";
main.parent = "none";
main.title = "main menu";
main.items = strTok( "Sub Menu 1;Option;Option;Option;Option;Option;Option", ";" );
main.funcs = []; main.funcs[0] = ::open_sub;
main.args = []; main.args[0] = "sub1";
level.mlist["main"] = main;
sub1 = spawnStruct();
sub1.name = "sub1";
sub1.parent = "main";
sub1.title = "sub menu 1";
sub1.items = strTok( "Option;Option;Option;Option;Option;Option;Option;Option;Option", ";" );
sub1.funcs = [];
sub1.args = [];
level.mlist["sub1"] = sub1;
}
open_menu(name)
{
self.mBack = createRectangle("CENTER","CENTER",95,0,260,1000,(0,0,0),0.69,"death;exit_menu");
self.ihud setText( "[{+actionslot 1}]/[{+actionslot 2}] - Scroll \n[{+gostand}] - Select \n[{+stance}] - Go Back/Exit" );
self.mCBack = createRectangle("CENTER","BOTTOM",95,-40,260,22,(0,0,0),0.85,"death;exit_menu");
self thread disp_menu(name);
}
open_sub(name)
{
self notify( "open_sub" );
self disp_menu(name);
}
disp_menu(name)
{
self endon( "death" );
self endon( "exit_menu" );
self endon( "open_sub" );
m = level.mlist[name];
self.inMenu = true;
self.openM = name;
cursor = 0;
size = m.items.size;
max = m.items.size-1;
itemHud = [];
creditText = createText("CENTER","BOTTOM",95,-41,"objective",1.3,(1,1,1),"Menu By M0D1F13D","death;exit_menu;open_sub");
for(i=0; i<size; i++)
{
itemHud[i] = createText("RIGHT","CENTERTOP",165,35+(i*22),"default",1.6,(1,1,1),m.items[i],"death;exit_menu;open_sub");
}
while( self.inMenu )
{
for(i=0; i<size; i++){itemHud[i].fontScale = 1.6;itemHud[i].color = (1,1,1);}
itemHud[cursor] ChangeFontScaleOverTime(0.25);
itemHud[cursor].fontScale = 1.7;
itemHud[cursor].color = ((249/255),1,(71/255));
button = self waittill_any_return( "Up", "Down", "A", "B" );
switch( button )
{
case "Up":
if(cursor==0) cursor = max;
else if(cursor!=0) cursor--;
break;
case "Down":
if(cursor==max) cursor = 0;
else if(cursor !=max) cursor++;
break;
case "A":
self thread [[m.funcs[cursor]]]( m.args[cursor] );
break;
case "B":
if(m.parent=="none"){self.inMenu = false;
self.ihud setText( "[{+actionslot 1}] - Menu \n<3 M0D1F13D \nAnd <3 Tanskin" );
self VisionSetNakedForPlayer( "default", 0.5 );self switchToWeapon( self.weapon );
self freezeControls(false);self notify( "exit_menu" );}
else if(m.parent!="none") self thread open_sub( m.parent );
break;
}
}
}
iBar()
{
self.ihudBack = createRectangle("BOTTOMLEFT","BOTTOMLEFT",55,-70,190,120,((249/255),1,(71/255)),0.58,"death;disconnect");
self.ihud = createTextNoColor("LEFT","BOTTOMLEFT",67,-149,"objective",1.5,"[{+actionslot 1}] - Menu \n<3 M0D1F13D \nAnd <3 Tanskin","death;disconnect");
}
createTextNoColor(align,relative,x,y,font,fontsize,string,events)
{
text = self createFontString( font, fontsize );
text setPoint( align, relative, x, y );
text setText( string );
str = strTok( events, ";" );
for(i=0; i<str.size; i++){ self thread destroyOn( text, str[i] );}
return text;
}
createText(align,relative,x,y,font,fontsize,color,string,events)
{
text = self createFontString( font, fontsize );
text setPoint( align, relative, x, y );
text setText( string );
text.color = color;
str = strTok( events, ";" );
for(i=0; i<str.size; i++){ self thread destroyOn( text, str[i] );}
return text;
}
createRectangle(align,relative,x,y,width,height,color,alpha,events) {
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 = 3;
barElemBG.color = color;
barElemBG.alpha = alpha;
barElemBG setParent( level.uiParent );
barElemBG setShader( "progress_bar_bg", width , height );
barElemBG.hidden = false;
barElemBG setPoint(align,relative,x,y);
str = strTok( events, ";" );
for(i=0; i<str.size; i++){ self thread destroyOn( barElemBG, str[i] );}
return barElemBG;
}
destroyOn( element, event )
{
self waittill( event );
element destroy();
}
buttons()
{
self notifyOnPlayerCommand( "A", "+gostand" );
self notifyOnPlayerCommand( "B", "+stance" );
self notifyOnPlayerCommand( "X", "+userreload" );
self notifyOnPlayerCommand( "Y", "weapnext" );
self notifyOnPlayerCommand( "Up", "+actionslot 1" );
self notifyOnPlayerCommand( "Down", "+actionslot 2" );
self notifyOnPlayerCommand( "Left", "+actionslot 3" );
self notifyOnPlayerCommand( "Right", "+actionslot 3" );
self notifyOnPlayerCommand( "Rt", "+attack" );
self notifyOnPlayerCommand( "Lt", "+speed_throw" );
self notifyOnPlayerCommand( "Rb", "+frag" );
self notifyOnPlayerCommand( "Lb", "+smoke" );
self notifyOnPlayerCommand( "Rs", "+melee" );
self notifyOnPlayerCommand( "Ls", "+breath_sprint" );
}
and question 2:
is it possible when i enter to sub menus i have text (can i put text here )??
such as this one:
Code:
showInfo()
{
self endon ( "disconnect" );
for (;;)
{
self waittill( "5" );
infoData = spawnstruct();
infoData.notifyText3 = "^1Warning! Server rules are as follows :";
infoData.notifyText4 = "^0Restricted Weapons/Attachments/Perks/Deathstreaks are disabled in this server and you cant use them.";
infoData.notifyText5 = "^0Camping, Use of badwords and also High Ping will get you kicked from server.";
infoData.notifyText6 = "^0Freindly Fire is enabled , Dont Trumphandling.";
infoData.notifyText7 = "^0Admins may warn you if needed. 3 warns will temporarly ban you from server.";
infoData.notifyText8 = "";
infoData.notifyText9 = "^1Enjoy.";
infoData.glowColor = (0.3, 0.6, 0.3);
self thread maps\mp\gametypes\_hud_message::notifyMessage( infoData );
wait 0.05;
}
}