public override void Use(Player p, string message, CommandData data) { EcoTransaction trans; bool all = false; if (!ParseArgs(p, message, ref all, "pay", out trans)) return; int matches = 1; Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches); if (matches > 1) return; if (p == who) { p.Message("You cannot pay yourself &3" + ServerConfig.Currency); return; } int money, srcMoney = p.IsSuper ? int.MaxValue : p.money; if (who == null) { trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money); if (trans.TargetName == null) return; if (!IsLegalPayment(p, srcMoney, money, trans.Amount)) return; money += trans.Amount; Economy.UpdateMoney(trans.TargetName, money); } else { trans.TargetName = who.name; money = who.money; if (!IsLegalPayment(p, srcMoney, money, trans.Amount)) return; who.SetMoney(who.money + trans.Amount); } trans.TargetFormatted = PlayerInfo.GetColoredName(p, trans.TargetName); trans.Type = EcoTransactionType.Payment; OnEcoTransactionEvent.Call(trans); }
public override void Use(Player p, string message, CommandData data) { EcoTransaction trans; bool all = false; if (!ParseArgs(p, message, ref all, "give", out trans)) { return; } int matches = 1; Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches); if (matches > 1) { return; } if (p == who) { p.Message("You cannot give yourself &3" + ServerConfig.Currency); return; } int money = 0; if (who == null) { trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money); if (trans.TargetName == null) { return; } if (ReachedMax(p, money, trans.Amount)) { return; } money += trans.Amount; Economy.UpdateMoney(trans.TargetName, money); } else { trans.TargetName = who.name; money = who.money; if (ReachedMax(p, money, trans.Amount)) { return; } who.SetMoney(who.money + trans.Amount); } trans.TargetFormatted = PlayerInfo.GetColoredName(p, trans.TargetName); trans.Type = EcoTransactionType.Give; OnEcoTransactionEvent.Call(trans); }
public override void Use(Player p, string message) { EcoTransaction data; bool all = false; if (!ParseArgs(p, message, ref all, "give", out data)) { return; } int matches = 1; Player who = PlayerInfo.FindMatches(p, data.TargetName, out matches); if (matches > 1) { return; } if (p != null && p == who) { Player.Message(p, "You cannot give yourself %3" + ServerConfig.Currency); return; } int money = 0; if (who == null) { data.TargetName = Economy.FindMatches(p, data.TargetName, out money); if (data.TargetName == null) { return; } if (ReachedMax(p, money, data.Amount)) { return; } money += data.Amount; Economy.UpdateMoney(data.TargetName, money); } else { data.TargetName = who.name; money = who.money; if (ReachedMax(p, money, data.Amount)) { return; } who.SetMoney(who.money + data.Amount); } data.TargetFormatted = PlayerInfo.GetColoredName(p, data.TargetName); data.Type = EcoTransactionType.Give; OnEcoTransactionEvent.Call(data); }
public static void MakePurchase(Player p, int cost, string item) { p.SetMoney(p.money - cost); EcoTransaction transaction = new EcoTransaction(); transaction.TargetName = p.name; transaction.TargetFormatted = p.ColoredName; transaction.Amount = cost; transaction.Type = EcoTransactionType.Purchase; transaction.ItemDescription = item; OnEcoTransactionEvent.Call(transaction); }
public override void Unload(bool shutdown) { OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect); OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand); OnChatEvent.Unregister(ChatHandler.HandleOnChat); OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting); OnSentMapEvent.Unregister(MiscHandlers.HandleOnMapSent); OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove); OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick); OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction); OnModActionEvent.Unregister(ModActionHandler.HandleModAction); Server.Background.Cancel(clearTask); }
public override void Load(bool startup) { OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical); OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical); OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical); OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical); OnSentMapEvent.Register(MiscHandlers.HandleOnMapSent, Priority.Critical); OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical); OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical); OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical); OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical); clearTask = Server.Background.QueueRepeat(IPThrottler.CleanupTask, null, TimeSpan.FromMinutes(10)); }
public override void Unload(bool shutdown) { OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect); OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand); OnChatEvent.Unregister(ChatHandler.HandleOnChat); OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting); OnSentMapEvent.Unregister(MiscHandlers.HandleSentMap); OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove); OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick); OnChangedZoneEvent.Unregister(MiscHandlers.HandleChangedZone); OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction); OnModActionEvent.Unregister(ModActionHandler.HandleModAction); }
public override void Load(bool startup) { OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical); OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical); OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical); OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical); OnSentMapEvent.Register(MiscHandlers.HandleSentMap, Priority.Critical); OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical); OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical); OnChangedZoneEvent.Register(MiscHandlers.HandleChangedZone, Priority.Critical); OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical); OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical); }
public override void Use(Player p, string message, CommandData data) { EcoTransaction trans; bool all = true; if (!ParseArgs(p, message, ref all, "take", out trans)) { return; } int matches = 1; Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches); if (matches > 1) { return; } if (p == who) { p.Message("%WYou cannot take &3" + Server.Config.Currency + " %Wfrom yourself"); return; } int money = 0; if (who == null) { trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money); if (trans.TargetName == null) { return; } Take(ref money, all, trans); Economy.UpdateMoney(trans.TargetName, money); } else { trans.TargetName = who.name; money = who.money; Take(ref money, all, trans); who.SetMoney(money); } trans.TargetFormatted = p.FormatNick(trans.TargetName); trans.Type = EcoTransactionType.Take; OnEcoTransactionEvent.Call(trans); }
public override void Use(Player p, string message) { EcoTransaction data; bool all = true; if (!ParseArgs(p, message, ref all, "take", out data)) { return; } int matches = 1; Player who = PlayerInfo.FindMatches(p, data.TargetName, out matches); if (matches > 1) { return; } if (p != null && p == who) { Player.Message(p, "%cYou can't take %3" + ServerConfig.Currency + "%c from yourself"); return; } int money = 0; if (who == null) { data.TargetName = Economy.FindMatches(p, data.TargetName, out money); if (data.TargetName == null) { return; } Take(ref money, all, data); Economy.UpdateMoney(data.TargetName, money); } else { data.TargetName = who.name; money = who.money; Take(ref money, all, data); who.SetMoney(money); } data.TargetFormatted = PlayerInfo.GetColoredName(p, data.TargetName); data.Type = EcoTransactionType.Take; OnEcoTransactionEvent.Call(data); }
public override void Use(Player p, string message, CommandData data) { EcoTransaction trans; bool all = true; if (!ParseArgs(p, message, ref all, "take", out trans)) { return; } int matches = 1; Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches); if (matches > 1) { return; } int money = 0; if (who == null) { trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money); if (trans.TargetName == null) { return; } Take(ref money, all, trans); Economy.UpdateMoney(trans.TargetName, money); } else { trans.TargetName = who.name; money = who.money; Take(ref money, all, trans); who.SetMoney(money); } trans.TargetFormatted = PlayerInfo.GetColoredName(p, trans.TargetName); trans.Type = EcoTransactionType.Take; OnEcoTransactionEvent.Call(trans); }
public override void Use(Player p, string message, CommandData data) { EcoTransaction trans; bool all = false; if (!ParseArgs(p, message, ref all, "pay", out trans)) { return; } // Player can use /pay messages to bypass a mute // TODO: Make MessageCmd.CanSpeak more generic so that can be used here instead if (trans.Reason != null && !p.CanSpeak()) { p.Message("%WCannot specify a payment reason, as you cannot currently speak"); return; } int matches = 1; Player who = PlayerInfo.FindMatches(p, trans.TargetName, out matches); if (matches > 1) { return; } if (p == who) { p.Message("%WYou cannot pay yourself &3" + Server.Config.Currency); return; } int money, srcMoney = p.IsSuper ? int.MaxValue : p.money; if (who == null) { trans.TargetName = Economy.FindMatches(p, trans.TargetName, out money); if (trans.TargetName == null) { return; } if (!IsLegalPayment(p, srcMoney, money, trans.Amount)) { return; } money += trans.Amount; Economy.UpdateMoney(trans.TargetName, money); } else { trans.TargetName = who.name; money = who.money; if (!IsLegalPayment(p, srcMoney, money, trans.Amount)) { return; } who.SetMoney(who.money + trans.Amount); } trans.TargetFormatted = PlayerInfo.GetColoredName(p, trans.TargetName); trans.Type = EcoTransactionType.Payment; OnEcoTransactionEvent.Call(trans); }