ketchu13

7dtd-server-fixes - Unban Command

Sep 17th, 2014
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. //@Author: Alloc => 7dtd-server-fixes => https://7dtd.illy.bz/browser/binary-improvements/7dtd-server-fixes
  2. //@Author: ketchu13 => Unban console command => [email protected]
  3. using System;
  4. using System.Collections.Generic;
  5.  
  6. namespace AllocsFixes.CustomCommands
  7. {
  8.     public class UnBan : ConsoleCommand
  9.     {
  10.         public UnBan (ConsoleSdtd cons) : base(cons)
  11.         {
  12.         }
  13.  
  14.         public override string Description ()
  15.         {
  16.             return "Deban un joueur (Steamid)";
  17.         }
  18.  
  19.         public override string[] Names ()
  20.         {
  21.             return new string[] { "unban", "ub" };
  22.         }
  23.  
  24.         public override void Run (string[] _params)
  25.         {
  26.             try {
  27.                 if (_params.Length != 1) {
  28.                     m_Console.SendResult("Utilisation: unban <steamidDuJoueur>");
  29.                     return;
  30.                 }
  31.  
  32.                 long tempLong;
  33.                 if (_params [0].Length != 17 || !long.TryParse (_params [0], out tempLong)) {
  34.                     m_Console.SendResult ("Not a valid Steam ID.");
  35.                     return;
  36.                 }
  37.  
  38.                 string steamid = CommonMappingFunctions.GetSteamID(_params[0]);
  39.                 if (steamid == null)
  40.                 {
  41.                     m_Console.SendResult("SteamId introuvable.");
  42.                     return;
  43.                 }
  44.  
  45.                 AdminTools at = CommonMappingFunctions.GetGameManager ().adminTools;
  46.                 if (!at.isBanned (_params [0])) {
  47.                     m_Console.SendResult ("Steam ID is not banned.");
  48.                     return;
  49.                 }
  50.  
  51.                 at.RemoveBan (_params [0]);
  52.                 m_Console.SendResult ("Joueur deban " + _params [0]);
  53.             } catch (Exception e) {
  54.                 Log.Out ("Error in Unban.Run: " + e);
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment