Finish the Economy database rewrite.

This commit is contained in:
UnknownShadow200 2016-09-02 20:26:33 +10:00
parent a204527ebb
commit 96db138a35
9 changed files with 246 additions and 218 deletions

View File

@ -29,40 +29,42 @@ namespace MCGalaxy.Commands {
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
public override void Use(Player p, string message) {
Economy.EcoStats ecos;
if (CheckSuper(p, message, "player name")) return;
if (!ValidName(p, message, "player")) return;
int matches = 1;
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message, out matches);
if (matches > 1) return;
if (matches == 0) {
string dbName = PlayerInfo.FindOfflineNameMatches(p, message);
if (dbName == null) return;
ecos = Economy.RetrieveEcoStats(dbName);
Player.Message(p, "%3===Economy stats for: %f" + ecos.playerName + "%7(offline)%3===");
} else {
ecos = Economy.RetrieveEcoStats(who.name);
Player.Message(p, "%3===Economy stats for: " + who.color + who.name + "%3===");
}
Player.Message(p, "Current balance: %f" + ecos.money + " %3" + Server.moneys);
Player.Message(p, "Total spent: %f" + ecos.totalSpent + " %3" + Server.moneys);
if (!(String.IsNullOrEmpty(ecos.purchase) || ecos.purchase == "%cNone"))
Player.Message(p, "Last purchase: " + ecos.purchase);
if (!(String.IsNullOrEmpty(ecos.payment) || ecos.payment == "%cNone"))
Player.Message(p, "Last payment: " + ecos.payment);
if (!(String.IsNullOrEmpty(ecos.salary) || ecos.salary == "%cNone"))
Player.Message(p, "Last receipt: " + ecos.salary);
if (!(String.IsNullOrEmpty(ecos.fine) || ecos.fine == "%cNone"))
Player.Message(p, "Last fine: " + ecos.fine);
string target = null;
int money = 0;
if (matches == 0) {
target = Economy.FindMatches(p, message, out money);
if (target == null) return;
} else {
target = who.name; money = who.money;
}
string targetName = PlayerInfo.GetColoredName(p, target);
Chat.MessageAll("Economy stats for {0}%S:", targetName);
Player.Message(p, " Current balance: &f{0} &3{1}", money, Server.moneys);
Economy.EcoStats ecos = Economy.RetrieveStats(target);
Player.Message(p, " Total spent: &f" + ecos.TotalSpent + " &3" + Server.moneys);
if (!(String.IsNullOrEmpty(ecos.Purchase) || ecos.Purchase == "%cNone"))
Player.Message(p, " Last purchase: " + ecos.Purchase);
if (!(String.IsNullOrEmpty(ecos.Payment) || ecos.Payment == "%cNone"))
Player.Message(p, " Last payment: " + ecos.Payment);
if (!(String.IsNullOrEmpty(ecos.Salary) || ecos.Salary == "%cNone"))
Player.Message(p, " Last receipt: " + ecos.Salary);
if (!(String.IsNullOrEmpty(ecos.Fine) || ecos.Fine == "%cNone"))
Player.Message(p, " Last fine: " + ecos.Fine);
}
public override void Help(Player p) {
Player.Message(p, "%T/balance <player>");
Player.Message(p, "%T/balance [player]");
Player.Message(p, "%HShows how much %3" + Server.moneys + " %H<player> has, " +
"plus their most recent transactions.");
Player.Message(p, "%HIf <player> is not given, shows your own balance.");
Player.Message(p, "%HIf [player] is not given, shows your own balance.");
}
}
}

View File

@ -15,36 +15,24 @@
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
namespace MCGalaxy.Commands {
public sealed class CmdFakePay : Command {
namespace MCGalaxy.Commands {
public sealed class CmdFakePay : MoneyCmd {
public override string name { get { return "fakepay"; } }
public override string shortcut { get { return "fpay"; } }
public override string type { get { return CommandTypes.Economy; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
string[] args = message.Split(' ');
Player who = PlayerInfo.FindMatches(p, args[0]);
if (who == null) return;
int amount = 0;
if (args.Length == 1 || !int.TryParse(args[1], out amount)) {
Player.Message(p, "You must specify an integer amount to fakepay."); return;
}
if (amount < 0) { Player.Message(p, "You can't fakepay a negative amount."); return; }
if (amount >= 16777215) { Player.Message(p, "You can only fakepay up to 16777215."); return; }
MoneyCmdData data;
if (!ParseArgs(p, message, false, "fakepay", out data)) return;
Player who = PlayerInfo.FindMatches(p, data.Name);
if (who == null) return;
if (data.Amount >= 16777215) { Player.Message(p, "You can only fakepay up to 16777215."); return; }
Chat.MessageAll("{0} %Swas given {1} {2}", who.ColoredName, amount, Server.moneys);
Chat.MessageAll("{0} %Swas given {1} {2}", who.ColoredName, data.Amount, Server.moneys);
}
public override void Help(Player p) {
Player.Message(p, "%T/fakepay <name> <amount>");
Player.Message(p, "%T/fakepay [name] [amount]");
Player.Message(p, "%HSends a fake give change message.");
}
}

View File

@ -17,58 +17,45 @@
*/
using System;
using System.Globalization;
namespace MCGalaxy.Commands
{
public sealed class CmdGive : Command
{
namespace MCGalaxy.Commands {
public sealed class CmdGive : MoneyCmd {
public override string name { get { return "give"; } }
public override string shortcut { get { return "gib"; } }
public override string type { get { return CommandTypes.Economy; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public CmdGive() { }
public override void Use(Player p, string message) {
string[] args = message.Split(' ');
if (args.Length != 2) { Help(p); return; }
string giver = null, giverRaw = null;
if (p == null) { giverRaw = "(console)"; giver = "(console)"; }
else { giverRaw = p.color + p.name; giver = p.ColoredName; }
int amount;
if (!int.TryParse(args[1], out amount)) {
Player.Message(p, "Amount must be an integer."); return;
}
if (amount < 0) { Player.Message(p, "Cannot give negative %3" + Server.moneys); return; }
MoneyCmdData data;
if (!ParseArgs(p, message, false, "give", out data)) return;
int matches = 1;
Player who = PlayerInfo.FindMatches(p, args[0], out matches);
Player who = PlayerInfo.FindMatches(p, data.Name, out matches);
if (matches > 1) return;
if (p != null && p == who) { Player.Message(p, "You cannot give yourself %3" + Server.moneys); return; }
Economy.EcoStats ecos;
string target = null;
int money = 0;
if (who == null) {
string dbName = PlayerInfo.FindOfflineNameMatches(p, args[0]);
if (dbName == null) return;
target = Economy.FindMatches(p, data.Name, out money);
if (target == null) return;
ecos = Economy.RetrieveEcoStats(dbName);
if (ReachedMax(p, ecos.money, amount)) return;
Chat.MessageAll("{0} %Sgave &f{1}%S(offline) &f{2} &3{3}",
giver, ecos.playerName, amount, Server.moneys);
if (ReachedMax(p, money, data.Amount)) return;
money += data.Amount;
Economy.UpdateMoney(target, money);
} else {
if (ReachedMax(p, who.money, amount)) return;
ecos.money = who.money;
who.SetMoney(who.money + amount);
ecos = Economy.RetrieveEcoStats(who.name);
Chat.MessageAll("{0} %Sgave {1} &f{2} &3{3}",
giver, who.ColoredName, amount, Server.moneys);
target = who.name; money = who.money;
if (ReachedMax(p, money, data.Amount)) return;
who.SetMoney(who.money + data.Amount);
}
string targetName = PlayerInfo.GetColoredName(p, target);
Chat.MessageAll("{0} %Sgave {1} &f{2} &3{3}",
data.Source, targetName, data.Amount, Server.moneys);
ecos.money += amount;
ecos.salary = "%f" + amount + "%3 " + Server.moneys + " by " +
giverRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateEcoStats(ecos);
Economy.EcoStats stats = Economy.RetrieveStats(target);
stats.Salary = "%f" + data.Amount + "%3 " + Server.moneys + " by "
+ data.SourceRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateStats(stats);
}
static bool ReachedMax(Player p, int current, int amount) {

View File

@ -17,62 +17,52 @@
*/
using System;
using System.Globalization;
namespace MCGalaxy.Commands
{
public sealed class CmdPay : Command
{
namespace MCGalaxy.Commands {
public sealed class CmdPay : MoneyCmd {
public override string name { get { return "pay"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Economy; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public CmdPay() { }
public override void Use(Player p, string message) {
string[] args = message.Split(' ');
if (args.Length != 2) { Help(p); return; }
int amount;
if (!int.TryParse(args[1], out amount)) { Player.Message(p, "Amount must be an integer."); return; }
if (amount < 0) { Player.Message(p, "Cannot pay negative %3" + Server.moneys); return; }
MoneyCmdData data;
if (!ParseArgs(p, message, false, "pay", out data)) return;
int matches = 1;
Player who = PlayerInfo.FindMatches(p, args[0], out matches);
Player who = PlayerInfo.FindMatches(p, data.Name, out matches);
if (matches > 1) return;
if (p != null && p == who) { Player.Message(p, "You cannot pay yourself %3" + Server.moneys); return; }
string target = null;
Economy.EcoStats payer, receiver;
int money;
if (who == null) {
string dbName = PlayerInfo.FindOfflineNameMatches(p, args[0]);
if (dbName == null) return;
target = Economy.FindMatches(p, data.Name, out money);
if (target == null) return;
payer = Economy.RetrieveEcoStats(p.name);
receiver = Economy.RetrieveEcoStats(dbName);
if (!IsLegalPayment(p, payer.money, receiver.money, amount)) return;
target = receiver.playerName;
Chat.MessageAll("{0} %Spaid &f{1}%S(offline) &f{2} &3{3}",
p.ColoredName, receiver.playerName, amount, Server.moneys);
if (!IsLegalPayment(p, p.money, money, data.Amount)) return;
money += data.Amount;
Economy.UpdateMoney(target, money);
} else {
payer = Economy.RetrieveEcoStats(p.name);
receiver = Economy.RetrieveEcoStats(who.name);
if (!IsLegalPayment(p, payer.money, receiver.money, amount)) return;
receiver.money = who.money;
who.SetMoney(who.money + amount);
target = who.color + who.name;
Chat.MessageAll("{0} %Spaid {1} &f{2} &3{3}",
p.ColoredName, who.ColoredName, amount, Server.moneys);
target = who.name; money = who.money;
if (!IsLegalPayment(p, p.money, money, data.Amount)) return;
who.SetMoney(who.money + data.Amount);
}
p.SetMoney(p.money - data.Amount);
string targetName = PlayerInfo.GetColoredName(p, target);
Chat.MessageAll("{0} %Spaid {1} &f{2} &3{3}",
data.Source, targetName, data.Amount, Server.moneys);
payer.payment = "%f" + amount + " %3" + Server.moneys + " to " + target + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
receiver.salary = "%f" + amount + " %3" + Server.moneys + " by " + p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
receiver.money += amount;
p.SetMoney(p.money - amount);
payer.money = p.money;
Economy.UpdateEcoStats(payer);
Economy.UpdateEcoStats(receiver);
Economy.EcoStats stats = Economy.RetrieveStats(p.name);
stats.Payment = "%f" + data.Amount + " %3" + Server.moneys + " to "
+ target + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateStats(stats);
stats = Economy.RetrieveStats(target);
stats.Salary = "%f" + data.Amount + " %3" + Server.moneys + " by "
+ p.color + p.name + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateStats(stats);
}
bool IsLegalPayment(Player p, int payer, int receiver, int amount) {
@ -83,7 +73,7 @@ namespace MCGalaxy.Commands
public override void Help(Player p) {
Player.Message(p, "%T/pay [player] [amount] ");
Player.Message(p, "%HPays <amount> %3" + Server.moneys + " %Hto [player]");
Player.Message(p, "%HPays [amount] &3" + Server.moneys + " %Hto [player]");
}
}
}

View File

@ -19,70 +19,58 @@ using System;
using System.Globalization;
namespace MCGalaxy.Commands {
public sealed class CmdTake : Command {
public sealed class CmdTake : MoneyCmd {
public override string name { get { return "take"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Economy; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public CmdTake() { }
public override void Use(Player p, string message) {
string[] args = message.Split(' ');
if (args.Length != 2) { Help(p); return; }
string taker = null, takerRaw = null;
if (p == null) { takerRaw = "(console)"; taker = "(console)"; }
else { takerRaw = p.color + p.name; taker = p.ColoredName; }
int amount = 0;
bool all = args[1].CaselessEq("all");
if (!all && !int.TryParse(args[1], out amount)) {
Player.Message(p, "Amount must be an integer."); return;
}
if (amount < 0) { Player.Message(p, "%cYou can't take negative %3" + Server.moneys); return; }
MoneyCmdData data;
if (!ParseArgs(p, message, true, "take", out data)) return;
int matches = 1;
Player who = PlayerInfo.FindMatches(p, args[0], out matches);
Player who = PlayerInfo.FindMatches(p, data.Name, out matches);
if (matches > 1) return;
if (p != null && p == who) { Player.Message(p, "%cYou can't take %3" + Server.moneys + "%c from yourself"); return; }
Economy.EcoStats ecos;
string target = null;
int money = 0;
if (who == null) {
string dbName = PlayerInfo.FindOfflineNameMatches(p, args[0]);
if (dbName == null) return;
ecos = Economy.RetrieveEcoStats(dbName);
Take(all, ref ecos, ref amount);
Chat.MessageAll("{0} %Stook &f{2} &3{3} %Sfrom &f{1}%S(offline)",
p.ColoredName, ecos.playerName, amount, Server.moneys);
target = Economy.FindMatches(p, data.Name, out money);
if (target == null) return;
Take(ref money, ref data);
Economy.UpdateMoney(target, money);
} else {
ecos = Economy.RetrieveEcoStats(who.name);
ecos.money = who.money;
Take(all, ref ecos, ref amount);
who.SetMoney(ecos.money);
Chat.MessageAll("{0} %Stook &f{2} &3{3} %Sfrom {1}",
p.ColoredName, who.ColoredName, amount, Server.moneys);
target = who.name; money = who.money;
Take(ref money, ref data);
who.SetMoney(money);
}
ecos.fine = "%f" + amount + " %3" + Server.moneys + " by " + takerRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateEcoStats(ecos);
string targetName = PlayerInfo.GetColoredName(p, target);
Chat.MessageAll("{0} %Stook &f{2} &3{3} %Sfrom {1}",
data.Source, targetName, data.Amount, Server.moneys);
Economy.EcoStats stats = Economy.RetrieveStats(target);
stats.Fine = "%f" + data.Amount + "%3 " + Server.moneys + " by "
+ data.SourceRaw + "%3 on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateStats(stats);
}
static void Take(bool all, ref Economy.EcoStats ecos, ref int amount) {
if (all || ecos.money < amount) {
amount = ecos.money;
ecos.money = 0;
static void Take(ref int money, ref MoneyCmdData data) {
if (data.All || money < data.Amount) {
data.Amount = money;
money = 0;
} else {
ecos.money -= amount;
money -= data.Amount;
}
}
public override void Help(Player p){
Player.Message(p, "%T/take [player] <amount>");
Player.Message(p, "%HTakes <amount> of " + Server.moneys + " from [player]");
Player.Message(p, "%T/take [player] [amount[");
Player.Message(p, "%HTakes [amount] of &3" + Server.moneys + " %Sfrom [player]");
Player.Message(p, "%T/take [player] all");
Player.Message(p, "%HTakes all the " + Server.moneys + " from [player]");
Player.Message(p, "%HTakes all the &3" + Server.moneys + " %Sfrom [player]");
}
}
}

View File

@ -0,0 +1,58 @@
/*
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;
namespace MCGalaxy.Commands {
public abstract class MoneyCmd : Command {
public override string type { get { return CommandTypes.Economy; } }
public override bool museumUsable { get { return true; } }
public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
protected bool ParseArgs(Player p, string message, bool canAll,
string action, out MoneyCmdData data) {
data = default(MoneyCmdData);
string[] args = message.Split(' ');
if (args.Length != 2) { Help(p); return false; }
data.Name = args[0];
if (p == null) {
data.SourceRaw = "(console)"; data.Source = "(console)";
} else {
data.SourceRaw = p.color + p.name; data.Source = p.ColoredName;
}
int amount = 0;
data.All = canAll && args[1].CaselessEq("all");
if (!data.All && !int.TryParse(args[1], out amount)) {
Player.Message(p, "Amount to {0} must be an integer.", action); return false;
}
if (amount < 0) {
Player.Message(p, "You cannot {0} negative &3" + Server.moneys, action); return false;
}
data.Amount = amount;
return true;
}
protected struct MoneyCmdData {
public string Source, SourceRaw, Name;
public int Amount;
public bool All;
}
}
}

View File

@ -41,28 +41,37 @@ PRIMARY KEY(player)
);";
public struct EcoStats {
public string playerName, purchase, payment, salary, fine;
public int money, totalSpent;
public EcoStats(string name, int mon, int tot, string pur, string pay, string sal, string fin) {
playerName = name;
money = mon;
totalSpent = tot;
purchase = pur;
payment = pay;
salary = sal;
fine = fin;
public string Player, Purchase, Payment, Salary, Fine;
public int TotalSpent;
public EcoStats(int tot, string player, string pur,
string pay, string sal, string fin) {
TotalSpent = tot;
Player = player;
Purchase = pur;
Payment = pay;
Salary = sal;
Fine = fin;
}
}
public static void LoadDatabase() {
Database.Execute(createTable);
DataTable eco = Database.Fill("SELECT (player, money) FROM Economy");
foreach (DataRow row in eco) {
DataTable eco = Database.Fill("SELECT * FROM Economy");
foreach (DataRow row in eco.Rows) {
int money = PlayerData.ParseInt(row["money"].ToString());
if (money == 0) continue;
UpdateMoney(row["player"].ToString(), money);
// TODO: remove zero money in Economy table
EcoStats stats;
stats.Player = row["player"].ToString();
stats.Payment = row["payment"].ToString();
stats.Purchase = row["purchase"].ToString();
stats.Salary = row["salary"].ToString();
stats.Fine = row["fine"].ToString();
stats.TotalSpent = PlayerData.ParseInt(row["total"].ToString());
UpdateMoney(stats.Player, money);
UpdateStats(stats);
}
}
@ -110,38 +119,43 @@ PRIMARY KEY(player)
}
}
}
public static EcoStats RetrieveEcoStats(string playername) {
EcoStats es = default(EcoStats);
es.playerName = playername;
using (DataTable eco = Database.Fill("SELECT * FROM Economy WHERE player=@0", playername)) {
if (eco.Rows.Count >= 1) {
es.money = int.Parse(eco.Rows[0]["money"].ToString());
es.totalSpent = int.Parse(eco.Rows[0]["total"].ToString());
es.purchase = eco.Rows[0]["purchase"].ToString();
es.payment = eco.Rows[0]["payment"].ToString();
es.salary = eco.Rows[0]["salary"].ToString();
es.fine = eco.Rows[0]["fine"].ToString();
} else {
es.purchase = "%cNone";
es.payment = "%cNone";
es.salary = "%cNone";
es.fine = "%cNone";
}
}
return es;
}
public static void UpdateEcoStats(EcoStats es) {
public static void UpdateStats(EcoStats stats) {
string type = Server.useMySQL ? "REPLACE INTO" : "INSERT OR REPLACE INTO";
Database.Execute(type + " Economy (player, money, total, purchase, payment, salary, fine) " +
"VALUES (@0, @1, @2, @3, @4, @5, @6)", es.playerName, es.money, es.totalSpent,
es.purchase, es.payment, es.salary, es.fine);
UpdateMoney(es.playerName, es.money);
"VALUES (@0, @1, @2, @3, @4, @5, @6)", stats.Player, 0, stats.TotalSpent,
stats.Purchase, stats.Payment, stats.Salary, stats.Fine);
}
public static EcoStats RetrieveStats(string name) {
EcoStats stats = default(EcoStats);
stats.Player = name;
using (DataTable eco = Database.Fill("SELECT * FROM Economy WHERE player=@0", name)) {
if (eco.Rows.Count > 0) {
stats.TotalSpent = int.Parse(eco.Rows[0]["total"].ToString());
stats.Purchase = eco.Rows[0]["purchase"].ToString();
stats.Payment = eco.Rows[0]["payment"].ToString();
stats.Salary = eco.Rows[0]["salary"].ToString();
stats.Fine = eco.Rows[0]["fine"].ToString();
} else {
stats.Purchase = "%cNone";
stats.Payment = "%cNone";
stats.Salary = "%cNone";
stats.Fine = "%cNone";
}
}
return stats;
}
public static string FindMatches(Player p, string name, out int money) {
DataRow row = PlayerInfo.QueryMulti(p, name, "Name, Money");
money = row == null ? 0 : PlayerData.ParseInt(row["Money"].ToString());
return row == null ? null : row["Name"].ToString();
}
public static void UpdateMoney(string name, int money) {
Database.Execute("UPDATE Players SET Money=@0 WHERE Name=@1", name, money);
Database.Execute("UPDATE Players SET Money=@0 WHERE Name=@1", money, name);
}
public static Item[] Items = { new ColorItem(), new TitleColorItem(),
@ -172,15 +186,15 @@ PRIMARY KEY(player)
public static RankItem Ranks { get { return (RankItem)Items[3]; } }
public static LevelItem Levels { get { return (LevelItem)Items[4]; } }
public static void MakePurchase(Player p, int cost, string item) {
Economy.EcoStats ecos = RetrieveEcoStats(p.name);
public static void MakePurchase(Player p, int cost, string item) {
p.SetMoney(p.money - cost);
ecos.money = p.money;
ecos.totalSpent += cost;
ecos.purchase = item + "%3 - Price: %f" + cost + " %3" + Server.moneys +
" - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
UpdateEcoStats(ecos);
Player.Message(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
Player.Message(p, "Your balance is now &f{0} &3{1}", p.money, Server.moneys);
Economy.EcoStats stats = RetrieveStats(p.name);
stats.TotalSpent += cost;
stats.Purchase = item + "%3 for %f" + cost + " %3" + Server.moneys +
" on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateStats(stats);
}
}
}

View File

@ -216,6 +216,7 @@
<Compile Include="Commands\Economy\CmdPay.cs" />
<Compile Include="Commands\Economy\CmdStore.cs" />
<Compile Include="Commands\Economy\CmdTake.cs" />
<Compile Include="Commands\Economy\MoneyCmd.cs" />
<Compile Include="Commands\Fun\Cmd8Ball.cs" />
<Compile Include="Commands\Fun\CmdAka.cs" />
<Compile Include="Commands\Fun\CmdCountdown.cs" />

View File

@ -180,14 +180,14 @@ namespace MCGalaxy {
}
static DataTable Query(string name, string selector) {
internal static DataTable Query(string name, string selector) {
string syntax = Server.useMySQL ?
"SELECT " + selector + " FROM Players WHERE Name=@0 COLLATE utf8_general_ci" :
"SELECT " + selector + " FROM Players WHERE Name=@0 COLLATE NOCASE";
return Database.Fill(syntax, name);
}
static DataRow QueryMulti(Player p, string name, string selector) {
internal static DataRow QueryMulti(Player p, string name, string selector) {
string syntax = Server.useMySQL ?
"SELECT " + selector + " FROM Players WHERE Name LIKE @0 LIMIT 21" :
"SELECT " + selector + " FROM Players WHERE Name LIKE @0 LIMIT 21 COLLATE NOCASE";