public static Exiled.API.Features.Player PlayerExists(ArraySegment <string> args, out ArraySegment <string> otherArgs) { ArraySegment <string> tempOut = new ArraySegment <string> { }; Exiled.API.Features.Player tempRet = null; int k = 0; string s = ""; args.ToList().ForEach((i) => { k++; s += i; foreach (Exiled.API.Features.Player player in Exiled.API.Features.Player.List) { if (player.Nickname == s || player.RawUserId == s || player.DisplayNickname == s) { tempOut = args.Segment(k); tempRet = player; break; } } }); if (tempRet != null) { otherArgs = tempOut; return(tempRet); } else { otherArgs = new ArraySegment <string> { }; return(tempRet); } }
public void PlayerEffect(PlayerEffects effects, EPlayer player) { switch (effects) { case PlayerEffects.Scp207: player.EnableEffect <Scp207>(Singleton.Config.Speed); player.ReferenceHub.playerEffectsController.ChangeEffectIntensity <Scp207>(Singleton.Config.AmountOfCokes); break; case PlayerEffects.Scp268: player.EnableEffect <Scp268>(15f); break; case PlayerEffects.Blinded: player.EnableEffect <Blinded>(Singleton.Config.BlindTime); break; case PlayerEffects.Sinkhole: player.EnableEffect <SinkHole>(Singleton.Config.SinkholeTime); break; default: break; } }
private User PlyToUser(Exiled.API.Features.Player player) { return(new User { name = player.Nickname, userid = player.UserId }); }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { string target; string reason; if (!sender.CheckPermission("scputils.moderatecommands")) { response = "<color=red> You need a higher administration level to use this command!</color>"; return(false); } else if (arguments.Count < 3) { response = $"Usage: {Command} <player name / id> <Minutes, 0 = permanent> <Reason>"; return(false); } target = arguments.Array[1].ToString(); Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(target); Player databasePlayer = target.GetDatabasePlayer(); if (databasePlayer == null) { response = "<color=yellow>Player not found on Database or Player is loading data!</color>"; return(false); } else if (databasePlayer.IsRestricted()) { response = "Player is already suspended!"; return(false); } else if (int.TryParse(arguments.Array[2], out int minutes)) { reason = string.Join(" ", arguments.Array, 3, arguments.Array.Length - 3); databasePlayer.Restricted.Add(DateTime.Now.AddMinutes(minutes), reason); if (minutes == 0) { databasePlayer.Restricted.Add(DateTime.Now.AddDays(20000), reason); } Database.LiteDatabase.GetCollection <Player>().Update(databasePlayer); response = $"Player suspended!"; } else { response = "Duration must be integer!"; } return(true); }
public static bool IsEnemy(this Exiled.API.Features.Player player, Team target) { if (player.Role == RoleType.Spectator || player.Role == RoleType.None || player.Team == target) { return(false); } return(target == Team.SCP || ((player.Team != Team.MTF && player.Team != Team.RSC) || (target != Team.MTF && target != Team.RSC)) && ((player.Team != Team.CDP && player.Team != Team.CHI) || (target != Team.CDP && target != Team.CHI)) ); }
public static Player GetDatabasePlayer(this Exiled.API.Features.Player player) { if (player == null) { return(null); } else if (Database.PlayerData.TryGetValue(player, out Player databasePlayer)) { return(databasePlayer); } else { return(Database.LiteDatabase.GetCollection <Player>().FindOne(queryPlayer => queryPlayer.Id == player.GetRawUserId())); } }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { string broadcast; if (!sender.CheckPermission("scputils.broadcast")) { response = "<color=red> You need a higher administration level to use this command!</color>"; return(false); } else if (arguments.Count < 3) { response = $"<color=yellow>Usage: {Command} <player> <hint/broadcast> <text></color>"; return(false); } else { broadcast = string.Join(" ", arguments.Array, 3, arguments.Array.Length - 3); Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(arguments.Array[1].ToString()); if (player == null) { response = "Invalid player!"; return(false); } switch (arguments.Array[2].ToString()) { case "broadcast": case "bc": player.Broadcast(ScpUtils.StaticInstance.Config.BroadcastDuration, broadcast); response = "Success!"; break; case "hint": case "h": player.ShowHint(broadcast, ScpUtils.StaticInstance.Config.BroadcastDuration); response = "Success!"; break; default: response = "Invalid argument, you should use broadcast/bc or hint/h."; break; } } return(true); }
public static User GetUser(ArraySegment <string> arguments, BobuxContext db) { Exiled.API.Features.Player player = Util.PlayerExists(arguments, out arguments); if (player != null) { Exiled.API.Enums.AuthenticationType auth = player.AuthenticationType; if (auth == Exiled.API.Enums.AuthenticationType.Discord) { try { User idk = db.Users.Single(u => u.DiscordId == UInt64.Parse(player.RawUserId)); idk.Player = player; return(idk); } catch { User idk = db.Add(new User { SteamId = null, DiscordId = UInt64.Parse(player.RawUserId), Bobux = 0, TotalBobux = 0 }).Entity; idk.Player = player; return(idk); } } else if (auth == Exiled.API.Enums.AuthenticationType.Steam) { try { User idk = db.Users.Single(u => u.SteamId == UInt64.Parse(player.RawUserId)); idk.Player = player; return(idk); } catch { User idk = db.Add(new User { SteamId = UInt64.Parse(player.RawUserId), DiscordId = null, Bobux = 0, TotalBobux = 0 }).Entity; idk.Player = player; return(idk); } } throw new BadAuthException("The player found is using an unsupported auth type. The only types currently supported are Steam and Discord auth"); } throw new PlayerNotFoundException("A player matching the arguments given was not found"); }
public IEnumerator <float> SpawnGhost(Exiled.API.Features.Player ply, float delay = 5) { yield return(Timing.WaitForSeconds(delay)); if (ply.Role == Plugin.GhostRole || ply.Role != RoleType.Spectator) { yield break; } ply.PlayGhostMessage(); ply.SpawnGhost(); yield return(Timing.WaitForSeconds(1f)); Plugin.Log.Debug($"{ply.Nickname} given the ghost spectator items."); ply.ClearInventory(); ply.AddItem(ItemType.Ammo762); ply.AddItem(ItemType.Ammo556); ply.AddItem(ItemType.Ammo9mm); ply.AddItem(ItemType.Flashlight); }
public void OnPocketDimensionDeath(FailingEscapePocketDimensionEventArgs ev) { Exiled.API.Features.Player Player106 = Exiled.API.Features.Player.List.FirstOrDefault(x => x.Role == RoleType.Scp106); if (Player106 != null && !SerpentsHand.API.SerpentsHand.GetSHPlayers().Contains(ev.Player)) { if (HealthOnKill.instance.Config.isHealthRegenRandom) { int rand = r.Next(5, 15); int health = (int)Player106.Health + rand; Player106.Health = health < Player106.MaxHealth ? health : Player106.MaxHealth; } else { int health = (int)Player106.Health + HealthOnKill.instance.Config.scp106HealthOnKillSet; Player106.Health = health < Player106.MaxHealth ? health : Player106.MaxHealth; } } }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { string target; if (!sender.CheckPermission("scputils.moderatecommands")) { response = "<color=red> You need a higher administration level to use this command!</color>"; return(false); } else if (arguments.Count < 1) { response = $"Usage: {Command} <player name/id>"; return(false); } else { target = arguments.Array[1].ToString(); } Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(target); Player databasePlayer = target.GetDatabasePlayer(); if (databasePlayer == null) { response = "<color=yellow>Player not found on Database or Player is loading data!</color>"; return(false); } else if (!databasePlayer.IsRestricted()) { response = "Player is not suspended!"; return(false); } databasePlayer.Restricted.Remove(databasePlayer.Restricted.Keys.Last()); Database.LiteDatabase.GetCollection <Player>().Update(databasePlayer); response = "Player unsuspended!"; return(true); }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { string target; if (!sender.CheckPermission("scputils.handlebadges")) { response = "<color=red> You need a higher administration level to use this command!</color>"; return(false); } else if (arguments.Count < 1) { response = $"Usage: {Command} <player name/id>"; return(false); } else { target = arguments.Array[1].ToString(); } Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(target); Player databasePlayer = target.GetDatabasePlayer(); if (databasePlayer == null) { response = "<color=yellow>Player not found on Database or Player is loading data!</color>"; return(false); } databasePlayer.BadgeExpire = DateTime.MinValue; Database.LiteDatabase.GetCollection <Player>().Update(databasePlayer); if (player != null) { player.BadgeHidden = false; //Badges will actually revoke now. player.ReferenceHub.serverRoles.SetGroup(null, false, false, false); } response = "Badge revoked!"; return(true); }
public static void Prefix(DissonanceUserSetup __instance, bool value) { Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(__instance.gameObject); if (string.IsNullOrEmpty(player?.UserId) || player.Team != Team.SCP) { return; } else if (ScpUtils.StaticInstance.Config.AllowedScps.Contains(player.Role)) { __instance.MimicAs939 = value; return; } else if (string.IsNullOrEmpty(ServerStatic.GetPermissionsHandler()._groups.FirstOrDefault(g => g.Value == player.ReferenceHub.serverRoles.Group).Key) && !string.IsNullOrEmpty(player.ReferenceHub.serverRoles.MyText)) { return; } else if (player.CheckPermission($"scputils_speak.{player.Role.ToString().ToLower()}")) { __instance.MimicAs939 = value; } }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { if (!sender.CheckPermission("scputils.badgevisibility")) { response = $"{ScpUtils.StaticInstance.Config.UnauthorizedBadgeChangeVisibility} "; return(false); } else if (((CommandSender)sender).Nickname.Equals("SERVER CONSOLE")) { response = "This command cannot be executed from console!"; return(false); } else { Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId); player.BadgeHidden = false; player.GetDatabasePlayer().HideBadge = false; response = "<color=green>Your badge has been shown!</color>"; return(true); } }
private static bool Prefix(Scp096 __instance) { if (__instance._flash.Enabled) { return(false); } Exiled.API.Features.Player scp096 = Exiled.API.Features.Player.Get(__instance.Hub); if (scp096.IsNPC() && !NPCS.Npc.Dictionary[__instance.Hub.gameObject].ProcessSCPLogic) { return(false); } Vector3 vector = __instance.Hub.transform.TransformPoint(Scp096._headOffset); foreach (System.Collections.Generic.KeyValuePair <GameObject, global::ReferenceHub> keyValuePair in global::ReferenceHub.GetAllHubs()) { global::ReferenceHub value = keyValuePair.Value; global::CharacterClassManager characterClassManager = value.characterClassManager; NPCS.Npc npc = NPCS.Npc.Dictionary.ContainsKey(keyValuePair.Key) ? NPCS.Npc.Dictionary[keyValuePair.Key] : null; if (characterClassManager.CurClass != global::RoleType.Spectator && !(value == __instance.Hub) && !characterClassManager.IsAnyScp() && Vector3.Dot((value.PlayerCameraReference.position - vector).normalized, __instance.Hub.PlayerCameraReference.forward) >= 0.1f && (npc == null || npc.ShouldTrigger096)) { VisionInformation visionInformation = VisionInformation.GetVisionInformation(value, vector, -0.1f, 60f, true, true, __instance.Hub.localCurrentRoomEffects); if (visionInformation.IsLooking) { float delay = visionInformation.LookingAmount / 0.25f * (visionInformation.Distance * 0.1f); if (!__instance.Calming) { __instance.AddTarget(value.gameObject); } if (__instance.CanEnrage && value.gameObject != null) { __instance.PreWindup(delay); } } } } return(false); }
public static bool Prefix(NetworkConnection conn, Scp939VoiceMessage msg) { Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(conn.identity.netId); if (string.IsNullOrEmpty(player?.UserId) || player.Team != Team.SCP) { return(false); } else if (ScpUtils.StaticInstance.Config.AllowedScps.Contains(player.Role)) { return(player.ReferenceHub.dissonanceUserSetup.MimicAs939 = msg.IsMimicking); } else if (string.IsNullOrEmpty(ServerStatic.GetPermissionsHandler()._groups.FirstOrDefault(g => g.Value == player.ReferenceHub.serverRoles.Group).Key) && !string.IsNullOrEmpty(player.ReferenceHub.serverRoles.MyText)) { return(false); } else if (player.CheckPermission($"scputils_speak.{player.Role.ToString().ToLower()}")) { return(player.ReferenceHub.dissonanceUserSetup.MimicAs939 = msg.IsMimicking); } else { return(false); } }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { string target; string nickname = ""; if (sender.CheckPermission("scputils.playersetname")) { if (arguments.Count < 2) { response = $"<color=yellow>Usage: {Command} <player name/id> <Nickname / None> </color>"; return(false); } else { target = arguments.Array[1].ToString(); nickname = string.Join(" ", arguments.Array, 2, arguments.Array.Length - 2); } } else if (sender.CheckPermission("scputils.changenickname")) { if (arguments.Count < 1) { response = $"<color=yellow>Usage: {Command} <Nickname / None> </color>"; return(false); } else { target = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId).UserId; if (target.GetDatabasePlayer().IsRestricted()) { response = "<color=red>You are banned from executing this command!</color>"; return(false); } nickname = string.Join(" ", arguments.Array, 1, arguments.Array.Length - 1); bool allowChange = true; foreach (Exiled.API.Features.Player playerList in Exiled.API.Features.Player.List) { if (playerList.Nickname.ToLower() == nickname.ToLower()) { allowChange = false; break; } } if (!allowChange) { response = "<color=red>This nickname is already used by another player, please choose another name!</color>"; return(false); } else if (ScpUtils.StaticInstance.Functions.CheckNickname(nickname) && !sender.CheckPermission("scputils.bypassnickrestriction")) { response = $"{ScpUtils.StaticInstance.Config.InvalidNicknameText} "; return(false); } } } else { response = $"{ScpUtils.StaticInstance.Config.UnauthorizedNickNameChange} "; return(false); } Player databasePlayer = target.GetDatabasePlayer(); if (databasePlayer == null) { response = "<color=yellow>Player not found on Database or Player is loading data!</color>"; return(false); } if (nickname.ToLower() == "none") { databasePlayer.CustomNickName = ""; Database.LiteDatabase.GetCollection <Player>().Update(databasePlayer); response = "<color=green>Success, changes will take effect next round!</color>"; return(true); } if (nickname.Length > ScpUtils.StaticInstance.Config.NicknameMaxLength) { response = "<color=red>Nickname is too long!</color>"; return(false); } databasePlayer.CustomNickName = nickname; Database.LiteDatabase.GetCollection <Player>().Update(databasePlayer); response = "<color=green>Success, choice has been saved!</color>"; Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(target); if (player != null) { player.DisplayNickname = nickname; } return(true); }
public ExiledPlayerCast(Exiled.API.Features.Player player) { _player = player; _logName = player.Nickname + " (" + player.UserId + ")"; }
public static string GetAuthentication(this Exiled.API.Features.Player player) { return(player.UserId.Split('@')[1]); }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { if (!sender.CheckPermission("ast.playermgm")) { response = "You can't use this command, you don't have \"ast.playermgm\" permission."; return(false); } if (arguments.Count < 1) { response = "Subcommands: clear (c), drop (d), reset (r). Will soon add the option to drop specific ammo types"; return(false); } else if (arguments.At(0) == "clear" || arguments.At(0) == "c") { if (arguments.Count > 1) { P Ply = P.Get(arguments.At(1)); if (Ply == null) { response = $"Player not found: {arguments.At(1)}"; return(false); } if (Ply.Role == RoleType.Spectator || Ply.Role == RoleType.None || Ply.Team == Team.SCP) { response = "You cannot clear the ammo of this player."; return(false); } Ply.Ammo.Clear(); response = $"Succesfully cleared the ammo of {Ply.Nickname}"; return(true); } else { response = $"Clears the ammo of a player. Usage: {Command} c <user>"; return(false); } } else if (arguments.At(0) == "drop" || arguments.At(0) == "d") { if (arguments.Count > 1) { P Ply = P.Get(arguments.At(1)); if (Ply == null) { response = $"Player not found: {arguments.At(1)}"; return(false); } if (Ply.Role == RoleType.Spectator || Ply.Role == RoleType.None || Ply.Team == Team.SCP) { response = "You cannot drop the ammo of this player."; return(false); } Ply.Ammo.DropAll(); response = $"Succesfully dropped the ammo of {Ply.Nickname}"; return(true); } else { response = $"Drops the ammo of a player. Usage: {Command} d <user>"; return(false); } } else if (arguments.At(0) == "reset" || arguments.At(0) == "r") { if (arguments.Count > 1) { P Ply = P.Get(arguments.At(1)); if (Ply == null) { response = $"Player not found: {arguments.At(1)}"; return(false); } if (Ply.Role == RoleType.Spectator || Ply.Role == RoleType.None || Ply.Team == Team.SCP) { response = "You cannot reset the ammo of this player."; return(false); } Ply.Ammo.ResetAmmo(); response = $"Succesfully reset the ammo of {Ply.Nickname}"; return(true); } else { response = $"Resets the ammo of a player to the class' default. Usage: {Command} c <user>"; return(false); } } else { response = "Invalid subcommand. Subcommands: clear (c), drop (d), reset (r). Will soon add the option to drop specific ammo types"; return(false); } }
public static string GetRawUserId(this Exiled.API.Features.Player player) { return(player.UserId.GetRawUserId()); }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { throw new NotImplementedException(); if (!sender.CheckPermission("ast.playermgm")) { response = "You can't use this command, you don't have \"ast.playermgm\" permission."; return(false); } if (arguments.Count < 1) { response = "Subcommands: clear (c), additem (ai), display(d)"; return(true); } else if (arguments.At(0) == "clear" || arguments.At(0) == "c") { if (arguments.Count > 1) { P Ply = P.Get(arguments.At(1)); if (Ply == null) { response = $"Player not found: {arguments.At(1)}"; return(false); } if (Ply.Role == RoleType.Spectator || Ply.Role == RoleType.None || Ply.Team == Team.SCP) { response = "You cannot clear the inventory of this player."; return(false); } Ply.Inventory.Clear(); response = $"Succesfully cleared the inventory of {Ply.Nickname}"; return(true); } else { response = $"Clears the inventory of a player. Usage: {Command} c <user>"; return(true); } } else if (arguments.At(0) == "additem" || arguments.At(0) == "ai") { if (arguments.Count > 1) { P Ply = P.Get(arguments.At(1)); if (Ply == null) { response = $"Player not found: {arguments.At(1)}"; return(false); } if (arguments.Count > 2) { } else { response = ""; return(true); } } else { response = $"Adds an item to the inventory of a player. Usage: {Command} ai <user> <item>"; return(true); } } else { response = "Invalid subcommand. Subcommands: "; return(false); } }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { if (!sender.CheckPermission("scputils.broadcast")) { response = "<color=red> You need a higher administration level to use this command!</color>"; return(false); } else if (arguments.Count < 3) { response = $"<color=yellow>Usage: {Command} <player> <hint(h)/broadcast(bc)> <id> <duration (optional, if empty will be used the default one set for this broadcast)></color>"; return(false); } else { var databaseBroadcast = GetBroadcast.FindBroadcast(arguments.Array[3]); if (databaseBroadcast == null) { response = "Invalid broadcast ID!"; return(false); } Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(arguments.Array[1].ToString()); if (player == null) { response = "Invalid player!"; return(false); } int duration = databaseBroadcast.Seconds; if (arguments.Count == 4) { if (int.TryParse(arguments.Array[4].ToString(), out duration)) { } else { response = "Broadcast duration must be an integer"; return(false); } } switch (arguments.Array[2].ToString()) { case "broadcast": case "bc": player.Broadcast((ushort)duration, databaseBroadcast.Text, global::Broadcast.BroadcastFlags.Normal, false); response = "Success!"; break; case "hint": case "h": player.ShowHint(databaseBroadcast.Text, duration); response = "Success!"; break; default: response = "Invalid argument, you should use broadcast/bc or hint/h."; break; } } return(true); }
private static bool Prefix(GameObject user, int duration, string reason, string issuer, bool isGlobalBan) { try { Exiled.API.Features.Player issuerPlayer = Exiled.API.Features.Player.Get(issuer) ?? Exiled.API.Features.Server.Host; if (Npc.Dictionary.ContainsKey(user)) { issuerPlayer.RemoteAdminMessage("WTF U TRIED TO BAN NPC?", false, Plugin.Instance.Name); issuerPlayer.ClearBroadcasts(); issuerPlayer.Broadcast(2, Plugin.Instance.Config.TranslationBanBroadcast); return(false); } if (isGlobalBan && ConfigFile.ServerConfig.GetBool("gban_ban_ip", false)) { duration = int.MaxValue; } string userId = null; string address = user.GetComponent <NetworkIdentity>().connectionToClient.address; Exiled.API.Features.Player targetPlayer = Exiled.API.Features.Player.Get(user); try { if (ConfigFile.ServerConfig.GetBool("online_mode", false)) { userId = targetPlayer.UserId; } } catch { ServerConsole.AddLog("Failed during issue of User ID ban (1)!"); return(false); } string message = $"You have been {((duration > 0) ? "banned" : "kicked")}. "; if (!string.IsNullOrEmpty(reason)) { message = message + "Reason: " + reason; } if (!ServerStatic.PermissionsHandler.IsVerified || !targetPlayer.IsStaffBypassEnabled) { if (duration > 0) { var ev = new BanningEventArgs(targetPlayer, issuerPlayer, duration, reason, message); Player.OnBanning(ev); duration = ev.Duration; reason = ev.Reason; message = ev.FullMessage; if (!ev.IsAllowed) { return(false); } string originalName = string.IsNullOrEmpty(targetPlayer.Nickname) ? "(no nick)" : targetPlayer.Nickname; long issuanceTime = TimeBehaviour.CurrentTimestamp(); long banExpieryTime = TimeBehaviour.GetBanExpirationTime((uint)duration); try { if (userId != null && !isGlobalBan) { BanHandler.IssueBan( new BanDetails { OriginalName = originalName, Id = userId, IssuanceTime = issuanceTime, Expires = banExpieryTime, Reason = reason, Issuer = issuer, }, BanHandler.BanType.UserId); if (!string.IsNullOrEmpty(targetPlayer.CustomUserId)) { BanHandler.IssueBan( new BanDetails { OriginalName = originalName, Id = targetPlayer.CustomUserId, IssuanceTime = issuanceTime, Expires = banExpieryTime, Reason = reason, Issuer = issuer, }, BanHandler.BanType.UserId); } } } catch { ServerConsole.AddLog("Failed during issue of User ID ban (2)!"); return(false); } try { if (ConfigFile.ServerConfig.GetBool("ip_banning", false) || isGlobalBan) { BanHandler.IssueBan( new BanDetails { OriginalName = originalName, Id = address, IssuanceTime = issuanceTime, Expires = banExpieryTime, Reason = reason, Issuer = issuer, }, BanHandler.BanType.IP); } } catch { ServerConsole.AddLog("Failed during issue of IP ban!"); return(false); } } else if (duration == 0) { var ev = new KickingEventArgs(targetPlayer, issuerPlayer, reason, message); Player.OnKicking(ev); reason = ev.Reason; message = ev.FullMessage; if (!ev.IsAllowed) { return(false); } } } ServerConsole.Disconnect(targetPlayer.ReferenceHub.gameObject, message); return(false); } catch (Exception e) { Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.BanningAndKicking (Repatched by CustomNPCs!!!): {e}\n{e.StackTrace}"); return(true); } }
/// <summary> /// Initializes a new instance of the <see cref="OwnerDyingEventArgs"/> class. /// </summary> /// <param name="item"><inheritdoc cref="Item"/></param> /// <param name="target"><inheritdoc cref="DyingEventArgs.Target"/></param> /// <param name="damageHandler"><inheritdoc cref="DyingEventArgs.DamageHandler"/></param> public OwnerDyingEventArgs(Item item, Player target, DamageHandlerBase damageHandler) : base(target, damageHandler) { Item = item; }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { string target; string badge; if (!sender.CheckPermission("scputils.handlebadges")) { response = "<color=red> You need a higher administration level to use this command!</color>"; return(false); } else if (arguments.Count < 3) { response = $"Usage: {Command} <player name / id> <Badge Name> <Minutes>"; return(false); } target = arguments.Array[1].ToString(); badge = arguments.Array[2].ToString(); Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(target); Player databasePlayer = target.GetDatabasePlayer(); if (databasePlayer == null) { response = "<color=yellow>Player not found on Database or Player is loading data!</color>"; return(false); } else if (!ServerStatic.GetPermissionsHandler().GetAllGroups().ContainsKey(badge)) { response = "Invalid role name!"; return(false); } else if (int.TryParse(arguments.Array[3], out int duration)) { UserGroup group = ServerStatic.GetPermissionsHandler()._groups[badge]; if (group.KickPower > ((CommandSender)sender).KickPower && !((CommandSender)sender).FullPermissions) { response = $"You need a higher administration level to use this command: The group you are trying to set has more kick power than yours. (Your kick power: {((CommandSender)sender).KickPower}, Required: {group.KickPower})"; return(false); } if (player != null) { BadgeSetEvent args = new BadgeSetEvent(); args.Player = player; args.NewBadgeName = badge; if (ServerStatic.PermissionsHandler._members.ContainsKey(player.UserId)) { ServerStatic.PermissionsHandler._members.Remove(player.UserId); } player.ReferenceHub.serverRoles.SetGroup(group, false, true, true); ServerStatic.PermissionsHandler._members.Add(player.UserId, badge); ScpUtils.StaticInstance.Events.OnBadgeSet(args); } databasePlayer.BadgeName = badge; databasePlayer.BadgeExpire = DateTime.Now.AddMinutes(duration); Database.LiteDatabase.GetCollection <Player>().Update(databasePlayer); response = $"Successfully set {group.BadgeText} badge! Duration: {duration} minute(s)!"; } else { response = "Arg3 must be integer!"; } return(true); }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { string target; string color; if (sender.CheckPermission("scputils.playersetcolor")) { if (arguments.Count < 2) { response = $"<color=yellow>Usage: {Command} <player name/id> <Color / None> </color>"; return(false); } else { target = arguments.Array[1].ToString(); color = arguments.Array[2].ToString().ToLower(); if (!validColors.Contains(color) && !color.Equals("none")) { response = "<color=red>Invalid color, type color in console to see valid SCP colors<color>"; return(false); } } } else if (sender.CheckPermission("scputils.changecolor")) { if (arguments.Count < 1) { response = $"<color=yellow>Usage: {Command} <Color / None></color>"; return(false); } else { target = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId).ToString().Split(new string[] { " " }, StringSplitOptions.None)[2]; color = arguments.Array[1].ToString().ToLower(); if (target.GetDatabasePlayer().IsRestricted()) { response = "<color=red>You are banned from executing this command!</color>"; return(false); } else if (!validColors.Contains(color) && !color.Equals("none")) { response = "<color=red>Invalid color, type color in console to see valid SCP colors</color>"; return(false); } else if (ScpUtils.StaticInstance.Config.RestrictedRoleColors.Contains(color)) { response = "<color=red>This color has been restricted by server owner, please use another color!</color>"; return(false); } } } else { response = $"{ScpUtils.StaticInstance.Config.UnauthorizedColorChange} "; return(false); } Player databasePlayer = target.GetDatabasePlayer(); if (databasePlayer == null) { response = "<color=yellow>Player not found on Database or Player is loading data!</color>"; return(false); } if (color == "none") { databasePlayer.ColorPreference = ""; Database.LiteDatabase.GetCollection <Player>().Update(databasePlayer); response = "<color=green>Success, changes will take effect next round!</color>"; return(true); } databasePlayer.ColorPreference = color; Database.LiteDatabase.GetCollection <Player>().Update(databasePlayer); response = "<color=green>Success, choice has been saved!</color>"; Exiled.API.Features.Player player = Exiled.API.Features.Player.Get(target); if (player != null) { player.RankColor = color; } return(true); }