Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.30 KB | None | 0 0
  1. var menu = new Menu();
  2. API.onServerEventTrigger.connect(function (openHelpMenu, args) {
  3. switch (openHelpMenu) {
  4. case "openHelpMenu":
  5. menu
  6. .createMenu("Help Menu")
  7. .addMenuItem("Commands", "", true, true, "showHelpCommands", "Commands")
  8. .addMenuItem("Animations", "", true, true, "callServerTrigger", "Animations")
  9. .addMenuItem("Police", "", true, true, "callServerTrigger", "Police")
  10. .addMenuItem("Admin", "", true, true, "callServerTrigger", "Admin")
  11. .addMenuItem("Rules", "", true, true, "callServerTrigger", "Rules")
  12. .addMenuItem("FAQ", "", true, true, "callServerTrigger", "FAQ")
  13. break;
  14. }
  15. });
  16.  
  17. function showHelpCommands(group) {
  18. switch (group) {
  19. case "Commands":
  20. API.sendChatMessage('~h~Here is the list of commands availible to you:');
  21. API.sendChatMessage('/time, /stats');
  22. break;
  23. }
  24. };
  25.  
  26.  
  27.  
  28. function callServerTrigger(Helpmenu) {
  29. var args = [].slice.call(arguments).splice(1);
  30. menu.callServerFunction(openHelpMenu, args);
  31. }
  32. API.onUpdate.connect(function () {
  33. if (menu.menuPool !== null) {
  34. menu.menuPool.ProcessMenus();
  35. }
  36. });
  37.  
  38. function Menu() {
  39. this.mainMenu = null;
  40. this.menuPool = API.getMenuPool();
  41.  
  42. this.createMenu = function (title, subTitle, isResetKey, posX, posY, anchor) {
  43.  
  44. this.destroyMenu();
  45.  
  46. title = typeof title !== "undefined" ? title : "Menu";
  47. subTitle = typeof subTitle !== "undefined" ? subTitle : "";
  48. isResetKey = typeof isResetKey !== "undefined" ? isResetKey : false;
  49. anchor = typeof anchor !== "undefined" ? anchor : 6;
  50. posX = typeof posX !== "undefined" ? posX : 0;
  51. posY = typeof posY !== "undefined" ? posY : 0;
  52.  
  53. this.mainMenu = API.createMenu(title, subTitle, posX, posY, anchor);
  54. this.menuPool.Add(this.mainMenu);
  55. this.mainMenu.Visible = true;
  56.  
  57. if (isResetKey === true) {
  58. this.mainMenu.ResetKey(menuControl.Back);
  59. }
  60.  
  61. return this;
  62. };
  63.  
  64. this.addMenuItem = function (title, subTitle, isActivateInvisibleMenu, isActivated, callFunction) {
  65.  
  66. title = typeof title !== "undefined" ? title : "MenuItem";
  67. subTitle = typeof subTitle !== "undefined" ? subTitle : "";
  68. isActivateInvisibleMenu = typeof isActivateInvisibleMenu !== "undefined" ? isActivateInvisibleMenu : true;
  69. isActivated = typeof isActivated !== "undefined" ? isActivated : false;
  70. callFunction = typeof callFunction !== "undefined" ? callFunction : "";
  71.  
  72. var args = [].slice.call(arguments).splice(5);
  73. var uiMenu = this.mainMenu;
  74. var menuItem = API.createMenuItem(title, subTitle);
  75.  
  76. if (isActivated === true) {
  77. menuItem.Activated.connect(function (menu, item) {
  78.  
  79. if (isActivateInvisibleMenu === true)
  80. uiMenu.Visible = false;
  81.  
  82. eval(callFunction)(args);
  83. });
  84. }
  85.  
  86. this.mainMenu.AddItem(menuItem);
  87.  
  88. return this;
  89. };
  90.  
  91. this.addCheckBoxItem = function (title, subTitle, defaultValue, isActivateInvisibleMenu, isActivated, callFunction) {
  92.  
  93. title = typeof title !== "undefined" ? title : "CheckBoxItem";
  94. subTitle = typeof subTitle !== "undefined" ? subTitle : "";
  95. defaultValue = typeof defaultValue !== "undefined" ? defaultValue : true;
  96. isActivateInvisibleMenu = typeof isActivateInvisibleMenu !== "undefined" ? isActivateInvisibleMenu : true;
  97. isActivated = typeof isActivated !== "undefined" ? isActivated : false;
  98. callFunction = typeof callFunction !== "undefined" ? callFunction : "";
  99.  
  100. var args = [].slice.call(arguments).splice(6);
  101. var checkBoxItem = API.createCheckboxItem(title, subTitle, defaultValue);
  102. var uiMenu = this.mainMenu;
  103.  
  104. if (isActivated === true) {
  105. checkBoxItem.CheckboxEvent.connect(function (item, callBack) {
  106. if (isActivateInvisibleMenu === true)
  107. uiMenu.Visible = false;
  108.  
  109. eval(callFunction)(callBack, args);
  110. });
  111. }
  112.  
  113. this.mainMenu.AddItem(checkBoxItem);
  114.  
  115. return this;
  116. };
  117.  
  118. this.addCloseButton = function () {
  119.  
  120. var uiMenu = this.mainMenu;
  121. var destroyMenu = this.destroyMenu();
  122. var menuItem = API.createMenuItem("~r~Close", "");
  123.  
  124. menuItem.Activated.connect(function (menu, item) {
  125. uiMenu.Visible = false;
  126. destroyMenu();
  127. });
  128. this.mainMenu.AddItem(menuItem);
  129.  
  130. return true;
  131. };
  132.  
  133. this.callClientFunction = function (functionName /*, args */) {
  134. var args = [].slice.call(arguments).splice(1);
  135. eval(functionName)(args);
  136. };
  137.  
  138. this.callServerFunction = function (functionName /*, args */) {
  139. var args = [].slice.call(arguments).splice(1);
  140. API.triggerServerEvent(functionName, args);
  141. };
  142.  
  143. this.destroyMenu = function () {
  144. if (this.mainMenu !== null)
  145. this.mainMenu.Visible = false;
  146.  
  147. this.mainMenu = null;
  148. this.menuPool = null;
  149. this.menuPool = API.getMenuPool();
  150.  
  151. return true;
  152. };
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement