Advertisement
Guest User

e

a guest
Oct 17th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.57 KB | None | 0 0
  1. usingUconomy = true;
  2.  
  3. // line 381 doing purchase item code
  4.  
  5. weaponsIDArray = array();
  6. clothingIDArray = array();
  7. buildablesIDArray = array();
  8. consumablesIDArray = array();
  9. weaponsDataArray = array();
  10. weaponsDataNameArray = array();
  11. weaponsDataIDArray = array();
  12. clothingDataArray = array();
  13. clothingDataNameArray = array();
  14. clothingDataIDArray = array();
  15. otherDataArray = array();
  16. otherDataNameArray = array();
  17. otherDataIDArray = array();
  18. buildablesDataArray = array();
  19. buildablesDataNameArray = array();
  20. buildablesDataIDArray = array();
  21. consumablesDataArray = array();
  22. consumablesDataNameArray = array();
  23. consumablesDataIDArray = array();
  24. pageData = array();
  25.  
  26. event onLoad(){
  27. database.execute("CREATE TABLE IF NOT EXISTS uShop(
  28. marketID INT PRIMARY KEY,
  29. name VARCHAR(255) NOT NULL DEFAULT 0,
  30. id INT NOT NULL DEFAULT 0,
  31. durability INT NOT NULL DEFAULT 0,
  32. attachments VARCHAR(255) NOT NULL DEFAULT 0,
  33. type VARCHAR(25) NOT NULL DEFAULT 0,
  34. price INT NOT NULL DEFAULT 0,
  35. seller VARCHAR(17) NOT NULL DEFAULT 0
  36. );");
  37. weaponsIDArray = file.read("WeaponsIDList.txt").split(",");
  38. clothingIDArray = file.read("ClothingIDList.txt").split(",");
  39. buildablesIDArray = file.read("BuildablesIDList.txt").split(",");
  40. consumablesIDArray = file.read("ConsumablesIDList.txt").split(",");
  41. }
  42.  
  43. function updateWeaponsData(){
  44. weaponsDataArray = array();
  45. weaponsDataNameArray = array();
  46. weaponsDataIDArray = array();
  47. checkType = "Weapon";
  48. marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
  49. foreach(val in marketData){
  50. weaponsDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
  51. weaponsDataNameArray.add(val[1]);
  52. weaponsDataIDArray.add(val[2]);
  53. }
  54. x=0;
  55. while(x != 16){
  56. weaponsDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
  57. weaponsDataNameArray.add("Empty");
  58. weaponsDataIDArray.add("Empty");
  59. x=x + 1;
  60. }
  61. }
  62. function updateClothingData(){
  63. clothingDataArray = array();
  64. clothingDataNameArray = array();
  65. clothingDataIDArray = array();
  66. checkType = "Clothing";
  67. marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
  68. foreach(val in marketData){
  69. clothingDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
  70. clothingDataNameArray.add(val[1]);
  71. clothingDataIDArray.add(val[2]);
  72. }
  73. x=0;
  74. while(x != 16){
  75. clothingDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
  76. clothingDataNameArray.add("Empty");
  77. clothingDataIDArray.add("Empty");
  78. x=x + 1;
  79. }
  80. }
  81. function updateBuildablesData(){
  82. buildablesDataArray = array();
  83. buildablesDataNameArray = array();
  84. buildablesDataIDArray = array();
  85. checkType = "Buildable";
  86. marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
  87. foreach(val in marketData){
  88. buildablesDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
  89. buildablesDataNameArray.add(val[1]);
  90. buildablesDataIDArray.add(val[2]);
  91. }
  92. x=0;
  93. while(x != 16){
  94. buildablesDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
  95. buildablesDataNameArray.add("Empty");
  96. buildablesDataIDArray.add("Empty");
  97. x=x + 1;
  98. }
  99. }
  100. function updateConsumablesData(){
  101. consumablesDataArray = array();
  102. consumablesDataNameArray = array();
  103. consumablesDataIDArray = array();
  104. checkType = "Consumable";
  105. marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
  106. foreach(val in marketData){
  107. consumablesDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
  108. consumablesDataNameArray.add(val[1]);
  109. consumablesDataIDArray.add(val[2]);
  110. }
  111. x=0;
  112. while(x != 16){
  113. consumablesDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
  114. consumablesDataNameArray.add("Empty");
  115. consumablesDataIDArray.add("Empty");
  116. x=x + 1;
  117. }
  118. }
  119. function updateOtherData(){
  120. otherDataArray = array();
  121. otherDataNameArray = array();
  122. otherDataIDArray = array();
  123. checkType = "Other";
  124. marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
  125. foreach(val in marketData){
  126. otherDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
  127. otherDataNameArray.add(val[1]);
  128. otherDataIDArray.add(val[2]);
  129. }
  130. x=0;
  131. while(x != 16){
  132. otherDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
  133. otherDataNameArray.add("Empty");
  134. otherDataIDArray.add("Empty");
  135. x=x + 1;
  136. }
  137. }
  138.  
  139. function buttonClicked(player, optionNumber){
  140. optionNumberOneLess = optionNumber - 1;
  141. caller = player;
  142. foreach(page in pageData){
  143. if(page[0] == caller.name){
  144. pages = page[1];
  145. pageType = page[2];
  146. if(pageType == "Weapons"){
  147. target = weaponsDataIDArray[toInt(pages * 16 + optionNumberOneLess)];
  148. if(target == "Empty"){
  149. player.message("Item Not Found");
  150. }
  151. else{
  152. foreach(page in pageData){
  153. if(page[0] == player.name){
  154. page[1] = 0;
  155. }
  156. }
  157. effectManager.clearUIbyID(4561, player.id);
  158. effectManager.clearUIbyID(4562, player.id);
  159. effectManager.clearUIbyID(4563, player.id);
  160. effectManager.clearUIbyID(4564, player.id);
  161. checkIDLoop = 1;
  162. foreach(val in weaponsDataArray){
  163. if(checkIDLoop == 1){
  164. if(toNumber(val[2]) == toNumber(target)){
  165. itemName = toString(val[1]);
  166. itemPrice = toNumber(val[6]);
  167. if(usingUconomy){
  168. playerBalance = player.balance;
  169. }
  170. else{
  171. playerBalance = player.experience;
  172. }
  173. itemDescription = "Durability: " + toString(val[3]) + "%
  174. Attachments:
  175. " + toString(val[4]);
  176. effectManager.sendUI(4560, 4560, player.id, "Back", "Purchase");
  177. page[3] = 1;
  178. page[4] = toNumber(val[0]);
  179. effectManager.sendUI(4565, 4565, player.id, "<color=cyan> Item: " + itemName + "</color>", "<color=cyan> Price: " + itemPrice + "</color>", "<color=cyan> Your balance: " + playerBalance + "</color>", "<color=cyan> " + itemDescription + "</color>");
  180. checkIDLoop = 0;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189.  
  190. command uShop(option, id, price){
  191. permission = "uShop";
  192. execute(){
  193. if(isSet(option)){
  194. if(option == "sell"){
  195. if(isSet(id) and isSet(price)){
  196. if(player.inventory.hasItem(id)){
  197. currentIDCount = 1;
  198. checkItemLoop = 1;
  199. DBcheck = database.execute("SELECT * FROM uShop;");
  200. foreach(val in DBcheck){
  201. if(toNumber(val[0]) >= currentIDCount){
  202. currentIDCount = toNumber(val[0]) + 1;
  203. }
  204. }
  205. inventoryArray = player.inventory.items;
  206. foreach(val in inventoryArray){
  207. if(val.id == id){
  208. if(checkItemLoop == 1){
  209. itemName = val.name;
  210. itemID = id;
  211. itemDurability = 100;
  212. itemAttachments = "None";
  213. itemType = 0;
  214. foreach(idtocheck in weaponsIDArray){
  215. if(toNumber(id) == toNumber(idtocheck)){
  216. itemType = "Weapon";
  217. }
  218. }
  219. foreach(idtocheck in clothingIDArray){
  220. if(toNumber(id) == toNumber(idtocheck)){
  221. itemType = "Clothing";
  222. }
  223. }
  224. foreach(idtocheck in buildablesIDArray){
  225. if(toNumber(id) == toNumber(idtocheck)){
  226. itemType = "Buildable";
  227. }
  228. }
  229. foreach(idtocheck in consumablesIDArray){
  230. if(toNumber(id) == toNumber(idtocheck)){
  231. itemType = "Consumable";
  232. }
  233. }
  234. if(itemType == 0){
  235. itemType = "Other";
  236. }
  237. itemPrice = toNumber(price);
  238. sellerID = player.id;
  239. marketID = currentIDCount;
  240. player.inventory.removeItem(id, 1);
  241. database.execute("INSERT INTO uShop (marketID, name, id, durability, attachments, type, price, seller) VALUES ('" + marketID + "', '" + itemName + "', '" + itemID + "', '" + itemDurability + "', '" + itemAttachments + "', '" + itemType + "', '" + itemPrice + "', '" + sellerID + "');");
  242. checkItemLoop = 0;
  243. }
  244. }
  245. }
  246.  
  247. }
  248. else{
  249. player.message("You dont have the item specified");
  250. }
  251. }
  252. else{
  253. player.message("Correct usage: /uMarket sell ITEMID PRICE");
  254. }
  255. }
  256. else if(option == "open"){
  257. caller = player;
  258. if(player.hasPermission("uShop")){
  259. check = 0;
  260. foreach(page in pageData){
  261. if(page[0] == caller.name){
  262. check = 1;
  263. break;
  264. }
  265. }
  266. if(check == 0){
  267. pageData.add(array(caller.name));
  268. }
  269. foreach(page in pageData){
  270. if(page[0] == caller.name){
  271. page.add(0);
  272. page.add("Weapons");
  273. page.add(0);
  274. page.add("None");
  275. updateWeaponsData();
  276. effectManager.clearUIbyID(4565, player.id);
  277. effectManager.sendUI(4560, 4560, player.id, "<--", "-->");
  278. effectManager.sendUI(4561, 4561, player.id, weaponsDataNameArray[0], weaponsDataNameArray[1], weaponsDataNameArray[2], weaponsDataNameArray[3]);
  279. effectManager.sendUI(4562, 4562, player.id, weaponsDataNameArray[4], weaponsDataNameArray[5], weaponsDataNameArray[6], weaponsDataNameArray[7]);
  280. effectManager.sendUI(4563, 4563, player.id, weaponsDataNameArray[8], weaponsDataNameArray[9], weaponsDataNameArray[10], weaponsDataNameArray[11]);
  281. effectManager.sendUI(4564, 4564, player.id, weaponsDataNameArray[12], weaponsDataNameArray[13], weaponsDataNameArray[14], weaponsDataNameArray[15]);
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289.  
  290.  
  291. event onEffectButtonClicked(player, key){
  292. caller = player;
  293. if(key == "uShop_Item1"){
  294. buttonClicked(player, 1);
  295. }
  296. else if(key == "uShop_Item2"){
  297. buttonClicked(player, 2);
  298. }
  299. else if(key == "uShop_Item3"){
  300. buttonClicked(player, 3);
  301. }
  302. else if(key == "uShop_Item4"){
  303. buttonClicked(player, 4);
  304. }
  305. else if(key == "uShop_Item5"){
  306. buttonClicked(player, 5);
  307. }
  308. else if(key == "uShop_Item6"){
  309. buttonClicked(player, 6);
  310. }
  311. else if(key == "uShop_Item7"){
  312. buttonClicked(player, 7);
  313. }
  314. else if(key == "uShop_Item8"){
  315. buttonClicked(player, 8);
  316. }
  317. else if(key == "uShop_Item9"){
  318. buttonClicked(player, 9);
  319. }
  320. else if(key == "uShop_Item10"){
  321. buttonClicked(player, 10);
  322. }
  323. else if(key == "uShop_Item11"){
  324. buttonClicked(player, 11);
  325. }
  326. else if(key == "uShop_Item12"){
  327. buttonClicked(player, 12);
  328. }
  329. else if(key == "uShop_Item13"){
  330. buttonClicked(player, 13);
  331. }
  332. else if(key == "uShop_Item14"){
  333. buttonClicked(player, 14);
  334. }
  335. else if(key == "uShop_Item15"){
  336. buttonClicked(player, 15);
  337. }
  338. else if(key == "uShop_Item16"){
  339. buttonClicked(player, 16);
  340. }
  341. else if(key == "uShop_Next_Purchase"){
  342. foreach(page in pageData){
  343. if(page[0] == caller.name and page[3] == 0){
  344. pages = page[1] * 16 + 7;
  345. pageType = page[2];
  346. if(pageType == "Weapons"){
  347. count = math.ceil(weaponsDataArray.count / 16) - 1;
  348. if(page[0] == caller.name and weaponsDataNameArray[toInt(pages)] == "Empty"){
  349. return;
  350. }
  351. else if(page[0] == caller.name and page[1] < count){
  352. page[1] = page[1] + 1;
  353. pages = page[1];
  354. updateWeaponsData();
  355. player1 = pages * 16 + 0;
  356. player2 = pages * 16 + 1;
  357. player3 = pages * 16 + 2;
  358. player4 = pages * 16 + 3;
  359. player5 = pages * 16 + 4;
  360. player6 = pages * 16 + 5;
  361. player7 = pages * 16 + 6;
  362. player8 = pages * 16 + 7;
  363. player9 = pages * 16 + 8;
  364. player10 = pages * 16 + 9;
  365. player11 = pages * 16 + 10;
  366. player12 = pages * 16 + 11;
  367. player13 = pages * 16 + 12;
  368. player14 = pages * 16 + 13;
  369. player15 = pages * 16 + 14;
  370. player16 = pages * 16 + 15;
  371. effectManager.sendUI(4561, 4561, caller.id, weaponsDataNameArray[toInt(player1)], weaponsDataNameArray[toInt(player2)], weaponsDataNameArray[toInt(player3)], weaponsDataNameArray[toInt(player4)]);
  372. effectManager.sendUI(4562, 4562, caller.id, weaponsDataNameArray[toInt(player5)], weaponsDataNameArray[toInt(player6)], weaponsDataNameArray[toInt(player7)], weaponsDataNameArray[toInt(player8)]);
  373. effectManager.sendUI(4563, 4563, caller.id, weaponsDataNameArray[toInt(player9)], weaponsDataNameArray[toInt(player10)], weaponsDataNameArray[toInt(player11)], weaponsDataNameArray[toInt(player12)]);
  374. effectManager.sendUI(4564, 4564, caller.id, weaponsDataNameArray[toInt(player13)], weaponsDataNameArray[toInt(player14)], weaponsDataNameArray[toInt(player15)], weaponsDataNameArray[toInt(player16)]);
  375. return;
  376. }
  377. }
  378. }
  379. else if(page[0] == caller.name and page[3] == 1){
  380. DBcheck = database.execute("SELECT * FROM uShop WHERE marketID = '" + page[4] + "';");
  381. DBcheck=DBcheck[0];
  382. if(usingUconomy){
  383. if(player.balance >= toNumber(DBcheck[6])){
  384.  
  385. }
  386. else{
  387. player.message("Not Enough Funds!");
  388. }
  389. }
  390. else{
  391. if(player.experience >= toNumber(DBcheck[6])){
  392.  
  393. }
  394. else{
  395. player.message("Not Enough Funds!");
  396. }
  397. }
  398. }
  399. }
  400. }
  401. else if(key == "uShop_Close"){
  402. foreach(page in pageData){
  403. if(page[0] == player.name){
  404. page[1] = 0;
  405. break;
  406. }
  407. }
  408. effectManager.clearUIbyID(4560, player.id);
  409. effectManager.clearUIbyID(4561, player.id);
  410. effectManager.clearUIbyID(4562, player.id);
  411. effectManager.clearUIbyID(4563, player.id);
  412. effectManager.clearUIbyID(4564, player.id);
  413. effectManager.clearUIbyID(4565, player.id);
  414. }
  415. }
  416. command debug(){
  417. foreach(page in pageData){
  418. player.message(page[0] + " " + page[1] + " " + page[2]);
  419. }
  420. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement