static void HandleGive(EcoTransaction data) { MessageAll("{0} %Sgave {1} &f{2} &3{3}{4}", data); Economy.EcoStats stats = Economy.RetrieveStats(data.TargetName); stats.Salary = Format(" by " + data.Source.name, data); Economy.UpdateStats(stats); }
public override void Use(Player p, string message) { bool emptyMessage = message == "" || message == null || message == string.Empty; if (p != null && emptyMessage) { Player.SendMessage(p, "You currently have %f" + p.money + " %3" + Server.moneys); } else if (message.Split().Length == 1) { Player who = Player.Find(message); if (who == null) { Economy.EcoStats ecos = Economy.RetrieveEcoStats(message); Player.SendMessage(p, ecos.playerName + "(%foffline" + Server.DefaultColor + ") currently has %f" + ecos.money + " %3" + Server.moneys); } //you can see everyone's stats with /eco stats [player] /*if (who.group.Permission >= p.group.Permission) { * Player.SendMessage(p, "%cCannot see the money of someone of equal or greater rank."); * return; * }*/ Player.SendMessage(p, who.color + who.name + Server.DefaultColor + " currently has %f" + who.money + " %3" + Server.moneys); } else if (p == null && emptyMessage) { Player.SendMessage(p, "%Console can't have %3" + Server.moneys); } else { Player.SendMessage(p, "%cInvalid parameters!"); Help(p); } }
static void HandleTake(EcoTransaction data) { MessageAll("{0} %Stook &f{2} &3{3} %Sfrom {1}{4}", data); Economy.EcoStats stats = Economy.RetrieveStats(data.TargetName); stats.Fine = Format(" by " + data.Source.name, data); Economy.UpdateStats(stats); }
public override void Use(Player p, string message) { MoneyCmdData data; if (!ParseArgs(p, message, false, "give", out data)) { return; } int matches = 1; 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; } string target = null; int money = 0; if (who == null) { target = Economy.FindMatches(p, data.Name, out money); if (target == null) { return; } if (ReachedMax(p, money, data.Amount)) { return; } money += data.Amount; Economy.UpdateMoney(target, money); } else { target = who.name; money = who.money; if (ReachedMax(p, money, data.Amount)) { return; } who.SetMoney(who.money + data.Amount); } MessageAll(p, "{0} %Sgave {1} &f{2} &3{3}{4}", target, data); Economy.EcoStats stats = Economy.RetrieveStats(target); stats.Salary = Format(p, " by " + data.SourceRaw, data); 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; } else { ecos.money -= amount; } }
public override void Use(Player p, string message, CommandData data) { if (CheckSuper(p, message, "player name")) { return; } if (message.Length == 0) { message = p.name; } if (!Formatter.ValidName(p, message, "player")) { return; } int matches = 1; Player who = PlayerInfo.FindMatches(p, message, out matches); if (matches > 1) { return; } 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 = p.FormatNick(target); p.Message("Economy stats for {0}%S:", targetName); p.Message(" Current balance: &f{0} &3{1}", money, Server.Config.Currency); Economy.EcoStats ecos = Economy.RetrieveStats(target); p.Message(" Total spent: &f" + ecos.TotalSpent + " &3" + Server.Config.Currency); Output(p, ecos.Purchase, "purchase"); Output(p, ecos.Payment, "payment"); Output(p, ecos.Salary, "receipt"); Output(p, ecos.Fine, "fine"); }
static void HandlePurchase(EcoTransaction data) { Economy.EcoStats stats = Economy.RetrieveStats(data.TargetName); stats.TotalSpent += data.Amount; stats.Purchase = data.ItemDescription + "%3 for %f" + data.Amount + " %3" + ServerConfig.Currency + " on %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture); Player p = PlayerInfo.FindExact(data.TargetName); if (p != null) { p.Message("Your balance is now &f{0} &3{1}", p.money, ServerConfig.Currency); } Economy.UpdateStats(stats); }
static void HandlePayment(EcoTransaction data) { MessageAll("{0} %Spaid {1} &f{2} &3{3}{4}", data); Economy.EcoStats stats = Economy.RetrieveStats(data.TargetName); stats.Salary = Format(" by " + data.Source.name, data); Economy.UpdateStats(stats); if (data.Source.IsSuper) { return; } stats = Economy.RetrieveStats(data.Source.name); stats.Payment = Format(" to " + data.TargetName, data); Economy.UpdateStats(stats); data.Source.SetMoney(data.Source.money - data.Amount); }
public override void Use(Player p, string message) { MoneyCmdData data; if (!ParseArgs(p, message, true, "take", out data)) { return; } int matches = 1; 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; } string target = null; int money = 0; if (who == null) { target = Economy.FindMatches(p, data.Name, out money); if (target == null) { return; } Take(ref money, ref data); Economy.UpdateMoney(target, money); } else { target = who.name; money = who.money; Take(ref money, ref data); who.SetMoney(money); } MessageAll(p, "{0} %Stook &f{2} &3{3} %Sfrom {1}{4}", target, data); Economy.EcoStats stats = Economy.RetrieveStats(target); stats.Fine = Format(p, " by " + data.SourceRaw, data); Economy.UpdateStats(stats); }
public override void Use(Player p, string message) { MoneyCmdData data; if (!ParseArgs(p, message, false, "pay", out data)) { return; } int matches = 1; 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; int money, srcMoney = Player.IsSuper(p) ? int.MaxValue : p.money; if (who == null) { target = Economy.FindMatches(p, data.Name, out money); if (target == null) { return; } if (!IsLegalPayment(p, srcMoney, money, data.Amount)) { return; } money += data.Amount; Economy.UpdateMoney(target, money); } else { target = who.name; money = who.money; if (!IsLegalPayment(p, srcMoney, money, data.Amount)) { return; } who.SetMoney(who.money + data.Amount); } if (!Player.IsSuper(p)) { p.SetMoney(p.money - data.Amount); } MessageAll(p, "{0} %Spaid {1} &f{2} &3{3}{4}", target, data); Economy.EcoStats stats = Economy.RetrieveStats(target); stats.Salary = Format(p, " by " + data.SourceRaw, data); Economy.UpdateStats(stats); if (Player.IsSuper(p)) { return; } stats = Economy.RetrieveStats(p.name); string targetName = PlayerInfo.GetColoredName(p, target); stats.Payment = Format(p, " to " + targetName, data); Economy.UpdateStats(stats); }