Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- usingUconomy = true;
- // line 381 doing purchase item code
- weaponsIDArray = array();
- clothingIDArray = array();
- buildablesIDArray = array();
- consumablesIDArray = array();
- weaponsDataArray = array();
- weaponsDataNameArray = array();
- weaponsDataIDArray = array();
- clothingDataArray = array();
- clothingDataNameArray = array();
- clothingDataIDArray = array();
- otherDataArray = array();
- otherDataNameArray = array();
- otherDataIDArray = array();
- buildablesDataArray = array();
- buildablesDataNameArray = array();
- buildablesDataIDArray = array();
- consumablesDataArray = array();
- consumablesDataNameArray = array();
- consumablesDataIDArray = array();
- pageData = array();
- event onLoad(){
- database.execute("CREATE TABLE IF NOT EXISTS uShop(
- marketID INT PRIMARY KEY,
- name VARCHAR(255) NOT NULL DEFAULT 0,
- id INT NOT NULL DEFAULT 0,
- durability INT NOT NULL DEFAULT 0,
- attachments VARCHAR(255) NOT NULL DEFAULT 0,
- type VARCHAR(25) NOT NULL DEFAULT 0,
- price INT NOT NULL DEFAULT 0,
- seller VARCHAR(17) NOT NULL DEFAULT 0
- );");
- weaponsIDArray = file.read("WeaponsIDList.txt").split(",");
- clothingIDArray = file.read("ClothingIDList.txt").split(",");
- buildablesIDArray = file.read("BuildablesIDList.txt").split(",");
- consumablesIDArray = file.read("ConsumablesIDList.txt").split(",");
- }
- function updateWeaponsData(){
- weaponsDataArray = array();
- weaponsDataNameArray = array();
- weaponsDataIDArray = array();
- checkType = "Weapon";
- marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
- foreach(val in marketData){
- weaponsDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
- weaponsDataNameArray.add(val[1]);
- weaponsDataIDArray.add(val[2]);
- }
- x=0;
- while(x != 16){
- weaponsDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
- weaponsDataNameArray.add("Empty");
- weaponsDataIDArray.add("Empty");
- x=x + 1;
- }
- }
- function updateClothingData(){
- clothingDataArray = array();
- clothingDataNameArray = array();
- clothingDataIDArray = array();
- checkType = "Clothing";
- marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
- foreach(val in marketData){
- clothingDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
- clothingDataNameArray.add(val[1]);
- clothingDataIDArray.add(val[2]);
- }
- x=0;
- while(x != 16){
- clothingDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
- clothingDataNameArray.add("Empty");
- clothingDataIDArray.add("Empty");
- x=x + 1;
- }
- }
- function updateBuildablesData(){
- buildablesDataArray = array();
- buildablesDataNameArray = array();
- buildablesDataIDArray = array();
- checkType = "Buildable";
- marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
- foreach(val in marketData){
- buildablesDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
- buildablesDataNameArray.add(val[1]);
- buildablesDataIDArray.add(val[2]);
- }
- x=0;
- while(x != 16){
- buildablesDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
- buildablesDataNameArray.add("Empty");
- buildablesDataIDArray.add("Empty");
- x=x + 1;
- }
- }
- function updateConsumablesData(){
- consumablesDataArray = array();
- consumablesDataNameArray = array();
- consumablesDataIDArray = array();
- checkType = "Consumable";
- marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
- foreach(val in marketData){
- consumablesDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
- consumablesDataNameArray.add(val[1]);
- consumablesDataIDArray.add(val[2]);
- }
- x=0;
- while(x != 16){
- consumablesDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
- consumablesDataNameArray.add("Empty");
- consumablesDataIDArray.add("Empty");
- x=x + 1;
- }
- }
- function updateOtherData(){
- otherDataArray = array();
- otherDataNameArray = array();
- otherDataIDArray = array();
- checkType = "Other";
- marketData = database.execute("SELECT * FROM uShop WHERE type = '" + checkType + "';");
- foreach(val in marketData){
- otherDataArray.add(array(val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]));
- otherDataNameArray.add(val[1]);
- otherDataIDArray.add(val[2]);
- }
- x=0;
- while(x != 16){
- otherDataArray.add(array("Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty", "Empty"));
- otherDataNameArray.add("Empty");
- otherDataIDArray.add("Empty");
- x=x + 1;
- }
- }
- function buttonClicked(player, optionNumber){
- optionNumberOneLess = optionNumber - 1;
- caller = player;
- foreach(page in pageData){
- if(page[0] == caller.name){
- pages = page[1];
- pageType = page[2];
- if(pageType == "Weapons"){
- target = weaponsDataIDArray[toInt(pages * 16 + optionNumberOneLess)];
- if(target == "Empty"){
- player.message("Item Not Found");
- }
- else{
- foreach(page in pageData){
- if(page[0] == player.name){
- page[1] = 0;
- }
- }
- effectManager.clearUIbyID(4561, player.id);
- effectManager.clearUIbyID(4562, player.id);
- effectManager.clearUIbyID(4563, player.id);
- effectManager.clearUIbyID(4564, player.id);
- checkIDLoop = 1;
- foreach(val in weaponsDataArray){
- if(checkIDLoop == 1){
- if(toNumber(val[2]) == toNumber(target)){
- itemName = toString(val[1]);
- itemPrice = toNumber(val[6]);
- if(usingUconomy){
- playerBalance = player.balance;
- }
- else{
- playerBalance = player.experience;
- }
- itemDescription = "Durability: " + toString(val[3]) + "%
- Attachments:
- " + toString(val[4]);
- effectManager.sendUI(4560, 4560, player.id, "Back", "Purchase");
- page[3] = 1;
- page[4] = toNumber(val[0]);
- 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>");
- checkIDLoop = 0;
- }
- }
- }
- }
- }
- }
- }
- }
- command uShop(option, id, price){
- permission = "uShop";
- execute(){
- if(isSet(option)){
- if(option == "sell"){
- if(isSet(id) and isSet(price)){
- if(player.inventory.hasItem(id)){
- currentIDCount = 1;
- checkItemLoop = 1;
- DBcheck = database.execute("SELECT * FROM uShop;");
- foreach(val in DBcheck){
- if(toNumber(val[0]) >= currentIDCount){
- currentIDCount = toNumber(val[0]) + 1;
- }
- }
- inventoryArray = player.inventory.items;
- foreach(val in inventoryArray){
- if(val.id == id){
- if(checkItemLoop == 1){
- itemName = val.name;
- itemID = id;
- itemDurability = 100;
- itemAttachments = "None";
- itemType = 0;
- foreach(idtocheck in weaponsIDArray){
- if(toNumber(id) == toNumber(idtocheck)){
- itemType = "Weapon";
- }
- }
- foreach(idtocheck in clothingIDArray){
- if(toNumber(id) == toNumber(idtocheck)){
- itemType = "Clothing";
- }
- }
- foreach(idtocheck in buildablesIDArray){
- if(toNumber(id) == toNumber(idtocheck)){
- itemType = "Buildable";
- }
- }
- foreach(idtocheck in consumablesIDArray){
- if(toNumber(id) == toNumber(idtocheck)){
- itemType = "Consumable";
- }
- }
- if(itemType == 0){
- itemType = "Other";
- }
- itemPrice = toNumber(price);
- sellerID = player.id;
- marketID = currentIDCount;
- player.inventory.removeItem(id, 1);
- database.execute("INSERT INTO uShop (marketID, name, id, durability, attachments, type, price, seller) VALUES ('" + marketID + "', '" + itemName + "', '" + itemID + "', '" + itemDurability + "', '" + itemAttachments + "', '" + itemType + "', '" + itemPrice + "', '" + sellerID + "');");
- checkItemLoop = 0;
- }
- }
- }
- }
- else{
- player.message("You dont have the item specified");
- }
- }
- else{
- player.message("Correct usage: /uMarket sell ITEMID PRICE");
- }
- }
- else if(option == "open"){
- caller = player;
- if(player.hasPermission("uShop")){
- check = 0;
- foreach(page in pageData){
- if(page[0] == caller.name){
- check = 1;
- break;
- }
- }
- if(check == 0){
- pageData.add(array(caller.name));
- }
- foreach(page in pageData){
- if(page[0] == caller.name){
- page.add(0);
- page.add("Weapons");
- page.add(0);
- page.add("None");
- updateWeaponsData();
- effectManager.clearUIbyID(4565, player.id);
- effectManager.sendUI(4560, 4560, player.id, "<--", "-->");
- effectManager.sendUI(4561, 4561, player.id, weaponsDataNameArray[0], weaponsDataNameArray[1], weaponsDataNameArray[2], weaponsDataNameArray[3]);
- effectManager.sendUI(4562, 4562, player.id, weaponsDataNameArray[4], weaponsDataNameArray[5], weaponsDataNameArray[6], weaponsDataNameArray[7]);
- effectManager.sendUI(4563, 4563, player.id, weaponsDataNameArray[8], weaponsDataNameArray[9], weaponsDataNameArray[10], weaponsDataNameArray[11]);
- effectManager.sendUI(4564, 4564, player.id, weaponsDataNameArray[12], weaponsDataNameArray[13], weaponsDataNameArray[14], weaponsDataNameArray[15]);
- }
- }
- }
- }
- }
- }
- }
- event onEffectButtonClicked(player, key){
- caller = player;
- if(key == "uShop_Item1"){
- buttonClicked(player, 1);
- }
- else if(key == "uShop_Item2"){
- buttonClicked(player, 2);
- }
- else if(key == "uShop_Item3"){
- buttonClicked(player, 3);
- }
- else if(key == "uShop_Item4"){
- buttonClicked(player, 4);
- }
- else if(key == "uShop_Item5"){
- buttonClicked(player, 5);
- }
- else if(key == "uShop_Item6"){
- buttonClicked(player, 6);
- }
- else if(key == "uShop_Item7"){
- buttonClicked(player, 7);
- }
- else if(key == "uShop_Item8"){
- buttonClicked(player, 8);
- }
- else if(key == "uShop_Item9"){
- buttonClicked(player, 9);
- }
- else if(key == "uShop_Item10"){
- buttonClicked(player, 10);
- }
- else if(key == "uShop_Item11"){
- buttonClicked(player, 11);
- }
- else if(key == "uShop_Item12"){
- buttonClicked(player, 12);
- }
- else if(key == "uShop_Item13"){
- buttonClicked(player, 13);
- }
- else if(key == "uShop_Item14"){
- buttonClicked(player, 14);
- }
- else if(key == "uShop_Item15"){
- buttonClicked(player, 15);
- }
- else if(key == "uShop_Item16"){
- buttonClicked(player, 16);
- }
- else if(key == "uShop_Next_Purchase"){
- foreach(page in pageData){
- if(page[0] == caller.name and page[3] == 0){
- pages = page[1] * 16 + 7;
- pageType = page[2];
- if(pageType == "Weapons"){
- count = math.ceil(weaponsDataArray.count / 16) - 1;
- if(page[0] == caller.name and weaponsDataNameArray[toInt(pages)] == "Empty"){
- return;
- }
- else if(page[0] == caller.name and page[1] < count){
- page[1] = page[1] + 1;
- pages = page[1];
- updateWeaponsData();
- player1 = pages * 16 + 0;
- player2 = pages * 16 + 1;
- player3 = pages * 16 + 2;
- player4 = pages * 16 + 3;
- player5 = pages * 16 + 4;
- player6 = pages * 16 + 5;
- player7 = pages * 16 + 6;
- player8 = pages * 16 + 7;
- player9 = pages * 16 + 8;
- player10 = pages * 16 + 9;
- player11 = pages * 16 + 10;
- player12 = pages * 16 + 11;
- player13 = pages * 16 + 12;
- player14 = pages * 16 + 13;
- player15 = pages * 16 + 14;
- player16 = pages * 16 + 15;
- effectManager.sendUI(4561, 4561, caller.id, weaponsDataNameArray[toInt(player1)], weaponsDataNameArray[toInt(player2)], weaponsDataNameArray[toInt(player3)], weaponsDataNameArray[toInt(player4)]);
- effectManager.sendUI(4562, 4562, caller.id, weaponsDataNameArray[toInt(player5)], weaponsDataNameArray[toInt(player6)], weaponsDataNameArray[toInt(player7)], weaponsDataNameArray[toInt(player8)]);
- effectManager.sendUI(4563, 4563, caller.id, weaponsDataNameArray[toInt(player9)], weaponsDataNameArray[toInt(player10)], weaponsDataNameArray[toInt(player11)], weaponsDataNameArray[toInt(player12)]);
- effectManager.sendUI(4564, 4564, caller.id, weaponsDataNameArray[toInt(player13)], weaponsDataNameArray[toInt(player14)], weaponsDataNameArray[toInt(player15)], weaponsDataNameArray[toInt(player16)]);
- return;
- }
- }
- }
- else if(page[0] == caller.name and page[3] == 1){
- DBcheck = database.execute("SELECT * FROM uShop WHERE marketID = '" + page[4] + "';");
- DBcheck=DBcheck[0];
- if(usingUconomy){
- if(player.balance >= toNumber(DBcheck[6])){
- }
- else{
- player.message("Not Enough Funds!");
- }
- }
- else{
- if(player.experience >= toNumber(DBcheck[6])){
- }
- else{
- player.message("Not Enough Funds!");
- }
- }
- }
- }
- }
- else if(key == "uShop_Close"){
- foreach(page in pageData){
- if(page[0] == player.name){
- page[1] = 0;
- break;
- }
- }
- effectManager.clearUIbyID(4560, player.id);
- effectManager.clearUIbyID(4561, player.id);
- effectManager.clearUIbyID(4562, player.id);
- effectManager.clearUIbyID(4563, player.id);
- effectManager.clearUIbyID(4564, player.id);
- effectManager.clearUIbyID(4565, player.id);
- }
- }
- command debug(){
- foreach(page in pageData){
- player.message(page[0] + " " + page[1] + " " + page[2]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement