Permalink
Browse files

1.1.0.0 release, reworked commands to not require i, added events, ad…

…ded sell command
  • Loading branch information...
1 parent fa13d94 commit ed4e300c91e6431f8053c0ae96e7abcf25c58aeb @Zamirathe Zamirathe committed Apr 20, 2015
@@ -1,9 +1,5 @@
using System;
using Rocket.RocketAPI;
-using SDG;
-using UnityEngine;
-using unturned.ROCKS.Uconomy;
-using Steamworks;
namespace UconomyBasicShop
{
@@ -33,144 +29,7 @@ public string Help
public void Execute(RocketPlayer playerid, string msg)
{
- string message;
- if (string.IsNullOrEmpty(msg))
- {
- message = "Usage: /buy <v or i>.<name or id>/<amount> (optional).";
- // We are going to print how to use
- RocketChatManager.Say(playerid, message);
- return;
- }
- byte amttobuy = 1;
- string[] components0 = Parser.getComponentsFromSerial(msg, '/');
- if (components0.Length > 1)
- {
- amttobuy = byte.Parse(components0[1]);
- }
- string[] components = Parser.getComponentsFromSerial(components0[0], '.');
- if (components.Length < 2)
- {
- message = "Usage: /buy <v or i>.<name or id>/<amount> (optional).";
- // We are going to print how to use
- RocketChatManager.Say(playerid, message);
- return;
- }
- ushort id;
- switch (components[0])
- {
- case "v":
- if (!UconomyBasicShop.Instance.Configuration.CanBuyVehicles)
- {
- RocketChatManager.Say(playerid, UconomyBasicShop.Instance.Configuration.BuyVehiclesOff);
- return;
- }
- string name = "";
- if (!ushort.TryParse(components[1], out id))
- {
- Asset[] array = Assets.find(EAssetType.Vehicle);
- Asset[] array2 = array;
- for (int i = 0; i < array2.Length; i++)
- {
- VehicleAsset vAsset = (VehicleAsset)array2[i];
- if (vAsset != null && vAsset.Name != null && vAsset.Name.ToLower().Contains(components[1].ToLower()))
- {
- id = vAsset.Id;
- name = vAsset.Name;
- break;
- }
- }
- }
- if (name == null && id == 0)
- {
- message = String.Format(UconomyBasicShop.Instance.Configuration.CouldNotFind, components[1]);
- RocketChatManager.Say(playerid, message);
- return;
- }
- else if (name == null && id != 0)
- {
- name = ((VehicleAsset)Assets.find(EAssetType.Vehicle, id)).Name;
- }
- decimal cost = UconomyBasicShop.Instance.ShopDB.GetVehicleCost(id);
- decimal balance = Uconomy.Instance.Database.GetBalance(playerid.CSteamID);
- if (cost <= 0m)
- {
- message = String.Format(UconomyBasicShop.Instance.Configuration.VehicleNotAvailable, name);
- RocketChatManager.Say(playerid, message);
- return;
- }
- if (balance < cost)
- {
- message = String.Format(UconomyBasicShop.Instance.Configuration.NotEnoughCurrencyMsg, Uconomy.Instance.Configuration.MoneyName, name);
- RocketChatManager.Say(playerid, message);
- return;
- }
- if (!playerid.GiveVehicle(id))
- {
- RocketChatManager.Say(playerid, "There was an error giving you " + name + ". You have not been charged.");
- return;
- }
- decimal newbal = Uconomy.Instance.Database.IncreaseBalance(playerid.CSteamID, (cost * -1));
- message = String.Format(UconomyBasicShop.Instance.Configuration.VehicleBuyMsg, name, cost, Uconomy.Instance.Configuration.MoneyName, newbal, Uconomy.Instance.Configuration.MoneyName);
- message = "You bought " + name + " for " + cost.ToString() + " " + Uconomy.Instance.Configuration.MoneyName + ".";
- RocketChatManager.Say(playerid, message);
- break;
- default:
- if (!UconomyBasicShop.Instance.Configuration.CanBuyItems)
- {
- RocketChatManager.Say(playerid, UconomyBasicShop.Instance.Configuration.BuyItemsOff);
- return;
- }
- name = null;
- if (!ushort.TryParse(components[1], out id))
- {
- Asset[] array = Assets.find(EAssetType.Item);
- Asset[] array2 = array;
- for (int i = 0; i < array2.Length; i++)
- {
- ItemAsset vAsset = (ItemAsset)array2[i];
- if (vAsset != null && vAsset.Name != null && vAsset.Name.ToLower().Contains(components[1].ToLower()))
- {
- id = vAsset.Id;
- name = vAsset.Name;
- break;
- }
- }
- }
- if (name == null && id == null)
- {
- message = String.Format(UconomyBasicShop.Instance.Configuration.CouldNotFind, components[1]);
- RocketChatManager.Say(playerid, message);
- return;
-
- }
- else if (name == null && id != null)
- {
- name = ((ItemAsset)Assets.find(EAssetType.Item, id)).Name;
- }
- cost = UconomyBasicShop.Instance.ShopDB.GetItemCost(id) * amttobuy;
- balance = Uconomy.Instance.Database.GetBalance(playerid.CSteamID);
- if (cost <= 0m)
- {
- message = String.Format(UconomyBasicShop.Instance.Configuration.ItemNotAvailable, name);
- RocketChatManager.Say(playerid, message);
- return;
- }
- if (balance < cost)
- {
- message = String.Format(UconomyBasicShop.Instance.Configuration.NotEnoughCurrencyMsg, Uconomy.Instance.Configuration.MoneyName, amttobuy, name);
- RocketChatManager.Say(playerid, message);
- return;
- }
- if (!playerid.GiveItem(id, amttobuy))
- {
- RocketChatManager.Say(playerid, "There was an error giving you " + name + ". You have not been charged.");
- return;
- }
- newbal = Uconomy.Instance.Database.IncreaseBalance(playerid.CSteamID, (cost * -1));
- message = String.Format(UconomyBasicShop.Instance.Configuration.ItemBuyMsg, name, cost, Uconomy.Instance.Configuration.MoneyName, newbal, Uconomy.Instance.Configuration.MoneyName, amttobuy);
- RocketChatManager.Say(playerid, message);
- break;
- }
+ UconomyBasicShop.Instance.Buy(playerid, msg);
}
}
}
@@ -34,96 +34,7 @@ public string Help
public void Execute(RocketPlayer playerid, string msg)
{
- string message;
- if (string.IsNullOrEmpty(msg))
- {
- message = "Usage: /cost <v or i>.<name or id>.";
- // We are going to print how to use
- RocketChatManager.Say(playerid, message);
- return;
- }
- string[] components = Parser.getComponentsFromSerial(msg, '.');
- if (components.Length < 2)
- {
- message = "Usage: /cost <v or i>.<name or id>.";
- // We are going to print how to use
- RocketChatManager.Say(playerid, message);
- return;
- }
- ushort id;
- switch (components[0])
- {
- case "v":
- string name = null;
- if (!ushort.TryParse(components[1], out id))
- {
- Asset[] array = Assets.find(EAssetType.Vehicle);
- Asset[] array2 = array;
- for (int i = 0; i < array2.Length; i++)
- {
- VehicleAsset vAsset = (VehicleAsset)array2[i];
- if (vAsset != null && vAsset.Name != null && vAsset.Name.ToLower().Contains(components[1].ToLower()))
- {
- id = vAsset.Id;
- name = vAsset.Name;
- break;
- }
- }
- }
- if (name == null && id == 0)
- {
- message = String.Format(UconomyBasicShop.Instance.Configuration.CouldNotFind, components[1]);
- RocketChatManager.Say(playerid, message);
- return;
- }
- else if (name == null && id != 0)
- {
- name = ((VehicleAsset)Assets.find(EAssetType.Vehicle, id)).Name;
- }
- decimal cost = UconomyBasicShop.Instance.ShopDB.GetVehicleCost(id);
- message = String.Format(UconomyBasicShop.Instance.Configuration.VehicleCostMsg, name, cost.ToString(), Uconomy.Instance.Configuration.MoneyName);
- if (cost <= 0m)
- {
- message = "There was an error getting the cost of " + name + "!";
- }
- RocketChatManager.Say(playerid, message);
- break;
- default:
- name = null;
- if (!ushort.TryParse(components[1], out id))
- {
- Asset[] array = Assets.find(EAssetType.Item);
- Asset[] array2 = array;
- for (int i = 0; i < array2.Length; i++)
- {
- ItemAsset iAsset = (ItemAsset)array2[i];
- if (iAsset != null && iAsset.Name != null && iAsset.Name.ToLower().Contains(components[1].ToLower()))
- {
- id = iAsset.Id;
- name = iAsset.Name;
- break;
- }
- }
- }
- if (name == null && id == null)
- {
- message = String.Format(UconomyBasicShop.Instance.Configuration.CouldNotFind, components[1]);
- RocketChatManager.Say(playerid, message);
- return;
- }
- else if (name == null && id != null)
- {
- name = ((ItemAsset)Assets.find(EAssetType.Item, id)).Name;
- }
- cost = UconomyBasicShop.Instance.ShopDB.GetItemCost(id);
- message = String.Format(UconomyBasicShop.Instance.Configuration.ItemCostMsg, name, cost.ToString(), Uconomy.Instance.Configuration.MoneyName);
- if (cost <= 0m)
- {
- message = "There was an error getting the cost of " + name + "!";
- }
- RocketChatManager.Say(playerid, message);
- break;
- }
+ UconomyBasicShop.Instance.Cost(playerid, msg);
}
}
}
Oops, something went wrong.

0 comments on commit ed4e300

Please sign in to comment.