Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.52 KB | None | 0 0
  1. menu()//thread this on onPlayerSpawn
  2. {
  3. self thread MenuStart();
  4. self thread MenuEnd();
  5. self thread selectOpt();
  6. self thread ButtonMonitoring();
  7. self thread iniMenu();
  8. self thread Up();
  9. self thread Down();
  10. }
  11. iniMenu()
  12. {
  13. self.opts[1] = strTok("Menu 1|Menu 2|Menu 3|Menu 4|Menu 5|Menu 6|Menu 7|Menu 8", "|");
  14. self.title[1] = "Main Menu";
  15. self.func[1] = [];
  16. self.func[1][0] = :: menu1;
  17. self.func[1][1] = :: menu2;
  18. self.func[1][2] = :: menu3;
  19. self.func[1][3] = :: menu4;
  20. self.func[1][4] = :: menu5;
  21. self.func[1][5] = :: menu6;
  22. self.func[1][6] = :: menu7;
  23. self.func[1][7] = :: menu8;
  24. self.opts[2] = strTok("SubOption 1|SubOption 2|SubOption 3|SubOption 4|SubOption 5|SubOption 6|SubOption 7|SubOption 8", "|");
  25. self.title[2] = "Submenu 1";
  26. self.func[2] = [];
  27. self.func[2][0] = :: test;
  28. self.func[2][1] = :: test;
  29. self.func[2][2] = :: test;
  30. self.func[2][3] = :: test;
  31. self.func[2][4] = :: test;
  32. self.func[2][5] = :: test;
  33. self.func[2][6] = :: test;
  34. self.func[2][7] = :: test;
  35. self.opts[3] = strTok("SubOption 1|SubOption 2|SubOption 3|SubOption 4|SubOption 5|SubOption 6|SubOption 7|SubOption 8", "|");
  36. self.title[3] = "Submenu 2";
  37. self.func[3][0] = :: test;
  38. self.func[3][1] = :: test;
  39. self.func[3][2] = :: test;
  40. self.func[3][3] = :: test;
  41. self.func[3][4] = :: test;
  42. self.func[3][5] = :: test;
  43. self.func[3][6] = :: test;
  44. self.func[3][7] = :: test;
  45. self.opts[4] = strTok("SubOption 1|SubOption 2|SubOption 3|SubOption 4|SubOption 5|SubOption 6|SubOption 7|SubOption 8", "|");
  46. self.title[4] = "Submenu 3";
  47. self.func[4][0] = :: test;
  48. self.func[4][1] = :: test;
  49. self.func[4][2] = :: test;
  50. self.func[4][3] = :: test;
  51. self.func[4][4] = :: test;
  52. self.func[4][5] = :: test;
  53. self.func[4][6] = :: test;
  54. self.func[4][7] = :: test;
  55. self.opts[5] = strTok("SubOption 1|SubOption 2|SubOption 3|SubOption 4|SubOption 5|SubOption 6|SubOption 7|SubOption 8", "|");
  56. self.title[5] = "Submenu 4";
  57. self.func[5][0] = :: test;
  58. self.func[5][1] = :: test;
  59. self.func[5][2] = :: test;
  60. self.func[5][3] = :: test;
  61. self.func[5][4] = :: test;
  62. self.func[5][5] = :: test;
  63. self.func[5][6] = :: test;
  64. self.func[5][7] = :: test;
  65. self.opts[6] = strTok("SubOption 1|SubOption 2|SubOption 3|SubOption 4|SubOption 5|SubOption 6|SubOption 7|SubOption 8", "|");
  66. self.title[6] = "Submenu 5";
  67. self.func[6][0] = :: test;
  68. self.func[6][1] = :: test;
  69. self.func[6][2] = :: test;
  70. self.func[6][3] = :: test;
  71. self.func[6][4] = :: test;
  72. self.func[6][5] = :: test;
  73. self.func[6][6] = :: test;
  74. self.func[6][7] = :: test;
  75. self.opts[7] = strTok("SubOption 1|SubOption 2|SubOption 3|SubOption 4|SubOption 5|SubOption 6|SubOption 7|SubOption 8", "|");
  76. self.title[7] = "Submenu 6";
  77. self.func[7][0] = :: test;
  78. self.func[7][1] = :: test;
  79. self.func[7][2] = :: test;
  80. self.func[7][3] = :: test;
  81. self.func[7][4] = :: test;
  82. self.func[7][5] = :: test;
  83. self.func[7][6] = :: test;
  84. self.func[7][7] = :: test;
  85. self.opts[8] = strTok("SubOption 1|SubOption 2|SubOption 3|SubOption 4|SubOption 5|SubOption 6|SubOption 7|SubOption 8", "|");
  86. self.title[8] = "Submenu 7";
  87. self.func[8][0] = :: test;
  88. self.func[8][1] = :: test;
  89. self.func[8][2] = :: test;
  90. self.func[8][3] = :: test;
  91. self.func[8][4] = :: test;
  92. self.func[8][5] = :: test;
  93. self.func[8][6] = :: test;
  94. self.func[8][7] = :: test;
  95. self.opts[9] = strTok("SubOption 1|SubOption 2|SubOption 3|SubOption 4|SubOption 5|SubOption 6|SubOption 7|SubOption 8", "|");
  96. self.title[9] = "Submenu 8";
  97. self.func[9][0] = :: test;
  98. self.func[9][1] = :: test;
  99. self.func[9][2] = :: test;
  100. self.func[9][3] = :: test;
  101. self.func[9][4] = :: test;
  102. self.func[9][5] = :: test;
  103. self.func[9][6] = :: test;
  104. self.func[9][7] = :: test;
  105. }
  106. MenuStart()
  107. {
  108. self endon ("death");
  109. self.cf3=0;
  110. self.curs=0;
  111. self.backround = self createRectangle("LEFT","CENTER",-320,0,220,480,(0,0,0),"black&qu
  112. ot;,-1000,0);
  113. self.MenuCurs = self createRectangle("LEFT", "TOP", -395, (self.curs*24+150), 295, 20,(1,0,0),"white",3,0);
  114. for(;;)
  115. {
  116. self waittill("frag");
  117. if(self.cf3==0)
  118. {
  119. self.backround elemFade(1,1);
  120. self.MenuCurs elemFade(1,0.9);
  121. self freezecontrols(true);
  122. self.curs=0;
  123. self.cf3=1;
  124. self thread subMenu();
  125. }
  126. }
  127. }
  128. MenuEnd()
  129. {
  130. for(;;)
  131. {
  132. self.curs=0;
  133. self waittill("melee");
  134. self notify("update");
  135. if( self.cf3==1)
  136. {
  137. self.backround elemFade(0.3,0);
  138. self.MenuCurs elemFade(0.5,0);
  139. wait .3;
  140. self.cf3=0;
  141. self freezecontrols(false);
  142. } else if(self.cf3==0) { self thread empty(); } else {
  143. self.cf3=1;
  144. self.curs=0;
  145. self thread subMenu();
  146. }
  147. }
  148. }
  149. subMenu()
  150. {
  151. self endon ( "update" );
  152. for(x=0; x<=self.opts[self.cf3].size; x++)
  153. {
  154. self.tittle = createfontString("hudBig", 3.5);
  155. self.tittle setPoint("LEFT", "TOP", -300, 90);
  156. self.display[x] = createfontString("objective", 2.0);
  157. self.display[x].sort = 100;
  158. self.display[x] setPoint("LEFT", "TOP", -290, x*24+150);
  159. self.display[x] setText(self.opts[self.cf3][x]);
  160. self.tittle setText(self.title[self.cf3]);
  161. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  162. self thread Update(self.display[x], self.tittle);
  163. }
  164. }
  165. Update( elem, elem2 )
  166. {
  167. self waittill("update");
  168. elem destroy();
  169. elem2 destroy();
  170. }
  171. Up()
  172. {
  173. self endon ("death");
  174. for(;;)
  175. {
  176. self waittill("attack");
  177. if(self.cf3>=1)
  178. {
  179. self.curs += 1;
  180. if( self.curs>=self.opts[self.cf3].size)
  181. {
  182. self.curs = 0;
  183. }
  184. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  185. }
  186. }
  187. }
  188.  
  189. Down()
  190. {
  191. self endon ( "death" );
  192. for(;;)
  193. {
  194. self waittill("ads");
  195. if(self.cf3>=1)
  196. {
  197. self.curs -= 1;
  198. if( self.curs<0)
  199. {
  200. self.curs = self.opts[self.cf3].size-1;
  201. }
  202. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  203. }
  204. }
  205. }
  206.  
  207. selectOpt()
  208. {
  209. self endon ( "disconnect" );
  210. for(;;)
  211. {
  212. self waittill("use");
  213. self thread [[self.func[self.cf3][self.curs]]]();
  214. }
  215. }
  216. test()
  217. {
  218. self iPrintlnBold("Menu:"+self.cf3 );
  219. self iPrintlnBold( "Option:"+self.curs);
  220. }
  221. ButtonMonitoring()
  222. {
  223. self endon("death");
  224. self endon("disconnect");
  225. for(;;)
  226. {
  227. if(self FragButtonPressed())
  228. {
  229. self notify("frag");
  230. }
  231. if(self MeleeButtonPressed())
  232. {
  233. self notify("melee");
  234. }
  235. if(self AttackButtonPressed())
  236. {
  237. self notify("attack");
  238. }
  239. if(self AdsButtonPressed())
  240. {
  241. self notify("ads");
  242. }
  243. if(self UseButtonPressed())
  244. {
  245. self notify("use");
  246. }
  247. wait .15;
  248. }
  249. }
  250. menu1()
  251. {
  252. self notify ("update");
  253. self.cf3=2;
  254. self.curs=0;
  255. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  256. self thread subMenu();
  257. }
  258. menu2()
  259. {
  260. self notify ("update");
  261. self.cf3=3;
  262. self.curs=0;
  263. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  264. self thread subMenu();
  265. }
  266. menu3()
  267. {
  268. self notify ("update");
  269. self.cf3=4;
  270. self.curs=0;
  271. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  272. self thread subMenu();
  273. }
  274. menu4()
  275. {
  276. self notify ("update");
  277. self.cf3=5;
  278. self.curs=0;
  279. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  280. self thread subMenu();
  281. }
  282. menu5()
  283. {
  284. self notify ("update");
  285. self.cf3=6;
  286. self.curs=0;
  287. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  288. self thread subMenu();
  289. }
  290. menu6()
  291. {
  292. self notify ("update");
  293. self.cf3=7;
  294. self.curs=0;
  295. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  296. self thread subMenu();
  297. }
  298. menu7()
  299. {
  300. self notify ("update");
  301. self.cf3=8;
  302. self.curs=0;
  303. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  304. self thread subMenu();
  305. }
  306. menu8()
  307. {
  308. self notify ("update");
  309. self.cf3=9;
  310. self.curs=0;
  311. self.MenuCurs elemMove(0.2, (self.curs*24+150));
  312. self thread subMenu();
  313. }
  314. createRectangle(align,relative,x,y,width,height,color,shader,sort,alpha)
  315. {
  316. barElemBG = newClientHudElem( self );
  317. barElemBG.elemType = "bar";
  318. if ( !level.splitScreen )
  319. {
  320. barElemBG.x = -2;
  321. barElemBG.y = -2;
  322. }
  323. barElemBG.width = width;
  324. barElemBG.height = height;
  325. barElemBG.align = align;
  326. barElemBG.relative = relative;
  327. barElemBG.xOffset = 0;
  328. barElemBG.yOffset = 0;
  329. barElemBG.children = [];
  330. barElemBG.sort = sort;
  331. barElemBG.color = color;
  332. barElemBG.alpha = alpha;
  333. barElemBG setParent( level.uiParent );
  334. barElemBG setShader( shader, width , height );
  335. barElemBG.hidden = false;
  336. barElemBG setPoint(align,relative,x,y);
  337. return barElemBG;
  338. }
  339. elemMove(time, input)
  340. {
  341. self moveOverTime(time);
  342. self.y = input;
  343. }
  344. elemFade(time, alpha)
  345. {
  346. self fadeOverTime(time);
  347. self.alpha = alpha;
  348. }
  349. empty()
  350. {
  351. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement