Advertisement
Guest User

Untitled

a guest
Sep 18th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. using Rocket.API;
  2. using Rocket.Core.Logging;
  3. using Rocket.Unturned.Chat;
  4. using Rocket.Unturned.Player;
  5. using Rocket.Unturned.Commands;
  6. using SDG;
  7. using SDG.Unturned;
  8. using Steamworks;
  9. using System.Collections.Generic;
  10. using Rocket.Core.Steam;
  11. using UnityEngine;
  12.  
  13. namespace rawrfuls.ThePunisher
  14. {
  15. public class CommandReport : IRocketCommand
  16. {
  17. public string Help
  18. {
  19. get { return "Reports a player"; }
  20. }
  21.  
  22. public string Name
  23. {
  24. get { return "report"; }
  25. }
  26.  
  27. public string Syntax
  28. {
  29. get { return "<player> [reason]"; }
  30. }
  31.  
  32. public List<string> Aliases {
  33. get { return new List<string>(); }
  34. }
  35.  
  36. public AllowedCaller AllowedCaller
  37. {
  38. get { return AllowedCaller.Both; }
  39. }
  40.  
  41. public List<string> Permissions
  42. {
  43. get
  44. {
  45. return new List<string>() { "thepunisher.report" };
  46. }
  47. }
  48.  
  49. public void Execute(IRocketPlayer caller, params string[] command)
  50. {
  51. try
  52. {
  53. if (command.Length == 0 || command.Length > 2)
  54. {
  55. UnturnedChat.Say(caller, ThePunisher.Instance.Translate("command_generic_invalid_parameter"), (Color)ThePunisher.Instance.getColor(ThePunisher.Instance.Configuration.Instance.PublicMessageColor));
  56. return;
  57. }
  58.  
  59. bool isOnline = false;
  60.  
  61. CSteamID steamid;
  62. string charactername = null;
  63.  
  64.  
  65. UnturnedPlayer otherPlayer = UnturnedPlayer.FromName(command[0]);
  66. ulong? otherPlayerID = command.GetCSteamIDParameter(0);
  67. if (otherPlayer == null || otherPlayer.CSteamID.ToString() == "0" || caller != null && otherPlayer.CSteamID.ToString() == caller.Id)
  68. {
  69. KeyValuePair<CSteamID, string> player = ThePunisher.GetPlayer(command[0]);
  70. if (player.Key.ToString() != "0")
  71. {
  72. steamid = player.Key;
  73. charactername = player.Value;
  74. }
  75. else
  76. {
  77. if (otherPlayerID != null)
  78. {
  79. steamid = new CSteamID(otherPlayerID.Value);
  80. Profile playerProfile = new Profile(otherPlayerID.Value);
  81. charactername = playerProfile.SteamID;
  82. }
  83. else
  84. {
  85. UnturnedChat.Say(caller, ThePunisher.Instance.Translate("command_generic_player_not_found"), (Color)ThePunisher.Instance.getColor(ThePunisher.Instance.Configuration.Instance.PublicMessageColor));
  86. return;
  87. }
  88. }
  89. }
  90. else
  91. {
  92. isOnline = true;
  93. steamid = otherPlayer.CSteamID;
  94. charactername = otherPlayer.CharacterName;
  95. }
  96. if (caller.ToString() == steamid.ToString())
  97. {
  98. UnturnedChat.Say(caller, ThePunisher.Instance.Translate("player_is_you"), (Color)ThePunisher.Instance.getColor(ThePunisher.Instance.Configuration.Instance.PublicMessageColor));
  99. return;
  100. }
  101. if (ThePunisher.Instance.Database.HasReported(steamid.ToString(), caller.ToString()) != null)
  102. {
  103. UnturnedChat.Say(caller, ThePunisher.Instance.Translate("player_allready_reported", charactername), (Color)ThePunisher.Instance.getColor(ThePunisher.Instance.Configuration.Instance.PublicMessageColor));
  104. return;
  105. }
  106. string adminName = "Console";
  107. if (caller != null) adminName = caller.ToString();
  108.  
  109. if (command.Length == 2)
  110. {
  111. ThePunisher.Instance.Database.ReportPlayer(charactername, steamid.ToString(), adminName, command[1]);
  112. UnturnedChat.Say(caller, ThePunisher.Instance.Translate("command_report_success", charactername, command[1]), (Color)ThePunisher.Instance.getColor(ThePunisher.Instance.Configuration.Instance.PublicMessageColor));
  113. }
  114. else
  115. {
  116. ThePunisher.Instance.Database.ReportPlayer(charactername, steamid.ToString(), adminName, "");
  117. UnturnedChat.Say(caller, ThePunisher.Instance.Translate("command_report_success", charactername, command[1]), (Color)ThePunisher.Instance.getColor(ThePunisher.Instance.Configuration.Instance.PublicMessageColor));
  118. }
  119. }
  120. catch (System.Exception ex)
  121. {
  122. Logger.LogException(ex);
  123. }
  124. }
  125. }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement