Advertisement
AutismAlex

uKits UI

Dec 8th, 2019
1,097
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.30 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. function buttonClicked(player, optionNumber){
  55. optionNumberOneLess = optionNumber - 1;
  56. caller = player;
  57. c=0;
  58. foreach(page in pageData){
  59. if(c == 0){
  60. if(page[0] == caller.id){
  61. c=1;
  62. pages = page[1];
  63. targetnumber = toInt(pages * 8 + optionNumberOneLess);
  64. target = kitNamesDescription[targetnumber];
  65. if(target == "Empty"){
  66. player.message("Kit Not Found");
  67. }
  68. else{
  69. kitTarget = KitInfo[targetnumber];
  70. if(caller.hasPermission(kitTarget[1])){
  71. player.sudo("/kit " + kitTarget[4]);
  72. }
  73. else{
  74. player.message("You do not have Permissions");
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }
  81.  
  82. event onEffectButtonClicked(player, key){
  83. caller = player;
  84. if(key == "uKits_Item1"){
  85. buttonClicked(player, 1);
  86. }
  87. else if(key == "uKits_Item2"){
  88. buttonClicked(player, 2);
  89. }
  90. else if(key == "uKits_Item3"){
  91. buttonClicked(player, 3);
  92. }
  93. else if(key == "uKits_Item4"){
  94. buttonClicked(player, 4);
  95. }
  96. else if(key == "uKits_Item5"){
  97. buttonClicked(player, 5);
  98. }
  99. else if(key == "uKits_Item6"){
  100. buttonClicked(player, 6);
  101. }
  102. else if(key == "uKits_Item7"){
  103. buttonClicked(player, 7);
  104. }
  105. else if(key == "uKits_Item8"){
  106. buttonClicked(player, 8);
  107. }
  108. else if(key == "uKits_Previous"){
  109. foreach(page in pageData){
  110. if(page[0] == caller.id){
  111. pages = page[1] * 8;
  112. count = math.ceil(KitInfo.count / 8) - 1;
  113. if(page[0] == caller.id and page[1] > 0){
  114. page[1] = page[1] - 1;
  115. pages = page[1];
  116. player1 = pages * 8 + 0;
  117. player2 = pages * 8 + 1;
  118. player3 = pages * 8 + 2;
  119. player4 = pages * 8 + 3;
  120. player5 = pages * 8 + 4;
  121. player6 = pages * 8 + 5;
  122. player7 = pages * 8 + 6;
  123. player8 = pages * 8 + 7;
  124. effectManager.sendUI(3805, 3805, caller.id, kitNamesDescription[toInt(player1)], kitNamesDescription[toInt(player2)], kitNamesDescription[toInt(player3)], kitNamesDescription[toInt(player4)]);
  125. effectManager.sendUI(3806, 3806, caller.id, kitNamesDescription[toInt(player5)], kitNamesDescription[toInt(player6)], kitNamesDescription[toInt(player7)], kitNamesDescription[toInt(player8)]);
  126. return;
  127. }
  128. }
  129. }
  130. }
  131. else if(key == "uKits_Next"){
  132. foreach(page in pageData){
  133. if(page[0] == caller.id){
  134. pages = page[1] * 8;
  135. count = math.ceil(KitInfo.count / 8) - 1;
  136. if(page[0] == caller.id and page[1] < count){
  137. page[1] = toNumber(page[1]) + 1;
  138. pages = page[1];
  139. player1 = pages * 8 + 0;
  140. player2 = pages * 8 + 1;
  141. player3 = pages * 8 + 2;
  142. player4 = pages * 8 + 3;
  143. player5 = pages * 8 + 4;
  144. player6 = pages * 8 + 5;
  145. player7 = pages * 8 + 6;
  146. player8 = pages * 8 + 7;
  147. effectManager.sendUI(3805, 3805, caller.id, kitNamesDescription[toInt(player1)], kitNamesDescription[toInt(player2)], kitNamesDescription[toInt(player3)], kitNamesDescription[toInt(player4)]);
  148. effectManager.sendUI(3806, 3806, caller.id, kitNamesDescription[toInt(player5)], kitNamesDescription[toInt(player6)], kitNamesDescription[toInt(player7)], kitNamesDescription[toInt(player8)]);
  149. return;
  150. }
  151. }
  152. }
  153. }
  154. else if(key == "uKits_Close"){
  155. effectManager.clearUIbyID(3805, player.id);
  156. effectManager.clearUIbyID(3806, player.id);
  157. }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement