Permalink
Browse files

Release 1.0.1.6

  • Loading branch information...
1 parent 0a85e5f commit 5490e3dd6f6abb753d286b4c3b4fb0fb759b14d8 @Zamirathe Zamirathe committed Mar 23, 2015
View
@@ -0,0 +1,40 @@
+Unturned 3 is property of Smartly Dressed Games.
+You are not allowed to change, mix or redistribute Unturned 3
+unless permission is explicitly given by Smartly Dressed Games.
+Copyright (C) 2015 Smartly Dressed Games
+
+
+The Rocket Wiki accesible at https://github.com/RocketFoundation/Rocket/wiki/
+is licensed under a Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) License.
+You are free to share and adapt it for any purpose as long as you give appropiate
+credit and license any derivations under the same license as the original.
+See http://creativecommons.org/licenses/by-sa/3.0/ for the human-readable summary
+and http://creativecommons.org/licenses/by-sa/3.0/legalcode for the full license.
+
+
+Rocket, as a modification to Unturned 3 is licensed under a
+Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
+You are free to share it as long as you give appropiate credit, don't use it
+for commercial purposes and dont distribute modified versions.
+See http://creativecommons.org/licenses/by-nc-nd/3.0/ for the human-readable summary
+and http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode for the full license.
+
+If you want to use Rocket for comercial purposes, please contact us at info@rocket.foundation
+
+
+The RocketAPI is licensed under GPLv2.
+All plugins are automatically sub licensed under the same license.
+Copyright (C) 2015 Rocket Foundation
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
View
@@ -0,0 +1,19 @@
+# ZaupShop
+A simple shop using the chat line. This allows you to have a shop for players to use Uconomy currency to buy items and vehicles. Buying vehicles is turned off by default.
+
+There are 3 commands: /shop, /cost, and /buy.
+/cost and /buy are meant to be used by everyone that has permissions for them. Just put the command in the permissions file for the group.
+/shop is meant for admins only, but is not limited to that. You can add groups to have the ability to use this command by adding shop in their group of commands and one or more of the following: shop.add (adding to the shop), shop.rem (removing from the shop), shop.chng (changing costs), or shop.* (all 3) to the group permissions.
+
+Usage:
+/buy <i or v>.<item name or id>/[amount] (optional) – This will use the same name to id find as /i. i stands for item, v stands for vehicle. Amount is only available for items and is optional, default is 1.
+/cost <i or v>.<item name or id> – Same as above but will display the user the cost of asked for item/vehicle.
+/shop <add/rem/chng>/<i or v>.<itemid>/<cost> – This is the most complicated as it has multiple options. add (Adding), rem (Removing), chng (Change cost), i for Item and v for Vehicle and is required, itemids only (no names) for this command and one is required. Cost is not required for rem, but is required for the other two.
+
+Only /shop can be run from both the console and in game.
+
+Requirements:
+Uconomy
+Mysql
+
+This will run off the same database as Uconomy, but just create 2 new tables for the items and vehicles in the shop to be stored in. The tables are created blank. An admin, or someone with ability to use /shop, will have to add the items/vehicles. These can only be added one at a time through the command. If you can access the table with something like phpmyadmin, feel free to add them in mass that way.
View
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Express 2013 for Windows Desktop
+VisualStudioVersion = 12.0.31101.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UconomyBasicShop", "UconomyBasicShop\UconomyBasicShop.csproj", "{ABF4C55C-D1AC-4A28-A08F-8A99042990BD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {ABF4C55C-D1AC-4A28-A08F-8A99042990BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ABF4C55C-D1AC-4A28-A08F-8A99042990BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ABF4C55C-D1AC-4A28-A08F-8A99042990BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ABF4C55C-D1AC-4A28-A08F-8A99042990BD}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,179 @@
+using System;
+using Rocket.RocketAPI;
+using SDG;
+using UnityEngine;
+using unturned.ROCKS.Uconomy;
+
+namespace UconomyBasicShop
+{
+ public class CommandBuy : Command
+ {
+ public CommandBuy()
+ {
+ this.commandName = "buy";
+ this.commandHelp = "Allows you to buy items from the shop.";
+ this.commandInfo = this.commandName + " - " + this.commandHelp;
+ }
+
+ protected override void execute(SteamPlayerID playerid, string msg)
+ {
+ 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)
+ {
+ if (p == "buy")
+ {
+ perm = true;
+ break;
+ }
+ }
+ if (!perm)
+ {
+ RocketChatManager.Say(playerid.CSteamID, "You don't have permission to use the /buy command.");
+ return;
+ }
+ 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);
+ 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.CSteamID, message);
+ return;
+ }
+ ushort id;
+ switch (components[0])
+ {
+ case "v":
+ if (!UconomyBasicShop.Instance.Configuration.CanBuyVehicles)
+ {
+ RocketChatManager.Say(playerid.CSteamID, 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.CSteamID, 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.CSteamID, message);
+ return;
+ }
+ if (balance < cost)
+ {
+ message = String.Format(UconomyBasicShop.Instance.Configuration.NotEnoughCurrencyMsg, Uconomy.Instance.Configuration.MoneyName, name);
+ RocketChatManager.Say(playerid.CSteamID, message);
+ return;
+ }
+ Player player = PlayerTool.getPlayer(playerid.CSteamID);
+ if (!VehicleTool.giveVehicle(player, id))
+ {
+ RocketChatManager.Say(playerid.CSteamID, "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.CSteamID, message);
+ break;
+ default:
+ if (!UconomyBasicShop.Instance.Configuration.CanBuyItems)
+ {
+ RocketChatManager.Say(playerid.CSteamID, 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.CSteamID, 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.CSteamID, message);
+ return;
+ }
+ if (balance < cost)
+ {
+ message = String.Format(UconomyBasicShop.Instance.Configuration.NotEnoughCurrencyMsg, Uconomy.Instance.Configuration.MoneyName, amttobuy, name);
+ RocketChatManager.Say(playerid.CSteamID, message);
+ return;
+ }
+ player = PlayerTool.getPlayer(playerid.CSteamID);
+ if (!ItemTool.tryForceGiveItem(player, id, amttobuy))
+ {
+ RocketChatManager.Say(playerid.CSteamID, "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.CSteamID, message);
+ break;
+ }
+ }
+ }
+}
@@ -0,0 +1,130 @@
+using System;
+using Rocket.RocketAPI;
+using Rocket.Logging;
+using SDG;
+using UnityEngine;
+using unturned.ROCKS.Uconomy;
+
+namespace UconomyBasicShop
+{
+ public class CommandCost : Command
+ {
+ public CommandCost()
+ {
+ this.commandName = "cost";
+ this.commandHelp = "Tells you the cost of a selected item.";
+ this.commandInfo = this.commandName + " - " + this.commandHelp;
+ }
+
+ protected override void execute(SteamPlayerID playerid, string msg)
+ {
+ 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)
+ {
+ if (p == "cost")
+ {
+ perm = true;
+ break;
+ }
+ }
+ if (!perm)
+ {
+ RocketChatManager.Say(playerid.CSteamID, "You don't have permission to use the /cost command.");
+ return;
+ }
+ 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);
+ 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);
+ 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.CSteamID, 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.CSteamID, 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.CSteamID, 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.CSteamID, message);
+ break;
+ }
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 5490e3d

Please sign in to comment.