Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 50 additions & 65 deletions CommandBounty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,120 +9,105 @@ namespace Freenex.FeexHitman
{
public class CommandBounty : IRocketCommand
{
public string Name
{
get { return "bounty"; }
}
public string Name => "bounty";

public string Help
{
get { return "Add bounty to players"; }
}
public string Help => "Add bounty to players";

public string Syntax
{
get { return "<player> <amount>"; }
}
public string Syntax => "<player> <amount>";

public List<string> Aliases
{
get { return new List<string>(); }
}
public List<string> Aliases => new List<string>();

public AllowedCaller AllowedCaller
{
get { return AllowedCaller.Player; }
}
public AllowedCaller AllowedCaller => AllowedCaller.Player;

public List<string> Permissions
{
get
public List<string> Permissions =>
new List<string>()
{
return new List<string>()
{
"bounty"
};
}
}
"bounty"
};

public void Execute(IRocketPlayer caller, params string[] command)
{
if (command.Length == 2)
{
UnturnedPlayer otherPlayer = UnturnedPlayer.FromName(command[0]);
var otherPlayer = UnturnedPlayer.FromName(command[0]);

if (otherPlayer == null)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found") != "hitman_general_not_found")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found"));
}
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found") !=
"hitman_general_not_found")
UnturnedChat.Say(caller,
FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found"));
return;
}

if (caller.Id == otherPlayer.Id)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_self") != "hitman_add_self")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_self"));
}
UnturnedChat.Say(caller,
FeexHitman.Instance.Translations.Instance.Translate("hitman_add_self"));
return;
}

decimal bounty = 0;
if (!Decimal.TryParse(command[1], out bounty) || bounty <= 0)
if (!decimal.TryParse(command[1], out bounty) || bounty <= 0)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_amount") != "hitman_add_amount")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_amount"));
}
UnturnedChat.Say(caller,
FeexHitman.Instance.Translations.Instance.Translate("hitman_add_amount"));
return;
}

decimal myBalance = Uconomy.Instance.Database.GetBalance(caller.Id);
if ((myBalance - bounty) < 0)
var myBalance = Uconomy.Instance.Database.GetBalance(caller.Id);
if (myBalance - bounty < 0)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_balance") != "hitman_add_balance")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_balance"));
}
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_balance") !=
"hitman_add_balance")
UnturnedChat.Say(caller,
FeexHitman.Instance.Translations.Instance.Translate("hitman_add_balance"));
return;
}

if (bounty < FeexHitman.Instance.Configuration.Instance.MinimumBounty)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_minimum") != "hitman_add_minimum")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_minimum", FeexHitman.Instance.Configuration.Instance.MinimumBounty));
}
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_minimum") !=
"hitman_add_minimum")
UnturnedChat.Say(caller,
FeexHitman.Instance.Translations.Instance.Translate("hitman_add_minimum",
FeexHitman.Instance.Configuration.Instance.MinimumBounty));
return;
}

if (FeexHitman.Instance.FeexHitmanDatabase.CheckExists(otherPlayer.CSteamID))
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_increased") != "hitman_general_chat_increased")
{
UnturnedChat.Say(FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_increased", otherPlayer.CharacterName, bounty, Convert.ToDecimal(FeexHitman.Instance.FeexHitmanDatabase.GetBounty(otherPlayer.CSteamID)) + bounty), UnityEngine.Color.yellow);
}
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_increased") !=
"hitman_general_chat_increased")
UnturnedChat.Say(
FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_increased",
otherPlayer.CharacterName, bounty,
Convert.ToDecimal(
FeexHitman.Instance.FeexHitmanDatabase.GetBounty(otherPlayer.CSteamID)) + bounty),
UnityEngine.Color.yellow);
}
else
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_created") != "hitman_general_chat_created")
{
UnturnedChat.Say(FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_created", otherPlayer.CharacterName, bounty), UnityEngine.Color.yellow);
}
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_created") !=
"hitman_general_chat_created")
UnturnedChat.Say(
FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_created",
otherPlayer.CharacterName, bounty), UnityEngine.Color.yellow);
}

Uconomy.Instance.Database.IncreaseBalance(caller.Id.ToString(), -bounty);
FeexHitman.Instance.FeexHitmanDatabase.AddUpdateVictimAccount(otherPlayer.CSteamID, bounty, otherPlayer.CharacterName);
FeexHitman.Instance.FeexHitmanDatabase.AddUpdateVictimAccount(otherPlayer.CSteamID, bounty,
otherPlayer.CharacterName);
}
else
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_invalid_parameter") != "hitman_general_invalid_parameter")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_general_invalid_parameter"));
}
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_invalid_parameter") !=
"hitman_general_invalid_parameter")
UnturnedChat.Say(caller,
FeexHitman.Instance.Translations.Instance.Translate("hitman_general_invalid_parameter"));
}
}
}
}
}
Loading