Permalink
Browse files

Update to work with rocket 3.1.0.0

  • Loading branch information...
1 parent 5490e3d commit 372512e45da54a1b82c6f33221ca9e3c98104862 @Zamirathe Zamirathe committed Mar 29, 2015
@@ -3,43 +3,42 @@
using SDG;
using UnityEngine;
using unturned.ROCKS.Uconomy;
+using Steamworks;
namespace UconomyBasicShop
{
- public class CommandBuy : Command
+ public class CommandBuy : IRocketCommand
{
- public CommandBuy()
+ public bool RunFromConsole
{
- this.commandName = "buy";
- this.commandHelp = "Allows you to buy items from the shop.";
- this.commandInfo = this.commandName + " - " + this.commandHelp;
+ get
+ {
+ return false;
+ }
}
-
- protected override void execute(SteamPlayerID playerid, string msg)
+ public string Name
{
- if (!RocketCommand.IsPlayer(playerid)) return;
- SteamPlayer splayer = PlayerTool.getSteamPlayer(playerid.CSteamID);
- string[] perms = RocketPermissionManager.GetPermissions(playerid.CSteamID);
- bool perm = false;
- foreach (string p in perms)
+ get
{
- if (p == "buy")
- {
- perm = true;
- break;
- }
+ return "buy";
}
- if (!perm)
+ }
+ public string Help
+ {
+ get
{
- RocketChatManager.Say(playerid.CSteamID, "You don't have permission to use the /buy command.");
- return;
+ return "Allows you to buy items from the shop.";
}
+ }
+
+ public void Execute(CSteamID 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.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
byte amttobuy = 1;
@@ -53,7 +52,7 @@ protected override void execute(SteamPlayerID playerid, string msg)
{
message = "Usage: /buy <v or i>.<name or id>/<amount> (optional).";
// We are going to print how to use
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
ushort id;
@@ -62,7 +61,7 @@ protected override void execute(SteamPlayerID playerid, string msg)
case "v":
if (!UconomyBasicShop.Instance.Configuration.CanBuyVehicles)
{
- RocketChatManager.Say(playerid.CSteamID, UconomyBasicShop.Instance.Configuration.BuyVehiclesOff);
+ RocketChatManager.Say(playerid, UconomyBasicShop.Instance.Configuration.BuyVehiclesOff);
return;
}
string name = "";
@@ -84,42 +83,42 @@ protected override void execute(SteamPlayerID playerid, string msg)
if (name == null && id == 0)
{
message = String.Format(UconomyBasicShop.Instance.Configuration.CouldNotFind, components[1]);
- RocketChatManager.Say(playerid.CSteamID, message);
+ 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);
+ decimal balance = Uconomy.Instance.Database.GetBalance(playerid);
if (cost <= 0m)
{
message = String.Format(UconomyBasicShop.Instance.Configuration.VehicleNotAvailable, name);
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
if (balance < cost)
{
message = String.Format(UconomyBasicShop.Instance.Configuration.NotEnoughCurrencyMsg, Uconomy.Instance.Configuration.MoneyName, name);
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
- Player player = PlayerTool.getPlayer(playerid.CSteamID);
+ Player player = PlayerTool.getPlayer(playerid);
if (!VehicleTool.giveVehicle(player, id))
{
- RocketChatManager.Say(playerid.CSteamID, "There was an error giving you " + name + ". You have not been charged.");
+ 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));
+ decimal newbal = Uconomy.Instance.Database.IncreaseBalance(playerid, (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.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
break;
default:
if (!UconomyBasicShop.Instance.Configuration.CanBuyItems)
{
- RocketChatManager.Say(playerid.CSteamID, UconomyBasicShop.Instance.Configuration.BuyItemsOff);
+ RocketChatManager.Say(playerid, UconomyBasicShop.Instance.Configuration.BuyItemsOff);
return;
}
name = null;
@@ -141,7 +140,7 @@ protected override void execute(SteamPlayerID playerid, string msg)
if (name == null && id == null)
{
message = String.Format(UconomyBasicShop.Instance.Configuration.CouldNotFind, components[1]);
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
@@ -150,28 +149,28 @@ protected override void execute(SteamPlayerID playerid, string msg)
name = ((ItemAsset)Assets.find(EAssetType.Item, id)).Name;
}
cost = UconomyBasicShop.Instance.ShopDB.GetItemCost(id) * amttobuy;
- balance = Uconomy.Instance.Database.GetBalance(playerid.CSteamID);
+ balance = Uconomy.Instance.Database.GetBalance(playerid);
if (cost <= 0m)
{
message = String.Format(UconomyBasicShop.Instance.Configuration.ItemNotAvailable, name);
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
if (balance < cost)
{
message = String.Format(UconomyBasicShop.Instance.Configuration.NotEnoughCurrencyMsg, Uconomy.Instance.Configuration.MoneyName, amttobuy, name);
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
- player = PlayerTool.getPlayer(playerid.CSteamID);
+ player = PlayerTool.getPlayer(playerid);
if (!ItemTool.tryForceGiveItem(player, id, amttobuy))
{
- RocketChatManager.Say(playerid.CSteamID, "There was an error giving you " + name + ". You have not been charged.");
+ 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));
+ newbal = Uconomy.Instance.Database.IncreaseBalance(playerid, (cost * -1));
message = String.Format(UconomyBasicShop.Instance.Configuration.ItemBuyMsg, name, cost, Uconomy.Instance.Configuration.MoneyName, newbal, Uconomy.Instance.Configuration.MoneyName, amttobuy);
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
break;
}
}
@@ -4,51 +4,50 @@
using SDG;
using UnityEngine;
using unturned.ROCKS.Uconomy;
+using Steamworks;
namespace UconomyBasicShop
{
- public class CommandCost : Command
+ public class CommandCost : IRocketCommand
{
- public CommandCost()
+ public bool RunFromConsole
{
- this.commandName = "cost";
- this.commandHelp = "Tells you the cost of a selected item.";
- this.commandInfo = this.commandName + " - " + this.commandHelp;
+ get
+ {
+ return false;
+ }
}
-
- protected override void execute(SteamPlayerID playerid, string msg)
+ public string Name
{
- if (!RocketCommand.IsPlayer(playerid)) return;
- SteamPlayer splayer = PlayerTool.getSteamPlayer(playerid.CSteamID);
- string[] perms = RocketPermissionManager.GetPermissions(playerid.CSteamID);
- bool perm = false;
- foreach (string p in perms)
+ get
{
- if (p == "cost")
- {
- perm = true;
- break;
- }
+ return "cost";
}
- if (!perm)
+ }
+ public string Help
+ {
+ get
{
- RocketChatManager.Say(playerid.CSteamID, "You don't have permission to use the /cost command.");
- return;
+ return "Tells you the cost of a selected item.";
}
+ }
+
+ public void Execute(CSteamID 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.CSteamID, message);
+ 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.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
ushort id;
@@ -74,7 +73,7 @@ protected override void execute(SteamPlayerID playerid, string msg)
if (name == null && id == 0)
{
message = String.Format(UconomyBasicShop.Instance.Configuration.CouldNotFind, components[1]);
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
else if (name == null && id != 0)
@@ -87,7 +86,7 @@ protected override void execute(SteamPlayerID playerid, string msg)
{
message = "There was an error getting the cost of " + name + "!";
}
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
break;
default:
name = null;
@@ -109,7 +108,7 @@ protected override void execute(SteamPlayerID playerid, string msg)
if (name == null && id == null)
{
message = String.Format(UconomyBasicShop.Instance.Configuration.CouldNotFind, components[1]);
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
return;
}
else if (name == null && id != null)
@@ -122,7 +121,7 @@ protected override void execute(SteamPlayerID playerid, string msg)
{
message = "There was an error getting the cost of " + name + "!";
}
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
break;
}
}
@@ -4,27 +4,43 @@
using Rocket.Logging;
using SDG;
using UnityEngine;
+using Steamworks;
namespace UconomyBasicShop
{
- public class CommandShop : Command
+ public class CommandShop : IRocketCommand
{
- public CommandShop()
+ public bool RunFromConsole
{
- this.commandName = "shop";
- this.commandHelp = "Allows admins to change, add, or remove items/vehicles from the shop.";
- this.commandInfo = this.commandName + " - " + this.commandHelp;
+ get
+ {
+ return true;
+ }
+ }
+ public string Name
+ {
+ get
+ {
+ return "shop";
+ }
+ }
+ public string Help
+ {
+ get
+ {
+ return "Allows admins to change, add, or remove items/vehicles from the shop.";
+ }
}
- protected override void execute(SteamPlayerID playerid, string msg)
+ public void Execute(CSteamID playerid, string msg)
{
- bool console = !RocketCommand.IsPlayer(playerid);
- SteamPlayer splayer = PlayerTool.getSteamPlayer(playerid.CSteamID);
+ bool console = (!string.IsNullOrEmpty(playerid.ToString()) && playerid.ToString() != "0") ? false : true;
+ SteamPlayer splayer = PlayerTool.getSteamPlayer(playerid);
string[] permnames = {"shop.*", "shop.add", "shop.rem", "shop.chng"};
bool[] perms = {false, false, false, false};
bool anyuse = false;
string message;
- string[] permlist = RocketPermissionManager.GetPermissions(playerid.CSteamID);
+ string[] permlist = RocketPermissionManager.GetPermissions(playerid);
foreach (string s in permlist)
{
switch (s)
@@ -64,7 +80,7 @@ protected override void execute(SteamPlayerID playerid, string msg)
}
if (!anyuse) {
// Assume this is a player
- RocketChatManager.Say(playerid.CSteamID, "You don't have permission to use the /shop command.");
+ RocketChatManager.Say(playerid, "You don't have permission to use the /shop command.");
return;
}
if (string.IsNullOrEmpty(msg))
@@ -183,15 +199,15 @@ protected override void execute(SteamPlayerID playerid, string msg)
}
}
}
- private void sendMessage(SteamPlayerID playerid, string message, bool console)
+ private void sendMessage(CSteamID playerid, string message, bool console)
{
if (console)
{
Logger.Log(message);
}
else
{
- RocketChatManager.Say(playerid.CSteamID, message);
+ RocketChatManager.Say(playerid, message);
}
}
}
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.1.6")]
-[assembly: AssemblyFileVersion("1.0.1.6")]
+[assembly: AssemblyVersion("1.0.1.8")]
+[assembly: AssemblyFileVersion("1.0.1.8")]
Oops, something went wrong.

0 comments on commit 372512e

Please sign in to comment.