mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-27 07:11:04 -04:00
Cleanup /economy, separate into a /buy command.
This commit is contained in:
parent
72e0bdd7fc
commit
69f5bdefc7
222
Commands/Economy/CmdBuy.cs
Normal file
222
Commands/Economy/CmdBuy.cs
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
|
not use this file except in compliance with the Licenses. You may
|
||||||
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
|
or implied. See the Licenses for the specific language governing
|
||||||
|
permissions and limitations under the Licenses.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Threading;
|
||||||
|
using MCGalaxy.SQL;
|
||||||
|
|
||||||
|
namespace MCGalaxy.Commands {
|
||||||
|
|
||||||
|
/// <summary> Economy Beta v1.0 QuantumHive </summary>
|
||||||
|
public sealed class CmdBuy : Command {
|
||||||
|
public override string name { get { return "buy"; } }
|
||||||
|
public override string shortcut { get { return "purchase"; } }
|
||||||
|
public override string type { get { return CommandTypes.Economy; } }
|
||||||
|
public override bool museumUsable { get { return false; } }
|
||||||
|
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
|
||||||
|
public override bool Enabled { get { return Economy.Settings.Enabled; } }
|
||||||
|
|
||||||
|
public override void Use(Player p, string message) {
|
||||||
|
if (p == null) { MessageInGameOnly(p); return; }
|
||||||
|
string[] parts = message.Split(' ');
|
||||||
|
|
||||||
|
Economy.EcoStats ecos = Economy.RetrieveEcoStats(p.name);
|
||||||
|
switch (parts[0].ToLower()) {
|
||||||
|
case "map":
|
||||||
|
case "level":
|
||||||
|
case "maps":
|
||||||
|
case "levels":
|
||||||
|
if (parts.Length < 2) { Help(p); return; }
|
||||||
|
Economy.Settings.Level lvl = Economy.FindLevel(parts[1]);
|
||||||
|
if (lvl == null) { Player.SendMessage(p, "%cThat isn't a level preset"); return; }
|
||||||
|
|
||||||
|
if (!p.EnoughMoney(lvl.price)) {
|
||||||
|
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy that map"); return;
|
||||||
|
}
|
||||||
|
int old = p.money;
|
||||||
|
int oldTS = ecos.totalSpent;
|
||||||
|
string oldP = ecos.purchase;
|
||||||
|
if (parts.Length < 3) { Help(p); return; }
|
||||||
|
string name = parts[2];
|
||||||
|
|
||||||
|
try {
|
||||||
|
Command.all.Find("newlvl").Use(null, p.name + "_" + name + " " + lvl.x + " " + lvl.y + " " + lvl.z + " " + lvl.type);
|
||||||
|
Player.SendMessage(p, "%aCreating level: '%f" + p.name + "_" + name + "%a' . . .");
|
||||||
|
p.money = p.money - lvl.price;
|
||||||
|
ecos.money = p.money;
|
||||||
|
ecos.totalSpent += lvl.price;
|
||||||
|
ecos.purchase = "%3Map: %f" + lvl.name + "%3 - Price: %f" + lvl.price + " %3" + Server.moneys +
|
||||||
|
" - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
|
Economy.UpdateEcoStats(ecos);
|
||||||
|
|
||||||
|
Command.all.Find("load").Use(null, p.name + "_" + name);
|
||||||
|
Thread.Sleep(250);
|
||||||
|
Level level = LevelInfo.Find(p.name + "_" + name);
|
||||||
|
if (level.permissionbuild > p.group.Permission) { level.permissionbuild = p.group.Permission; }
|
||||||
|
if (level.permissionvisit > p.group.Permission) { level.permissionvisit = p.group.Permission; }
|
||||||
|
Command.all.Find("goto").Use(p, p.name + "_" + name);
|
||||||
|
|
||||||
|
Player.SendMessage(p, "%aSuccessfully created your map: '%f" + p.name + "_" + name + "%a'");
|
||||||
|
Player.SendMessage(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
|
||||||
|
try {
|
||||||
|
//safe against SQL injections, but will be replaced soon by a new feature
|
||||||
|
//DB
|
||||||
|
Database.executeQuery("INSERT INTO `Zone" + level.name + "` (SmallX, SmallY, SmallZ, BigX, BigY, BigZ, Owner) parts[1]S " +
|
||||||
|
"(0,0,0," + (level.Width - 1) + "," + (level.Height - 1) + "," + (level.Length - 1) + ",'" + p.name + "')");
|
||||||
|
//DB
|
||||||
|
Player.SendMessage(p, "%aZoning Succesful");
|
||||||
|
} catch { Player.SendMessage(p, "%cZoning Failed"); }
|
||||||
|
} catch {
|
||||||
|
Player.SendMessage(p, "%cSomething went wrong, Money restored");
|
||||||
|
if (old != p.money) {
|
||||||
|
p.money = old; ecos.money = old; ecos.totalSpent = oldTS; ecos.purchase = oldP;
|
||||||
|
Economy.UpdateEcoStats(ecos);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case "colors":
|
||||||
|
case "color":
|
||||||
|
case "colours":
|
||||||
|
case "colour":
|
||||||
|
if (parts.Length < 2) { Help(p); return; }
|
||||||
|
if (!p.EnoughMoney(Economy.Settings.ColorPrice)) {
|
||||||
|
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a color");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!parts[1].StartsWith("&") || !parts[1].StartsWith("%")) {
|
||||||
|
parts[1] = Colors.Parse(parts[1]);
|
||||||
|
if (parts[1] == "") {
|
||||||
|
Player.SendMessage(p, "%cThat wasn't a color");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parts[1] == p.color) {
|
||||||
|
Player.SendMessage(p, "%cYou already have a " + parts[1] + Colors.Name(parts[1]) + "%c color"); return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command.all.Find("color").Use(null, p.name + " " + Colors.Name(parts[1]));
|
||||||
|
p.money = p.money - Economy.Settings.ColorPrice;
|
||||||
|
ecos.money = p.money;
|
||||||
|
ecos.totalSpent += Economy.Settings.ColorPrice;
|
||||||
|
ecos.purchase = "%3Color: " + parts[1] + Colors.Name(parts[1]) + "%3 - Price: %f" + Economy.Settings.ColorPrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
|
Economy.UpdateEcoStats(ecos);
|
||||||
|
Player.SendMessage(p, "%aYour color has been successfully changed to " + parts[1] + Colors.Name(parts[1]));
|
||||||
|
Player.SendMessage(p, "%aYour balance is now %f" + p.money.ToString() + " %3" + Server.moneys);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "tcolor":
|
||||||
|
case "tcolors":
|
||||||
|
case "titlecolor":
|
||||||
|
case "titlecolors":
|
||||||
|
case "tc":
|
||||||
|
if (parts.Length < 2) { Help(p); return; }
|
||||||
|
if (!p.EnoughMoney(Economy.Settings.TColorPrice)) {
|
||||||
|
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a titlecolor");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!parts[1].StartsWith("&") || !parts[1].StartsWith("%")) {
|
||||||
|
parts[1] = Colors.Parse(parts[1]);
|
||||||
|
if (parts[1] == "") {
|
||||||
|
Player.SendMessage(p, "%cThat wasn't a color");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parts[1] == p.titlecolor) {
|
||||||
|
Player.SendMessage(p, "%cYou already have a " + parts[1] + Colors.Name(parts[1]) + "%c titlecolor"); return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Command.all.Find("tcolor").Use(null, p.name + " " + Colors.Name(parts[1]));
|
||||||
|
p.money = p.money - Economy.Settings.TColorPrice;
|
||||||
|
ecos.money = p.money;
|
||||||
|
ecos.totalSpent += Economy.Settings.TColorPrice;
|
||||||
|
ecos.purchase = "%3Titlecolor: " + parts[1] + Colors.Name(parts[1]) + "%3 - Price: %f" + Economy.Settings.TColorPrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
|
Economy.UpdateEcoStats(ecos);
|
||||||
|
Player.SendMessage(p, "%aYour titlecolor has been successfully changed to " + parts[1] + Colors.Name(parts[1]));
|
||||||
|
Player.SendMessage(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "titles":
|
||||||
|
case "title":
|
||||||
|
if (parts.Length < 2) { Help(p); return; }
|
||||||
|
if (!p.EnoughMoney(Economy.Settings.TitlePrice)) {
|
||||||
|
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a title"); return;
|
||||||
|
}
|
||||||
|
if (parts[1] == p.title) {
|
||||||
|
Player.SendMessage(p, "%cYou already have that title"); return;
|
||||||
|
}
|
||||||
|
if (parts[1].Length > 17) {
|
||||||
|
Player.SendMessage(p, "%cTitles cannot be longer than 17 characters"); return;
|
||||||
|
}
|
||||||
|
var regex = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z0-9-_\\.]*$");
|
||||||
|
if (!regex.IsMatch(parts[1])) {
|
||||||
|
Player.SendMessage(p, "%cInvalid title! Titles may only contain alphanumeric characters and .-_");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool free = parts[1] == "";
|
||||||
|
Command.all.Find("title").Use(null, p.name + " " + parts[1]);
|
||||||
|
if (!free) {
|
||||||
|
p.money = p.money - Economy.Settings.TitlePrice;
|
||||||
|
ecos.money = p.money;
|
||||||
|
ecos.totalSpent += Economy.Settings.TitlePrice;
|
||||||
|
ecos.purchase = "%3Title: %f" + parts[1] + "%3 - Price: %f" + Economy.Settings.TitlePrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
|
Economy.UpdateEcoStats(ecos);
|
||||||
|
Player.SendMessage(p, "%aYour title has been successfully changed to [" + p.titlecolor + parts[1] + "%a]");
|
||||||
|
} else {
|
||||||
|
Player.SendMessage(p, "%aYour title has been successfully removed for free");
|
||||||
|
}
|
||||||
|
Player.SendMessage(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ranks":
|
||||||
|
case "rank":
|
||||||
|
if (parts.Length >= 2) {
|
||||||
|
Player.SendMessage(p, "%cYou cannot provide a rank name, use %a/eco buy rank %cto buy the NEXT rank."); return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LevelPermission maxrank = Group.Find(Economy.Settings.MaxRank).Permission;
|
||||||
|
if (p.group.Permission >= maxrank) {
|
||||||
|
Player.SendMessage(p, "%cYou cannot buy anymore ranks, because you passed the max buyable rank: " + Group.Find(Economy.Settings.MaxRank).color + Economy.Settings.MaxRank);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!p.EnoughMoney(Economy.NextRank(p).price)) {
|
||||||
|
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy the next rank"); return;
|
||||||
|
}
|
||||||
|
Command.all.Find("promote").Use(null, p.name);
|
||||||
|
p.money = p.money - Economy.FindRank(p.group.name).price;
|
||||||
|
ecos.money = p.money;
|
||||||
|
ecos.totalSpent += Economy.FindRank(p.group.name).price;
|
||||||
|
ecos.purchase = "%3Rank: " + p.group.color + p.group.name + "%3 - Price: %f" + Economy.FindRank(p.group.name).price + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
|
Economy.UpdateEcoStats(ecos);
|
||||||
|
Player.SendMessage(p, "%aYou've successfully bought the rank " + p.group.color + p.group.name);
|
||||||
|
Player.SendMessage(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Player.SendMessage(p, "%cThat wasn't a valid command addition!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Help(Player p) {
|
||||||
|
Player.SendMessage(p, "%T/buy <title/color/tcolor/rank/map> [parts[1]] <map name>");
|
||||||
|
Player.SendMessage(p, "%Hparts[1] is either [title/color/tcolor/map_preset]");
|
||||||
|
Player.SendMessage(p, "%Hmap name is only used for %T/buy map%H.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -42,8 +42,6 @@ namespace MCGalaxy.Commands {
|
|||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "setup":
|
case "setup":
|
||||||
HandleSetup(p, message, args); break;
|
HandleSetup(p, message, args); break;
|
||||||
case "buy":
|
|
||||||
HandleBuy(p, message, args); break;
|
|
||||||
case "stats":
|
case "stats":
|
||||||
case "balance":
|
case "balance":
|
||||||
case "amount":
|
case "amount":
|
||||||
@ -84,23 +82,14 @@ namespace MCGalaxy.Commands {
|
|||||||
if (Economy.FindLevel(args[3]) != null) { Player.SendMessage(p, "%cThat preset level already exists"); break; } else {
|
if (Economy.FindLevel(args[3]) != null) { Player.SendMessage(p, "%cThat preset level already exists"); break; } else {
|
||||||
Economy.Settings.Level level = new Economy.Settings.Level();
|
Economy.Settings.Level level = new Economy.Settings.Level();
|
||||||
level.name = args[3];
|
level.name = args[3];
|
||||||
if (isGood(args[4]) && isGood(args[5]) && isGood(args[6])) { level.x = args[4]; level.y = args[5]; level.z = args[6]; } else { Player.SendMessage(p, "%cDimension must be a power of 2"); break; }
|
if (isGood(args[4]) && isGood(args[5]) && isGood(args[6])) {
|
||||||
switch (args[7].ToLower()) {
|
level.x = args[4]; level.y = args[5]; level.z = args[6];
|
||||||
case "flat":
|
} else { Player.SendMessage(p, "%cDimension must be a power of 2"); break; }
|
||||||
case "pixel":
|
|
||||||
case "island":
|
if (!MapGen.IsRecognisedFormat(args[7])) {
|
||||||
case "mountains":
|
MapGen.PrintValidFormats(p); return;
|
||||||
case "ocean":
|
|
||||||
case "forest":
|
|
||||||
case "desert":
|
|
||||||
case "space":
|
|
||||||
level.type = args[7].ToLower();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Player.SendMessage(p, "%cValid types are: island, mountains, forest, ocean, flat, pixel, desert, space");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
level.type = args[7].ToLower();
|
||||||
try {
|
try {
|
||||||
level.price = int.Parse(args[8]);
|
level.price = int.Parse(args[8]);
|
||||||
} catch { Player.SendMessage(p, "%cInvalid price input: that wasn't a number!"); return; }
|
} catch { Player.SendMessage(p, "%cInvalid price input: that wasn't a number!"); return; }
|
||||||
@ -115,101 +104,67 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
case "delete":
|
case "delete":
|
||||||
case "remove":
|
case "remove":
|
||||||
if (lvl == null) { Player.SendMessage(p, "%cThat preset level doesn't exist"); break; } else { Economy.Settings.LevelsList.Remove(lvl); Player.SendMessage(p, "%aSuccessfully removed preset: %f" + lvl.name); break; }
|
if (lvl == null) { Player.SendMessage(p, "%cThat preset level doesn't exist"); return; }
|
||||||
|
Economy.Settings.LevelsList.Remove(lvl);
|
||||||
|
Player.SendMessage(p, "%aSuccessfully removed preset: %f" + lvl.name);
|
||||||
|
break;
|
||||||
|
|
||||||
case "edit":
|
case "edit":
|
||||||
case "change":
|
case "change":
|
||||||
if (lvl == null) { Player.SendMessage(p, "%cThat preset level doesn't exist"); break; } else {
|
if (lvl == null) { Player.SendMessage(p, "%cThat preset level doesn't exist"); return; }
|
||||||
switch (args[4]) {
|
|
||||||
case "name":
|
switch (args[4]) {
|
||||||
case "title":
|
case "name":
|
||||||
Economy.Settings.LevelsList.Remove(lvl);
|
case "title":
|
||||||
lvl.name = args[5];
|
lvl.name = args[5];
|
||||||
Economy.Settings.LevelsList.Add(lvl);
|
Player.SendMessage(p, "%aSuccessfully changed preset name to %f" + lvl.name);
|
||||||
Player.SendMessage(p, "%aSuccessfully changed preset name to %f" + lvl.name);
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case "x":
|
case "x":
|
||||||
if (isGood(args[5])) {
|
if (isGood(args[5])) {
|
||||||
Economy.Settings.LevelsList.Remove(lvl);
|
lvl.x = args[5];
|
||||||
lvl.x = args[5];
|
Player.SendMessage(p, "%aSuccessfully changed preset x size to %f" + lvl.x);
|
||||||
Economy.Settings.LevelsList.Add(lvl);
|
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
|
||||||
Player.SendMessage(p, "%aSuccessfully changed preset x size to %f" + lvl.x);
|
break;
|
||||||
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "y":
|
case "y":
|
||||||
if (isGood(args[5])) {
|
if (isGood(args[5])) {
|
||||||
Economy.Settings.LevelsList.Remove(lvl);
|
lvl.y = args[5];
|
||||||
lvl.y = args[5];
|
Player.SendMessage(p, "%aSuccessfully changed preset y size to %f" + lvl.y);
|
||||||
Economy.Settings.LevelsList.Add(lvl);
|
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
|
||||||
Player.SendMessage(p, "%aSuccessfully changed preset y size to %f" + lvl.y);
|
break;
|
||||||
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "z":
|
case "z":
|
||||||
if (isGood(args[5])) {
|
if (isGood(args[5])) {
|
||||||
Economy.Settings.LevelsList.Remove(lvl);
|
lvl.z = args[5];
|
||||||
lvl.z = args[5];
|
Player.SendMessage(p, "%aSuccessfully changed preset z size to %f" + lvl.z);
|
||||||
Economy.Settings.LevelsList.Add(lvl);
|
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
|
||||||
Player.SendMessage(p, "%aSuccessfully changed preset z size to %f" + lvl.z);
|
break;
|
||||||
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "type":
|
case "type":
|
||||||
Economy.Settings.LevelsList.Remove(lvl);
|
if (MapGen.IsRecognisedFormat(args[5])) {
|
||||||
switch (args[5].ToLower()) {
|
lvl.type = args[5].ToLower();
|
||||||
case "flat":
|
} else {
|
||||||
case "pixel":
|
MapGen.PrintValidFormats(p); return;
|
||||||
case "island":
|
}
|
||||||
case "mountains":
|
Player.SendMessage(p, "%aSuccessfully changed preset type to %f" + lvl.type);
|
||||||
case "ocean":
|
break;
|
||||||
case "forest":
|
|
||||||
case "desert":
|
|
||||||
case "space":
|
|
||||||
lvl.type = args[5].ToLower();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
case "price":
|
||||||
Player.SendMessage(p, "%cValid types are: island, mountains, forest, ocean, flat, pixel, desert, space");
|
int newPrice = 0;
|
||||||
Economy.Settings.LevelsList.Add(lvl);
|
if (!int.TryParse(args[5], out newPrice)) {
|
||||||
return;
|
Player.SendMessage(p, "%cInvalid amount of %3" + Server.moneys); return;
|
||||||
}
|
}
|
||||||
Economy.Settings.LevelsList.Add(lvl);
|
if (newPrice < 0) {
|
||||||
Player.SendMessage(p, "%aSuccessfully changed preset type to %f" + lvl.type);
|
Player.SendMessage(p, "%cAmount of %3" + Server.moneys + "%c cannot be negative"); return;
|
||||||
break;
|
}
|
||||||
|
lvl.price = newPrice;
|
||||||
|
Player.SendMessage(p, "%aSuccessfully changed preset price to %f" + lvl.price + " %3" + Server.moneys);
|
||||||
|
break;
|
||||||
|
|
||||||
/*case "dimensions":
|
default:
|
||||||
case "sizes":
|
Player.SendMessage(p, "%cThat wasn't a valid command addition!");
|
||||||
case "dimension":
|
break;
|
||||||
case "size":
|
|
||||||
Economy.Settings.LevelsList.Remove(lvl);
|
|
||||||
if (isGood(args[4])) { lvl.x = args[4]; }
|
|
||||||
if (isGood(args[5])) { lvl.y = args[5]; }
|
|
||||||
if (isGood(args[6])) { lvl.z = args[6]; } else { Player.SendMessage(p, "A Dimension was wrong, it must a power of 2"); Economy.Settings.LevelsList.Add(lvl); break; }
|
|
||||||
Economy.Settings.LevelsList.Add(lvl);
|
|
||||||
Player.SendMessage(p, "Changed preset name");
|
|
||||||
break;*/
|
|
||||||
|
|
||||||
case "price":
|
|
||||||
Economy.Settings.LevelsList.Remove(lvl);
|
|
||||||
int old = lvl.price;
|
|
||||||
try {
|
|
||||||
lvl.price = int.Parse(args[5]);
|
|
||||||
} catch {
|
|
||||||
Economy.Settings.LevelsList.Add(lvl);
|
|
||||||
Player.SendMessage(p, "%cInvalid amount of %3" + Server.moneys);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (lvl.price < 0) { Player.SendMessage(p, "%cAmount of %3" + Server.moneys + "%c cannot be negative"); lvl.price = old; Economy.Settings.LevelsList.Add(lvl); return; }
|
|
||||||
Economy.Settings.LevelsList.Add(lvl);
|
|
||||||
Player.SendMessage(p, "%aSuccessfully changed preset price to %f" + lvl.price + " %3" + Server.moneys);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Player.SendMessage(p, "%cThat wasn't a valid command addition!");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -361,189 +316,6 @@ namespace MCGalaxy.Commands {
|
|||||||
Economy.Save();
|
Economy.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleBuy(Player p, string message, string[] args) {
|
|
||||||
if (p == null) { Player.SendMessage(p, "%cConsole cannot buy any items"); return; }
|
|
||||||
Economy.EcoStats ecos = Economy.RetrieveEcoStats(p.name);
|
|
||||||
switch (args[1]) {
|
|
||||||
case "map":
|
|
||||||
case "level":
|
|
||||||
case "maps":
|
|
||||||
case "levels":
|
|
||||||
Economy.Settings.Level lvl = Economy.FindLevel(args[2]);
|
|
||||||
if (lvl == null) { Player.SendMessage(p, "%cThat isn't a level preset"); return; } else {
|
|
||||||
if (!p.EnoughMoney(lvl.price)) {
|
|
||||||
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy that map");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if (args[3] == null) { Player.SendMessage(p, "%cYou didn't specify a name for your level"); return; } else {
|
|
||||||
int old = p.money;
|
|
||||||
int oldTS = ecos.totalSpent;
|
|
||||||
string oldP = ecos.purchase;
|
|
||||||
try {
|
|
||||||
Command.all.Find("newlvl").Use(null, p.name + "_" + args[3] + " " + lvl.x + " " + lvl.y + " " + lvl.z + " " + lvl.type);
|
|
||||||
Player.SendMessage(p, "%aCreating level: '%f" + p.name + "_" + args[3] + "%a' . . .");
|
|
||||||
p.money = p.money - lvl.price;
|
|
||||||
ecos.money = p.money;
|
|
||||||
ecos.totalSpent += lvl.price;
|
|
||||||
ecos.purchase = "%3Map: %f" + lvl.name + "%3 - Price: %f" + lvl.price + " %3" + Server.moneys + " - Date: %f" + ecoColor + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
|
||||||
Economy.UpdateEcoStats(ecos);
|
|
||||||
Command.all.Find("load").Use(null, p.name + "_" + args[3]);
|
|
||||||
Thread.Sleep(250);
|
|
||||||
Level level = LevelInfo.Find(p.name + "_" + args[3]);
|
|
||||||
if (level.permissionbuild > p.group.Permission) { level.permissionbuild = p.group.Permission; }
|
|
||||||
if (level.permissionvisit > p.group.Permission) { level.permissionvisit = p.group.Permission; }
|
|
||||||
Command.all.Find("goto").Use(p, p.name + "_" + args[3]);
|
|
||||||
|
|
||||||
Player.SendMessage(p, "%aSuccessfully created your map: '%f" + p.name + "_" + args[3] + "%a'");
|
|
||||||
Player.SendMessage(p, "%aYour balance is now %f" + p.money.ToString() + " %3" + Server.moneys);
|
|
||||||
try {
|
|
||||||
//safe against SQL injections, but will be replaced soon by a new feature
|
|
||||||
//DB
|
|
||||||
Database.executeQuery("INSERT INTO `Zone" + level.name + "` (SmallX, SmallY, SmallZ, BigX, BigY, BigZ, Owner) VALUES " +
|
|
||||||
"(0,0,0," + (level.Width - 1) + "," + (level.Height - 1) + "," + (level.Length - 1) + ",'" + p.name + "')");
|
|
||||||
//DB
|
|
||||||
Player.SendMessage(p, "%aZoning Succesful");
|
|
||||||
return;
|
|
||||||
} catch { Player.SendMessage(p, "%cZoning Failed"); return; }
|
|
||||||
} catch { Player.SendMessage(p, "%cSomething went wrong, Money restored"); if (old != p.money) { p.money = old; ecos.money = old; ecos.totalSpent = oldTS; ecos.purchase = oldP; Economy.UpdateEcoStats(ecos); } return; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "colors":
|
|
||||||
case "color":
|
|
||||||
case "colours":
|
|
||||||
case "colour":
|
|
||||||
if (p.EnoughMoney(Economy.Settings.ColorPrice) == false) {
|
|
||||||
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a color");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!args[2].StartsWith("&") || !args[2].StartsWith("%")) {
|
|
||||||
args[2] = Colors.Parse(args[2]);
|
|
||||||
if (args[2] == "") {
|
|
||||||
Player.SendMessage(p, "%cThat wasn't a color");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args[2] == p.color) {
|
|
||||||
Player.SendMessage(p, "%cYou already have a " + args[2] + Colors.Name(args[2]) + "%c color");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
Command.all.Find("color").Use(null, p.name + " " + Colors.Name(args[2]));
|
|
||||||
p.money = p.money - Economy.Settings.ColorPrice;
|
|
||||||
ecos.money = p.money;
|
|
||||||
ecos.totalSpent += Economy.Settings.ColorPrice;
|
|
||||||
ecos.purchase = "%3Color: " + args[2] + Colors.Name(args[2]) + "%3 - Price: %f" + Economy.Settings.ColorPrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
|
||||||
Economy.UpdateEcoStats(ecos);
|
|
||||||
Player.SendMessage(p, "%aYour color has been successfully changed to " + args[2] + Colors.Name(args[2]));
|
|
||||||
Player.SendMessage(p, "%aYour balance is now %f" + p.money.ToString() + " %3" + Server.moneys);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "tcolor":
|
|
||||||
case "tcolors":
|
|
||||||
case "titlecolor":
|
|
||||||
case "titlecolors":
|
|
||||||
case "tc":
|
|
||||||
if (!p.EnoughMoney(Economy.Settings.TColorPrice)) {
|
|
||||||
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a titlecolor");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!args[2].StartsWith("&") || !args[2].StartsWith("%")) {
|
|
||||||
args[2] = Colors.Parse(args[2]);
|
|
||||||
if (args[2] == "") {
|
|
||||||
Player.SendMessage(p, "%cThat wasn't a color");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args[2] == p.titlecolor) {
|
|
||||||
Player.SendMessage(p, "%cYou already have a " + args[2] + Colors.Name(args[2]) + "%c titlecolor");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
Command.all.Find("tcolor").Use(null, p.name + " " + Colors.Name(args[2]));
|
|
||||||
p.money = p.money - Economy.Settings.TColorPrice;
|
|
||||||
ecos.money = p.money;
|
|
||||||
ecos.totalSpent += Economy.Settings.TColorPrice;
|
|
||||||
ecos.purchase = "%3Titlecolor: " + args[2] + Colors.Name(args[2]) + "%3 - Price: %f" + Economy.Settings.TColorPrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
|
||||||
Economy.UpdateEcoStats(ecos);
|
|
||||||
Player.SendMessage(p, "%aYour titlecolor has been successfully changed to " + args[2] + Colors.Name(args[2]));
|
|
||||||
Player.SendMessage(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "titles":
|
|
||||||
case "title":
|
|
||||||
if (p.EnoughMoney(Economy.Settings.TitlePrice) == false) {
|
|
||||||
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a title");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args[3] != string.Empty) {
|
|
||||||
Player.SendMessage(p, "%cYour title cannot contain any spaces");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args[2] == p.title) {
|
|
||||||
Player.SendMessage(p, "%cYou already have that title");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args[2].Length > 17) {
|
|
||||||
Player.SendMessage(p, "%cTitles cannot be longer than 17 characters");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var regex = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z0-9-_\\.]*$");
|
|
||||||
if (!regex.IsMatch(args[2])) {
|
|
||||||
Player.SendMessage(p, "%cInvalid title! Titles may only contain alphanumeric characters and .-_");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bool free = false;
|
|
||||||
if (args[2] == null || args[2] == string.Empty || args[2] == "") {
|
|
||||||
args[2] = ""; //just an extra check to make sure it's good
|
|
||||||
free = true;
|
|
||||||
}
|
|
||||||
Command.all.Find("title").Use(null, p.name + " " + args[2]);
|
|
||||||
if (!free) {
|
|
||||||
p.money = p.money - Economy.Settings.TitlePrice;
|
|
||||||
ecos.money = p.money;
|
|
||||||
ecos.totalSpent += Economy.Settings.TitlePrice;
|
|
||||||
ecos.purchase = "%3Title: %f" + args[2] + "%3 - Price: %f" + Economy.Settings.TitlePrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
|
||||||
Economy.UpdateEcoStats(ecos);
|
|
||||||
Player.SendMessage(p, "%aYour title has been successfully changed to [" + p.titlecolor + args[2] + "%a]");
|
|
||||||
} else { Player.SendMessage(p, "%aYour title has been successfully removed for free"); }
|
|
||||||
Player.SendMessage(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "ranks":
|
|
||||||
case "rank":
|
|
||||||
if (args[2] != "" && args[2] != null && !string.IsNullOrEmpty(args[2]) && args[2] != string.Empty) {
|
|
||||||
Player.SendMessage(p, "%cYou cannot provide a rank name, use %a/eco buy rank %cto buy the NEXT rank.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LevelPermission maxrank = Group.Find(Economy.Settings.MaxRank).Permission;
|
|
||||||
if (p.group.Permission == maxrank || p.group.Permission >= maxrank) {
|
|
||||||
Player.SendMessage(p, "%cYou cannot buy anymore ranks, because you passed the max buyable rank: " + Group.Find(Economy.Settings.MaxRank).color + Economy.Settings.MaxRank);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if (!p.EnoughMoney(Economy.NextRank(p).price)) {
|
|
||||||
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy the next rank");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Command.all.Find("promote").Use(null, p.name);
|
|
||||||
p.money = p.money - Economy.FindRank(p.group.name).price;
|
|
||||||
ecos.money = p.money;
|
|
||||||
ecos.totalSpent += Economy.FindRank(p.group.name).price;
|
|
||||||
ecos.purchase = "%3Rank: " + p.group.color + p.group.name + "%3 - Price: %f" + Economy.FindRank(p.group.name).price + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
|
||||||
Economy.UpdateEcoStats(ecos);
|
|
||||||
Player.SendMessage(p, "%aYou've successfully bought the rank " + p.group.color + p.group.name);
|
|
||||||
Player.SendMessage(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
Player.SendMessage(p, "%cThat wasn't a valid command addition!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleStats(Player p, string message, string[] args) {
|
void HandleStats(Player p, string message, string[] args) {
|
||||||
Economy.EcoStats ecostats;
|
Economy.EcoStats ecostats;
|
||||||
if (p == null && args[1] == "") {
|
if (p == null && args[1] == "") {
|
||||||
@ -681,23 +453,20 @@ namespace MCGalaxy.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
string defaultcolor = Group.findPerm(defaultRank).color;
|
|
||||||
string othercolor = Group.findPermInt(CommandOtherPerms.GetPerm(this)).color;
|
|
||||||
Player.SendMessage(p, "%3===Welcome to the Economy Help Menu===");
|
Player.SendMessage(p, "%3===Welcome to the Economy Help Menu===");
|
||||||
Player.SendMessage(p, defaultcolor + "%f/eco buy <title/color/tcolor/rank/map> [%atitle/color/tcolor/map_preset%f] [%acustom_map_name%f] %e- to buy one of these features");
|
Player.SendMessage(p, "%f/eco stats [%aplayer%f] %e- view ecostats about yourself or [player]");
|
||||||
Player.SendMessage(p, defaultcolor + "%f/eco stats [%aplayer%f] %e- view ecostats about yourself or [player]");
|
Player.SendMessage(p, "%f/eco info <title/color/tcolor/rank/map> %e- view information about buying the specific feature");
|
||||||
Player.SendMessage(p, defaultcolor + "%f/eco info <title/color/tcolor/rank/map> %e- view information about buying the specific feature");
|
|
||||||
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) {
|
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) {
|
||||||
Player.SendMessage(p, othercolor + "%f/eco setup <type> %e- to setup economy");
|
Player.SendMessage(p, "%f/eco setup <type> %e- to setup economy");
|
||||||
Player.SendMessage(p, othercolor + "%f/eco help <buy/stats/info/setup> %e- get more specific help");
|
Player.SendMessage(p, "%f/eco help <buy/stats/info/setup> %e- get more specific help");
|
||||||
} else { Player.SendMessage(p, defaultcolor + "%f/eco help <buy/stats/info> %e- get more specific help"); }
|
} else { Player.SendMessage(p, "%f/eco help <buy/stats/info> %e- get more specific help"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupHelp(Player p) {
|
public void SetupHelp(Player p) {
|
||||||
Player.SendMessage(p, "%3===Economy Setup Help Menu===");
|
Player.SendMessage(p, "%3===Economy Setup Help Menu===");
|
||||||
if (p !=null && p.name == Server.server_owner) {
|
if (p == null || p.name == Server.server_owner) {
|
||||||
Player.SendMessage(p, "%4/eco setup apply %e- applies the changes made to 'economy.properties'");
|
Player.SendMessage(p, "%4/eco setup apply %e- applies the changes made to 'economy.properties'");
|
||||||
} else if (p == null) { Player.SendMessage(p, "%4/eco setup apply %e- applies the changes made to 'economy.properties'"); }
|
}
|
||||||
Player.SendMessage(p, "%4/eco setup [%aenable%4/%cdisable%4] %e- to enable/disable the economy system");
|
Player.SendMessage(p, "%4/eco setup [%aenable%4/%cdisable%4] %e- to enable/disable the economy system");
|
||||||
Player.SendMessage(p, "%4/eco setup [title/color/tcolor/rank/map] [%aenable%4/%cdisable%4] %e- to enable/disable that feature");
|
Player.SendMessage(p, "%4/eco setup [title/color/tcolor/rank/map] [%aenable%4/%cdisable%4] %e- to enable/disable that feature");
|
||||||
Player.SendMessage(p, "%4/eco setup [title/color/tcolor] [%3price%4] %e- to setup the prices for these features");
|
Player.SendMessage(p, "%4/eco setup [title/color/tcolor] [%3price%4] %e- to setup the prices for these features");
|
||||||
@ -708,7 +477,7 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.SendMessage(p, "%4/eco setup map edit [%fname%4] [name/x/y/z/type/price] [%fvalue%4] %e- to edit a map preset");
|
Player.SendMessage(p, "%4/eco setup map edit [%fname%4] [name/x/y/z/type/price] [%fvalue%4] %e- to edit a map preset");
|
||||||
}
|
}
|
||||||
|
|
||||||
static public bool isGood(string value) {
|
public static bool isGood(string value) {
|
||||||
ushort uvalue = ushort.Parse(value);
|
ushort uvalue = ushort.Parse(value);
|
||||||
switch (uvalue) {
|
switch (uvalue) {
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -1,102 +1,102 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 MCForge
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
not use this file except in compliance with the Licenses. You may
|
not use this file except in compliance with the Licenses. You may
|
||||||
obtain a copy of the Licenses at
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
http://www.opensource.org/licenses/ecl2.php
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
http://www.gnu.org/licenses/gpl-3.0.html
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the Licenses are distributed on an "AS IS"
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
{
|
{
|
||||||
public sealed class CmdTake : Command
|
public sealed class CmdTake : Command
|
||||||
{
|
{
|
||||||
public override string name { get { return "take"; } }
|
public override string name { get { return "take"; } }
|
||||||
public override string shortcut { get { return ""; } }
|
public override string shortcut { get { return ""; } }
|
||||||
public override string type { get { return CommandTypes.Other; } }
|
public override string type { get { return CommandTypes.Other; } }
|
||||||
public override bool museumUsable { get { return true; } }
|
public override bool museumUsable { get { return true; } }
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
||||||
public CmdTake() { }
|
public CmdTake() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message)
|
||||||
{
|
{
|
||||||
if (message.IndexOf(' ') == -1) { Help(p); return; }
|
if (message.IndexOf(' ') == -1) { Help(p); return; }
|
||||||
if (message.Split(' ').Length != 2) { Help(p); return; }
|
if (message.Split(' ').Length != 2) { Help(p); return; }
|
||||||
|
|
||||||
string user1 = "";
|
string user1 = "";
|
||||||
string user2 = "";
|
string user2 = "";
|
||||||
if (p == null) { user1 = "%f[ " + Server.DefaultColor + "Console%f]"; user2 = String.Format("{0}Console [&a{1}{0}]", Server.DefaultColor, Server.ZallState); } else { user1 = p.color + p.name; user2 = p.prefix + p.name; }
|
if (p == null) { user1 = "%f[ " + Server.DefaultColor + "Console%f]"; user2 = String.Format("{0}Console [&a{1}{0}]", Server.DefaultColor, Server.ZallState); } else { user1 = p.color + p.name; user2 = p.prefix + p.name; }
|
||||||
|
|
||||||
int amountTaken = 0;
|
int amountTaken = 0;
|
||||||
bool all = false;
|
bool all = false;
|
||||||
try { amountTaken = int.Parse(message.Split(' ')[1]); }
|
try { amountTaken = int.Parse(message.Split(' ')[1]); }
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
if (message.Split()[1].ToLower() != "all")
|
if (message.Split()[1].ToLower() != "all")
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "%cInvalid amount");
|
Player.SendMessage(p, "%cInvalid amount");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
all = true;
|
all = true;
|
||||||
}
|
}
|
||||||
if (amountTaken < 0) { Player.SendMessage(p, "%cYou can't take negative %3" + Server.moneys); return; }
|
if (amountTaken < 0) { Player.SendMessage(p, "%cYou can't take negative %3" + Server.moneys); return; }
|
||||||
|
|
||||||
|
|
||||||
Player who = PlayerInfo.Find(message.Split()[0]);
|
Player who = PlayerInfo.Find(message.Split()[0]);
|
||||||
Economy.EcoStats ecos;
|
Economy.EcoStats ecos;
|
||||||
if (who == null)
|
if (who == null)
|
||||||
{ //player is offline
|
{ //player is offline
|
||||||
OfflinePlayer off = PlayerInfo.FindOffline(message.Split()[0]);
|
OfflinePlayer off = PlayerInfo.FindOffline(message.Split()[0]);
|
||||||
if (off == null) { Player.SendMessage(p, "%cThe player %f" + message.Split()[0] + Server.DefaultColor + "(offline)%c does not exist or has never logged on to this server"); return; }
|
if (off == null) { Player.SendMessage(p, "%cThe player %f" + message.Split()[0] + Server.DefaultColor + "(offline)%c does not exist or has never logged on to this server"); return; }
|
||||||
ecos = Economy.RetrieveEcoStats(message.Split()[0]);
|
ecos = Economy.RetrieveEcoStats(message.Split()[0]);
|
||||||
if (all || ecos.money - amountTaken < 0)
|
if (all || ecos.money - amountTaken < 0)
|
||||||
{
|
{
|
||||||
amountTaken = ecos.money;
|
amountTaken = ecos.money;
|
||||||
ecos.money = 0;
|
ecos.money = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ecos.money -= amountTaken;
|
ecos.money -= amountTaken;
|
||||||
ecos.fine = "%f" + amountTaken + " %3" + Server.moneys + " by " + user1 + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
ecos.fine = "%f" + amountTaken + " %3" + Server.moneys + " by " + user1 + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
Economy.UpdateEcoStats(ecos);
|
Economy.UpdateEcoStats(ecos);
|
||||||
Player.GlobalMessage(user2 + Server.DefaultColor + " took %f" + amountTaken + " %3" + Server.moneys + Server.DefaultColor + " from " + off.color + off.name + "%f(offline)");
|
Player.GlobalMessage(user2 + Server.DefaultColor + " took %f" + amountTaken + " %3" + Server.moneys + Server.DefaultColor + " from " + off.color + off.name + "%f(offline)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ecos = Economy.RetrieveEcoStats(who.name);
|
ecos = Economy.RetrieveEcoStats(who.name);
|
||||||
if (who == p)
|
if (who == p)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "%cYou can't take %3" + Server.moneys + "%c from yourself");
|
Player.SendMessage(p, "%cYou can't take %3" + Server.moneys + "%c from yourself");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (all || ecos.money - amountTaken < 0)
|
if (all || ecos.money - amountTaken < 0)
|
||||||
{
|
{
|
||||||
amountTaken = who.money;
|
amountTaken = who.money;
|
||||||
who.money = 0;
|
who.money = 0;
|
||||||
ecos.money = 0;
|
ecos.money = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
who.money -= amountTaken;
|
who.money -= amountTaken;
|
||||||
ecos.money = who.money;
|
ecos.money = who.money;
|
||||||
}
|
}
|
||||||
ecos.fine = "%f" + amountTaken + " %3" + Server.moneys + " by " + user1 + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
ecos.fine = "%f" + amountTaken + " %3" + Server.moneys + " by " + user1 + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
|
||||||
Economy.UpdateEcoStats(ecos);
|
Economy.UpdateEcoStats(ecos);
|
||||||
Player.GlobalMessage(user2 + Server.DefaultColor + " took %f" + amountTaken + " %3" + Server.moneys + Server.DefaultColor + " from " + who.prefix + who.name);
|
Player.GlobalMessage(user2 + Server.DefaultColor + " took %f" + amountTaken + " %3" + Server.moneys + Server.DefaultColor + " from " + who.prefix + who.name);
|
||||||
}
|
}
|
||||||
public override void Help(Player p)
|
public override void Help(Player p)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "&f/take [player] <amount> " + Server.DefaultColor + "- Takes <amount> of " + Server.moneys + " from [player]");
|
Player.SendMessage(p, "&f/take [player] <amount> " + Server.DefaultColor + "- Takes <amount> of " + Server.moneys + " from [player]");
|
||||||
Player.SendMessage(p, "&f/take [player] all " + Server.DefaultColor + "- Takes all the " + Server.moneys + " from [player]");
|
Player.SendMessage(p, "&f/take [player] all " + Server.DefaultColor + "- Takes all the " + Server.moneys + " from [player]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -167,11 +167,13 @@
|
|||||||
<Compile Include="Commands\Economy\CmdAward.cs" />
|
<Compile Include="Commands\Economy\CmdAward.cs" />
|
||||||
<Compile Include="Commands\Economy\CmdAwardMod.cs" />
|
<Compile Include="Commands\Economy\CmdAwardMod.cs" />
|
||||||
<Compile Include="Commands\Economy\CmdAwards.cs" />
|
<Compile Include="Commands\Economy\CmdAwards.cs" />
|
||||||
|
<Compile Include="Commands\Economy\CmdBuy.cs" />
|
||||||
<Compile Include="Commands\Economy\CmdEconomy.cs" />
|
<Compile Include="Commands\Economy\CmdEconomy.cs" />
|
||||||
<Compile Include="Commands\Economy\CmdFakePay.cs" />
|
<Compile Include="Commands\Economy\CmdFakePay.cs" />
|
||||||
<Compile Include="Commands\Economy\CmdGive.cs" />
|
<Compile Include="Commands\Economy\CmdGive.cs" />
|
||||||
<Compile Include="Commands\Economy\CmdMoney.cs" />
|
<Compile Include="Commands\Economy\CmdMoney.cs" />
|
||||||
<Compile Include="Commands\Economy\CmdPay.cs" />
|
<Compile Include="Commands\Economy\CmdPay.cs" />
|
||||||
|
<Compile Include="Commands\Economy\CmdTake.cs" />
|
||||||
<Compile Include="Commands\Fun\Cmd8Ball.cs" />
|
<Compile Include="Commands\Fun\Cmd8Ball.cs" />
|
||||||
<Compile Include="Commands\Fun\CmdAka.cs" />
|
<Compile Include="Commands\Fun\CmdAka.cs" />
|
||||||
<Compile Include="Commands\Fun\CmdAlive.cs" />
|
<Compile Include="Commands\Fun\CmdAlive.cs" />
|
||||||
@ -348,7 +350,6 @@
|
|||||||
<Compile Include="Commands\Other\CmdSetPass.cs" />
|
<Compile Include="Commands\Other\CmdSetPass.cs" />
|
||||||
<Compile Include="Commands\Other\CmdSpawn.cs" />
|
<Compile Include="Commands\Other\CmdSpawn.cs" />
|
||||||
<Compile Include="Commands\Other\CmdSummon.cs" />
|
<Compile Include="Commands\Other\CmdSummon.cs" />
|
||||||
<Compile Include="Commands\Other\CmdTake.cs" />
|
|
||||||
<Compile Include="Commands\Other\CmdTColor.cs" />
|
<Compile Include="Commands\Other\CmdTColor.cs" />
|
||||||
<Compile Include="Commands\Other\CmdText.cs" />
|
<Compile Include="Commands\Other\CmdText.cs" />
|
||||||
<Compile Include="Commands\Other\CmdTimer.cs" />
|
<Compile Include="Commands\Other\CmdTimer.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user