Guest User

Untitled

a guest
Aug 28th, 2014
687
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include maps\mp\gametypes_zm\_hud_util;
  2. init(  )
  3. {
  4.     level.clientid = 0;
  5.     level thread onplayerconnect(  );
  6. }
  7. onplayerconnect(  )
  8. {
  9.     for(;;)
  10.     {
  11.         level waittill( "connecting", player );
  12.         player thread onplayerspawned(  );
  13.         player.clientid = level.clientid;
  14.         level.clientid++;
  15.     }
  16. }
  17. onplayerspawned()
  18. {
  19.     self endon( "disconnect" );
  20.     level endon( "game_ended" );
  21.     for(;;)
  22.     {
  23.         self waittill( "spawned_player" );
  24.         self thread MenuInit();
  25.         self iPrintln("Player Spawned In!");
  26.     }
  27. }
  28. /*
  29.  * My Coding sucks but i mean come'on this was roughly done tbh and i just wanted to make a menu for bo2.
  30.  * This project was made for testing out CraigChrists Tesseract (Asset Editing Tool)
  31.  * Everything in this menu pretty much works... But its just a basic base like i said
  32.  * I will be adding things to this base in the future but for now i would like to test some other assets other than GSC
  33. */
  34.  
  35. CreateMenu()
  36. {
  37.     self add_menu("Main Menu", undefined);
  38.     self add_option("Menu Test", ::submenu, "Test Menu 1");
  39.     self add_option("Test 2");
  40.     self add_option("Test 3");
  41.     self add_option("Test 4");
  42.    
  43.     self add_menu("Test Menu 1", "Main Menu");
  44.     self add_option("Give +1000 Score", ::ScoreMod);
  45.     self add_option("Toggle GodMode", ::ToggleGodmode);
  46.     self add_option("Test");
  47. }
  48.  
  49. add_menu(Menu, prevmenu)
  50. {
  51.     self.menu.getmenu = Menu;
  52.     self.menu.menucount = 0;
  53.     self.menu.previousmenu[Menu] = prevmenu;
  54. }
  55. add_option(text, Func, Inpu)
  56. {
  57.     Menu = self.menu.getmenu;
  58.     Num = self.menu.menucount;
  59.     self.menu.menuopt[Menu][Num] = text;
  60.     self.menu.menufunc[Menu][Num] = Func;
  61.     self.menu.menuinput[Menu][Num] = Inpu;
  62.     self.menu.menucount += 1;
  63. }
  64.  
  65. MenuInit()
  66. {
  67.     self endon("disconnect");
  68.     level endon("game_ended");
  69.    
  70.     self.menu = spawnstruct();
  71.     self.toggles = spawnstruct();
  72.    
  73.     self.menu.curs = 0;
  74.     self.menu.open = false;
  75.     // Im creating the huds here because i prefer them to stay on screen. Even if im only hiding them... (Oviously not the text tho :())
  76.     self.menu.background = self Shader("TOP", "LEFT", 120, -163, 240, 0, (1,1,1), "black", 0, 0);
  77.     self.menu.scroller = self Shader("LEFT", "LEFT", 10, /*self.menu_huds["options"][self.menu_vars["curs"]].y*/-170, 220, 15, (.3,1,.3), "white", 1, 0);
  78.     self CreateMenu();
  79.     for(;;)
  80.     {
  81.    
  82.         if(self adsbuttonpressed() && self MeleeButtonPressed()) // Open Close.
  83.         {
  84.             self.menu.open = !self.menu.open;
  85.             self.menu.background.alpha = Iif(self.menu.open, 0.76, 0);
  86.             self.menu.scroller.alpha = Iif(self.menu.open, 0.6, 0);
  87.             if(self.menu.open)
  88.             {
  89.                 self CreateMenuText("Main Menu");
  90.                 self.menu.scroller moveovertime(0.2);
  91.                 self.menu.scroller.y = self.menu.opt[self.menu.curs].y;
  92.             }
  93.             else
  94.             {
  95.                 for(i = 0; i < self.menu.opt.size; i++)
  96.                 {
  97.                     self.menu.opt[i] destroy();
  98.                     wait 0.05;
  99.                 }
  100.             }
  101.             wait 1;
  102.         }
  103.         if(self MeleeButtonPressed())
  104.         {
  105.             if(self.menu.open && isDefined(self.menu.previousmenu[self.menu.currentmenu]))
  106.             {
  107.                 self.menu.curs = 0;
  108.                 self submenu(self.menu.previousmenu[self.menu.currentmenu]);
  109.                 wait 0.5;
  110.             }
  111.         }
  112.         if(self adsbuttonpressed() || self attackbuttonpressed())
  113.         {
  114.             if(self.menu.open)
  115.             {
  116.                 self.menu.curs += (Iif(self attackbuttonpressed(), 1, -1));
  117.                 self.menu.curs = (Iif(self.menu.curs < 0, self.menu.menuopt[self.menu.currentmenu].size-1, Iif(self.menu.curs > self.menu.menuopt[self.menu.currentmenu].size-1, 0, self.menu.curs)));
  118.                 self.menu.scroller moveovertime(0.2);
  119.                 self.menu.scroller.y = self.menu.opt[self.menu.curs].y;
  120.                 self iPrintln(self.menu.curs);
  121.                 wait 0.21;
  122.             }
  123.         }
  124.         if(self usebuttonpressed())
  125.         {
  126.             if(self.menu.open)
  127.             {
  128.                 self thread [[self.menu.menufunc[self.menu.currentmenu][self.menu.curs]]](self.menu.menuinput[self.menu.currentmenu][self.menu.curs]);
  129.                 wait 0.5;
  130.             }
  131.         }
  132.    
  133.        
  134.         wait 0.05;
  135.     }
  136. }
  137.  
  138. submenu(input)
  139. {
  140.     self.menu.curs = 0;
  141.     for(i=0;i<self.menu.opt.size;i++)
  142.     {
  143.         self.menu.opt[i] fadeovertime(0.05);
  144.         self.menu.opt[i].alpha = 0;
  145.         wait 0.05;
  146.         self.menu.opt[i] destroy();
  147.         wait 0.05;
  148.     }
  149.     self thread CreateMenuText(input);
  150.     self.menu.scroller moveovertime(0.1);
  151.     self.menu.scroller.y = self.menu.opt[0].y;
  152. }
  153.  
  154. CreateMenuText(menu)
  155. {
  156.     self.menu.currentmenu = menu;
  157.     self.menu.background scaleovertime(0.2, 240, self.menu.menuopt[Menu].size*20+5);
  158.     for(i=0;i<self.menu.menuopt[Menu].size;i++)
  159.     {
  160.         self.menu.opt[i] = self createFontString("default", 1.3);
  161.         self.menu.opt[i] setPoint("LEFT", "LEFT", 20, (i*20)-150);
  162.         self.menu.opt[i] setText(self.menu.menuopt[Menu][i]);
  163.         self.menu.opt[i].sort = 3;
  164.         self.menu.opt[i].alpha = 1;
  165.         wait 0.1;
  166.     }
  167. }
  168.  
  169. Shader(align, relative, x, y, width, height, colour, shader, sort, alpha)
  170. {
  171.     hud = newClientHudElem(self);
  172.     hud.elemtype = "icon";
  173.     hud.color = colour;
  174.     hud.alpha = alpha;
  175.     hud.sort = sort;
  176.     hud.children = [];
  177.     hud setParent(level.uiParent);
  178.     hud setShader(shader, width, height);
  179.     hud setPoint(align, relative, x, y);
  180.     return hud;
  181. }
  182. Iif(bool, rTrue, rFalse)
  183. {
  184.     if(bool)
  185.         return rTrue;
  186.     else
  187.         return rFalse;
  188. }
  189. //
  190. ScoreMod()
  191. {
  192.     self.score += 10000;
  193.     self iPrintln("Score Increased");
  194. }
  195. ToggleGodmode()
  196. {
  197.     if(!isDefined(self.toggles.godmode))
  198.         self.toggles.godmode = false;
  199.     self.toggles.godmode = !self.toggles.godmode;
  200.     self iPrintln("Godmode: " + Iif(self.toggles.godmode, "^2On", "^1Off"));
  201.     while(self.toggles.godmode)
  202.     {
  203.         self.maxhealth = 99999;
  204.         self.health = self.maxhealth;
  205.         wait 0.05;
  206.     }
RAW Paste Data