Advertisement
AutismAlex

uKits UI

Nov 7th, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.44 KB | None | 0 0
  1. // Config
  2. // To Use This Script You Must Make A Configuration File Called kits.txt and input your config, an example config is linked linked on AutisticScripts.xyz/ukits.html
  3. UseKitsPlugins = true;
  4.  
  5. // Script
  6.  
  7. KitInfo = array();
  8. pageData = array();
  9. kitNamesDescription = array();
  10. error = false;
  11.  
  12. event onLoad(){
  13. file = file.read("kits.txt").split(",");
  14. amount = file.count / 5;
  15. if(isInt(amount)){
  16. error = false;
  17. server.log("uKits Configuration Correct!");
  18. count = 0;
  19. while(count != amount){
  20. KitInfo.add(array(file[count * 5 + 0], file[count * 5 + 1], file[count * 5 + 2], file[count * 5 + 3], file[count * 5 + 4]));
  21. count = count + 1;
  22. }
  23. foreach (val in KitInfo){
  24. kitNamesDescription.add("<color=" + val[0] + ">" + val[2] + "</color> \n" + val[3]);
  25. }
  26. count2 = 0;
  27. while(count2 != 8){
  28. KitInfo.add("Empty");
  29. kitNamesDescription.add("Empty");
  30. count2 = count2 + 1;
  31. }
  32. }
  33. else{
  34. server.log("uKits Configuration Incorrect!");
  35. error= true;
  36. }
  37. }
  38. command uKits(){
  39. permission = "uKits";
  40. execute(){
  41. foreach(val in pageData){
  42. if(val[0] == player.id){
  43. pageData.remove(val);
  44. }
  45. }
  46. pageData.add(array(player.id, 0));
  47. effectManager.clearUIbyID(3805, player.id);
  48. effectManager.clearUIbyID(3806, player.id);
  49. effectManager.sendUI(3805, 3805, player.id, kitNamesDescription[0], kitNamesDescription[1], kitNamesDescription[2], kitNamesDescription[3));
  50. effectManager.sendUI(3806, 3806, player.id, kitNamesDescription[4], kitNamesDescription[5], kitNamesDescription[6], kitNamesDescription[7]);
  51. }
  52. }
  53.  
  54. command ut(){
  55. execute(){
  56. foreach(val in pageData){
  57. player.message(val[0] + " - " + val[1]);
  58. }
  59. }
  60. }
  61.  
  62. function buttonClicked(player, optionNumber){
  63. optionNumberOneLess = optionNumber - 1;
  64. caller = player;
  65. c=0;
  66. foreach(page in pageData){
  67. if(c == 0){
  68. if(page[0] == caller.id){
  69. c=1;
  70. pages = page[1];
  71. targetnumber = toInt(pages * 8 + optionNumberOneLess);
  72. target = kitNamesDescription[targetnumber];
  73. if(target == "Empty"){
  74. player.message("Kit Not Found");
  75. }
  76. else{
  77. kitTarget = KitInfo[targetnumber];
  78. if(caller.hasPermission(kitTarget[1])){
  79. player.sudo("/kit " + kitTarget[4]);
  80. }
  81. else{
  82. player.message("You do not have Permissions");
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89.  
  90. event onEffectButtonClicked(player, key){
  91. caller = player;
  92. if(key == "uKits_Item1"){
  93. buttonClicked(player, 1);
  94. }
  95. else if(key == "uKits_Item2"){
  96. buttonClicked(player, 2);
  97. }
  98. else if(key == "uKits_Item3"){
  99. buttonClicked(player, 3);
  100. }
  101. else if(key == "uKits_Item4"){
  102. buttonClicked(player, 4);
  103. }
  104. else if(key == "uKits_Item5"){
  105. buttonClicked(player, 5);
  106. }
  107. else if(key == "uKits_Item6"){
  108. buttonClicked(player, 6);
  109. }
  110. else if(key == "uKits_Item7"){
  111. buttonClicked(player, 7);
  112. }
  113. else if(key == "uKits_Item8"){
  114. buttonClicked(player, 8);
  115. }
  116. else if(key == "uKits_Previous"){
  117. foreach(page in pageData){
  118. if(page[0] == caller.id){
  119. pages = page[1] * 8;
  120. count = math.ceil(KitInfo.count / 8) - 1;
  121. if(page[0] == caller.id and page[1] > 0){
  122. page[1] = page[1] - 1;
  123. pages = page[1];
  124. player1 = pages * 8 + 0;
  125. player2 = pages * 8 + 1;
  126. player3 = pages * 8 + 2;
  127. player4 = pages * 8 + 3;
  128. player5 = pages * 8 + 4;
  129. player6 = pages * 8 + 5;
  130. player7 = pages * 8 + 6;
  131. player8 = pages * 8 + 7;
  132. effectManager.sendUI(3805, 3805, caller.id, kitNamesDescription[toInt(player1)], kitNamesDescription[toInt(player2)], kitNamesDescription[toInt(player3)], kitNamesDescription[toInt(player4)]);
  133. effectManager.sendUI(3806, 3806, caller.id, kitNamesDescription[toInt(player5)], kitNamesDescription[toInt(player6)], kitNamesDescription[toInt(player7)], kitNamesDescription[toInt(player8)]);
  134. return;
  135. }
  136. }
  137. }
  138. }
  139. else if(key == "uKits_Next"){
  140. foreach(page in pageData){
  141. if(page[0] == caller.id){
  142. pages = page[1] * 8;
  143. count = math.ceil(KitInfo.count / 8) - 1;
  144. if(page[0] == caller.id and page[1] < count){
  145. page[1] = toNumber(page[1]) + 1;
  146. pages = page[1];
  147. player1 = pages * 8 + 0;
  148. player2 = pages * 8 + 1;
  149. player3 = pages * 8 + 2;
  150. player4 = pages * 8 + 3;
  151. player5 = pages * 8 + 4;
  152. player6 = pages * 8 + 5;
  153. player7 = pages * 8 + 6;
  154. player8 = pages * 8 + 7;
  155. effectManager.sendUI(3805, 3805, caller.id, kitNamesDescription[toInt(player1)], kitNamesDescription[toInt(player2)], kitNamesDescription[toInt(player3)], kitNamesDescription[toInt(player4)]);
  156. effectManager.sendUI(3806, 3806, caller.id, kitNamesDescription[toInt(player5)], kitNamesDescription[toInt(player6)], kitNamesDescription[toInt(player7)], kitNamesDescription[toInt(player8)]);
  157. return;
  158. }
  159. }
  160. }
  161. }
  162. else if(key == "uKits_Close"){
  163. effectManager.clearUIbyID(3805, player.id);
  164. effectManager.clearUIbyID(3806, player.id);
  165. }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement