public override bool Execute(IServerConnection server, IPlayer p, params string[] args) { string currentLine = String.Join(" ", args, 1, args.Length - 1); GroupCollection groups = CommandMatch(p, currentLine); if (groups == null) { p.Error(CommandUsage); return(false); } int howmany = 0; IPlayer target = null; if (!Int32.TryParse(groups["coins"].Value, out howmany)) { p.Message(CommandUsage); return(false); } target = server.AllPlayers.FindPlayerByNameOrID(groups["name"].Value, false); if ((target == null)) { p.Message("R:Error.TargetNotFound", groups["name"].Value); return(false); } if (p.zCoins < (howmany + CommandCost)) { p.Message("R:Error.NotEnoughCoins"); return(false); } p.AddCoins((-1) * howmany, "bounty on " + target.Name); p.Message("R:Cmd.Bounty.NewBounty", howmany, target.Name); target.AddBounty(howmany, "bounty by " + p.Name); return(true); }
public override bool ProcessLine(IServerConnection serverConnection, string currentLine) { if (rgDeath.IsMatch(currentLine)) { Match match = rgDeath.Match(currentLine); GroupCollection groups = match.Groups; IPlayer killer = serverConnection.AllPlayers.FindPlayerByNameOrID(groups["killer"].Value); IPlayer victim = serverConnection.AllPlayers.FindPlayerByNameOrID(groups["victim"].Value); if ((killer == null) || (victim == null)) { return(false); } if (killer == victim) { killer.AddCoins(-100, "Death"); killer.Message("You lost 100 coins."); } else { if (victim.Bounty != 0) { killer.CollectBounty(victim.Bounty, "Bounty on " + victim.Name); killer.Message("You collected the bounty of {0} coins set on {1}'s head.", victim.Bounty, victim.Name); victim.AddBounty((-1) * victim.Bounty, "collected by " + killer.Name); victim.Message("The bounty on your head has been cleared."); } else { if ((Program.Config.CoinPercentageOnKill > 0) && (victim.zCoins > 100)) { int howmuch = (int)((victim.zCoins * Program.Config.CoinPercentageOnKill) / 100.0); if (howmuch > 0) { killer.AddBloodCoins(howmuch, "Killed " + victim.Name); killer.Message("You took {0} coins from the dead body of {1}", howmuch, victim.Name); victim.AddCoins((-1) * howmuch, "Killed by " + killer.Name); victim.Message("{0} took {1} coins from your dead body.", killer.Name, howmuch); if (Program.Config.BountyFactor > 0) { killer.AddBounty((int)(howmuch * Program.Config.BountyFactor), "MDK " + victim.Name); } } } } } serverConnection.Execute("lp"); return(true); } return(false); }