public static bool Run(SvPlayer player, string ExeBy, bool ShowNoPermMessage = false, byte?jobIndex = null) { if ((player.player.admin && ExeBy.Contains("admins")) || ExeBy.Contains("everyone") || ExeBy.Contains($"username:{player.player.username}")) { return(true); } string[] GroupsSplit = ExeBy.Split(','); foreach (string name in GroupsSplit) { if (jobIndex != null) { if (Groups.Any(curr => $"group:{curr.Value.Name}".Equals(name.Trim()) && curr.Value.Users.Contains(player.playerData.username)) || name == $"jobindex:{jobIndex}") { return(true); } } else if (Groups.Any(curr => $"group:{curr.Value.Name}".Equals(name.Trim()) && curr.Value.Users.Contains(player.playerData.username))) { return(true); } } if (ShowNoPermMessage) { player.SendChatMessage($"<color={errorColor}>{MsgNoPerm}</color>"); } return(false); }
public static void Run(SvPlayer player, string message) { new Thread(BP_Essentials.Save.Run) { IsBackground = true }.Start(); }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) { player.SendChatMessage(ArgRequired); return; } var shPlayer = GetShByStr.Run(arg1); if (shPlayer == null) { player.SendChatMessage(NotFoundOnline); return; } if (shPlayer == player.player) { player.SendChatMessage($"<color={errorColor}>You cannot teleport to yourself.</color>"); return; } PlayerList[shPlayer.ID].TpaUser = player.player; player.SendChatMessage($"<color={infoColor}>Sent a TPA request to</color> <color={argColor}>{shPlayer.username}</color><color={infoColor}>.</color>"); shPlayer.svPlayer.SendChatMessage($"<color={argColor}>{player.player.username}</color> <color={infoColor}>sent you a tpa request. Type</color> <color={argColor}>{CmdCommandCharacter}{CmdTpaaccept}</color> <color={infoColor}>to accept it.</color>"); }
public static void Run(SvPlayer player, string message) { string arg = GetArgument.Run(1, false, false, message).Trim().ToLower(); switch (arg) { case "ver": case "version": player.SendChatMessage("Version: " + Variables.Version); break; case "help": player.SendChatMessage("Subcommands for /essentials:"); player.SendChatMessage(" - help : Shows this menu."); player.SendChatMessage(" - info : Shows infomation about the developer."); player.SendChatMessage(" - ver/version : Shows version number."); player.SendChatMessage(" - cmd/command : Gives a link to the website of BP-Essentials."); break; case "cmd": case "cmds": case "command": case "commands": player.SendChatMessage("Up to date help can be found at https://goo.gl/Rwhtjs"); break; case "info": default: player.SendChatMessage("Essentials Created by UserR00T & DeathByKorea & BP."); player.SendChatMessage("Version " + Variables.Version); player.SendChatMessage("Type '/essentials help' for more info. "); break; } }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) { player.SendChatMessage(ArgRequired); return; } arg1 = arg1.Remove(arg1.LastIndexOf(" ", StringComparison.CurrentCulture)).Trim(); var shPlayer = GetShByStr.Run(arg1); if (shPlayer == null) { player.SendChatMessage(NotFoundOnline); return; } if (!float.TryParse(message.Split(' ').Last().Trim(), out float time)) { player.SendChatMessage(ArgRequired); return; } if (!SendToJail.Run(shPlayer, time)) { player.SendChatMessage($"<color={errorColor}>Cannot send</color> <color={argColor}>{shPlayer.username}</color> <color={errorColor}>To jail.</color>"); return; } shPlayer.svPlayer.SendChatMessage($"<color={argColor}>{player.player.username}</color> <color={infoColor}>sent you to jail.</color>"); player.SendChatMessage($"<color={infoColor}>Sent</color> <color={argColor}>{shPlayer.username}</color> <color={infoColor}>To jail.</color>"); }
public static void Run(SvPlayer player) { try { Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] [JOIN] {player.player.username} IP is: {player.connection.IP}"); int tries = 0; while (tries < 2) { try { if (!File.ReadAllText(IpListFile).Contains(player.player.username + ": " + player.connection.IP)) { File.AppendAllText(IpListFile, player.player.username + ": " + player.connection.IP + Environment.NewLine); } break; } catch (IOException) { ++tries; } } } catch (Exception ex) { ErrorLogging.Run(ex); } }
public static bool Run(SvPlayer player, string message) { if (MessagesAllowedPerSecond != -1 && MessagesAllowedPerSecond < 50) { if (PlayerList.TryGetValue(player.player.ID, out var currObj)) { if (currObj.MessagesSent >= MessagesAllowedPerSecond) { Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] {player.player.username} got kicked for spamming! {currObj.MessagesSent}/s (max: {MessagesAllowedPerSecond}) messages sent."); player.svManager.Kick(player.connection); return(true); } PlayerList[player.player.ID].MessagesSent++; if (!currObj.IsCurrentlyAwaiting) { PlayerList[player.player.ID].IsCurrentlyAwaiting = true; Task.Factory.StartNew(async() => { await Task.Delay(TimeBetweenDelay); if (PlayerList.ContainsKey(player.player.ID)) { PlayerList[player.player.ID].MessagesSent = 0; PlayerList[player.player.ID].IsCurrentlyAwaiting = false; } }); } } } return(false); }
public static bool SvBan(SvPlayer player, ref int otherID) { if (player.player.admin) { return(true); } if (BlockBanButtonTabMenu) { player.SendChatMessage($"<color={errorColor}>This button has been disabled. Please use the ban commands. ID: {otherID}</color>"); return(true); } var targetPlayer = player.entity.manager.FindByID <ShPlayer>(otherID); if (!targetPlayer || targetPlayer.svPlayer.serverside) { player.SendChatMessage("Cannot ban NPC"); return(true); } LogMessage.LogOther($"{PlaceholderParser.ParseTimeStamp()} [INFO] {targetPlayer.username} Got banned by {player.playerData.username}"); player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"<color={argColor}>{targetPlayer.username}</color> <color={warningColor}>Just got banned by</color> <color={argColor}>{player.player.username}</color>"); SendDiscordMessage.BanMessage(targetPlayer.username, player.playerData.username); player.svManager.AddBanned(targetPlayer); player.svManager.Disconnect(targetPlayer.svPlayer.connection, DisconnectTypes.Banned); return(true); }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) { player.SendChatMessage(ArgRequired); return; } var currPlayer = GetShByStr.Run(arg1); if (currPlayer == null) { player.SendChatMessage(NotFoundOnline); return; } // To be improved currPlayer.svPlayer.SvSetWearable(-1626497894); //NullArmor currPlayer.svPlayer.SvSetWearable(673780802); //NullBack currPlayer.svPlayer.SvSetWearable(-1638932793); //NullBody currPlayer.svPlayer.SvSetWearable(1089711634); //NullFace currPlayer.svPlayer.SvSetWearable(2064679354); //NullFeet currPlayer.svPlayer.SvSetWearable(1174688158); //NullHands currPlayer.svPlayer.SvSetWearable(-501996567); //NullHead currPlayer.svPlayer.SvSetWearable(-1191209217); //NullLegs foreach (var item in currPlayer.myItems.Values.ToList()) { if (item.item.GetType() == typeof(ShWearable)) { currPlayer.TransferItem(DeltaInv.RemoveFromMe, item.item.index, currPlayer.MyItemCount(item.item.index), true); } } currPlayer.svPlayer.SendChatMessage($"<color={argColor}>{player.playerData.username}</color> <color={warningColor}>Removed your clothes.</color>"); player.SendChatMessage($"<color={infoColor}>Removed </color><color={argColor}>{currPlayer.username}</color><color={infoColor}>'s clothes.</color>"); }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) { player.SendChatMessage(ArgRequired); return; } var shPlayer = GetShByStr.Run(arg1); if (shPlayer == null) { player.SendChatMessage(NotFoundOnline); return; } var tempList = new List <InventoryItem>(); foreach (var item in shPlayer.myItems.Values) { tempList.Add(item); } for (int i = 0; i < tempList.Count; i++) { shPlayer.TransferItem(DeltaInv.RemoveFromMe, tempList[i].item.index, shPlayer.MyItemCount(tempList[i].item.index), true); } player.SendChatMessage($"<color={infoColor}>You cleared the inventory of</color> <color={argColor}>{shPlayer.username}</color><color={infoColor}>.</color>"); shPlayer.svPlayer.SendChatMessage($"<color={warningColor}>Your inventory has been cleared by</color> <color={argColor}>{player.playerData.username}</color><color={warningColor}>.</color>"); }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) { arg1 = player.player.username; } var currPlayer = GetShByStr.Run(arg1); if (currPlayer == null) { player.SendChatMessage(NotFoundOnline); return; } ReadFile.Run(GodListFile); var msg = $"<color={infoColor}>Godmode</color> <color={argColor}>{{0}}</color> <color={infoColor}>for</color> <color={argColor}>'{arg1}'</color><color={infoColor}>.</color>"; if (GodListPlayers.Contains(currPlayer.username)) { RemoveStringFromFile.Run(GodListFile, currPlayer.username); ReadFile.Run(GodListFile); player.SendChatMessage(string.Format(msg, "disabled")); return; } File.AppendAllText(GodListFile, currPlayer.username + Environment.NewLine); GodListPlayers.Add(currPlayer.username); player.SendChatMessage(string.Format(msg, "enabled")); }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) { player.SendChatMessage(ArgRequired); return; } var currPlayer = GetShByStr.Run(arg1); if (currPlayer == null) { player.SendChatMessage(NotFoundOnline); return; } ReadFile.Run(MuteListFile); if (!MutePlayers.Contains(currPlayer.username)) { MutePlayers.Add(currPlayer.username); File.AppendAllText(MuteListFile, currPlayer.username + Environment.NewLine); player.SendChatMessage($"<color={infoColor}>Muted </color><color={argColor}>{currPlayer.username}</color><color={infoColor}>.</color>"); return; } RemoveStringFromFile.Run(MuteListFile, currPlayer.username); ReadFile.Run(MuteListFile); player.SendChatMessage($"<color={infoColor}>Unmuted </color><color={argColor}>{currPlayer.username}</color><color={infoColor}>.</color>"); }
public static void Run(SvPlayer player, string message) { var arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) { player.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, ArgRequired); return; } var currPlayer = GetShByStr.Run(arg1); if (currPlayer == null) { player.SendChatMessage(NotFoundOnline); return; } string[] contentarray = { "Username: "******"", "", "Job: " + Jobs[currPlayer.job.jobIndex], "Health: " + Math.Floor(currPlayer.health), "OwnsApartment: " + (bool)currPlayer.ownedApartment, "Position: " + currPlayer.GetPosition().ToString(), "WantedLevel: " + currPlayer.wantedLevel, "IsAdmin: " + currPlayer.admin, "BankBalance: " + currPlayer.svPlayer.bankBalance, "ChatEnabled: " + PlayerList[currPlayer.ID].ChatEnabled, "IP: " + currPlayer.svPlayer.connection.IP }; var content = string.Join("\r\n", contentarray); player.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, content); }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) { player.SendChatMessage(ArgRequired); return; } if (WipePassword == "default") { player.SendChatMessage($"<color={errorColor}>Password was not changed yet, cannot use this command.</color>"); return; } if (arg1 != WipePassword) { player.SendChatMessage($"<color={errorColor}>Invalid password.</color>"); return; } Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Wipe command ran by {player.player.username}, password matched, deleting all save files."); foreach (var currPlayer in PlayerList.Values.ToList()) { player.svManager.Disconnect(currPlayer.ShPlayer.svPlayer.connection, DisconnectTypes.Problem); } Thread.Sleep(500); var files = Directory.GetFiles(Path.Combine(Application.persistentDataPath, "PlayerData/"), "*.json").Where(item => item.EndsWith(".json", StringComparison.CurrentCulture)); foreach (var file in files.ToList()) { File.Delete(file); } Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] All user data deleted!"); }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); string arg2 = message.Split(' ').Last().Trim(); string correctSyntax = $"<color={argColor}>{GetArgument.Run(0, false, false, message)}</color> <color={errorColor}>[Player] [Amount]</color> <color={warningColor}>(Incorrect or missing argument(s).)</color>"; if (string.IsNullOrEmpty(arg1) || string.IsNullOrEmpty(arg2)) { player.SendChatMessage(correctSyntax); return; } int lastIndex = arg1.LastIndexOf(" ", StringComparison.CurrentCulture); if (lastIndex != -1) arg1 = arg1.Remove(lastIndex).Trim(); bool parsedSuccessfully = int.TryParse(arg2, out var arg2int); if (!parsedSuccessfully) { player.SendChatMessage(correctSyntax); return; } var currPlayer = GetShByStr.Run(arg1); if (currPlayer == null) { player.SendChatMessage(NotFoundOnline); return; } currPlayer.TransferMoney(DeltaInv.AddToMe, arg2int, true); player.SendChatMessage($"<color={infoColor}>Successfully gave</color> <color={argColor}>{currPlayer.username} {arg2int}</color><color={infoColor}>$</color>"); currPlayer.svPlayer.SendChatMessage($"<color={argColor}>{player.player.username}</color><color={infoColor}> gave you </color><color={argColor}>{arg2int}</color><color={infoColor}>$!</color>"); }
public static void Run(SvPlayer player) { if (CheckBannedEnabled) { try { if (player.player.admin || string.IsNullOrEmpty(player.connection.IP.Trim())) { return; } foreach (var line in File.ReadAllLines(BansFile)) { if (string.IsNullOrEmpty(line) || !line.StartsWith("# " + player.player.username, StringComparison.CurrentCulture)) { continue; } } Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] {player.player.username} Joined while banned! IP: {player.connection.IP}"); player.svManager.AddBanned(player.player); player.svManager.Disconnect(player.connection, DisconnectTypes.Banned); } catch (Exception ex) { ErrorLogging.Run(ex); } } }
public static void Run(SvPlayer player, string message, string prefix = "") { try { var mssge = $"{PlaceholderParser.ParseTimeStamp()} {prefix}[{(message.StartsWith(CmdCommandCharacter, StringComparison.CurrentCulture) ? "COMMAND" : "MESSAGE")}] {player.playerData.username}: {message}"; Debug.Log(mssge); int tries = 0; while (tries < 2) { try { if (!message.StartsWith(CmdCommandCharacter, StringComparison.CurrentCulture)) { File.AppendAllText(ChatLogFile, mssge + Environment.NewLine); } else { File.AppendAllText(CommandLogFile, mssge + Environment.NewLine); } File.AppendAllText(LogFile, mssge + Environment.NewLine); break; } catch (IOException) { Thread.Sleep(50); ++tries; } } } catch (Exception ex) { ErrorLogging.Run(ex); } }
private static bool WillDieByDamage(this SvPlayer sv, DamageIndex type, float amount, Collider collider) { if (sv.player.IsDead() || sv.player.IsShielded(type, collider)) { return(false); } if (sv.player.IsBlocking(type)) { amount *= 0.3f; } else if (collider == sv.player.headCollider) { amount *= 2f; } if (sv.serverside) { amount /= sv.svManager.settings.difficulty; } amount -= amount * (sv.player.armorLevel / sv.player.maxStat * 0.5f); return(sv.player.health - amount <= 0); }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1)) { player.SendChatMessage(ArgRequired); return; } var currPlayer = GetShByStr.Run(arg1); if (currPlayer == null) { player.SendChatMessage(NotFoundOnline); return; } currPlayer.svPlayer.Restrain(currPlayer.manager.handcuffed); var shRetained = currPlayer.curEquipable as ShRestrained; currPlayer.svPlayer.SvSetEquipable(shRetained.otherRestrained.index); if (!currPlayer.svPlayer.serverside) { currPlayer.svPlayer.SendChatMessage("You've been restrained"); } player.SendChatMessage($"<color={infoColor}>Restrained</color> <color={argColor}>{currPlayer.username}</color><color={infoColor}>.</color>"); }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, false, message); if (arg1 == "all" || arg1 == "everyone") { if (!player.player.admin) { player.SendChatMessage(MsgNoPerm); return; } for (var i = 0; i < 6; i++) { player.SendChatMessage(" "); } player.SendChatMessage($"<color={argColor}>{player.playerData.username}</color><color={warningColor}> Cleared the chat for everyone.</color>"); } else { for (var i = 0; i < 6; i++) { player.SendChatMessage(" "); } player.SendChatMessage($"<color={warningColor}>Cleared the chat for yourself.</color>"); } }
public static void Run(SvPlayer player, string message) { string arg1 = GetArgument.Run(1, false, false, message); string arg2 = GetArgument.Run(2, false, false, message); if (string.IsNullOrEmpty(arg1)) { player.SendChatMessage(ArgRequired); return; } if (string.IsNullOrWhiteSpace(arg2)) { arg2 = "1"; } bool parsedSuccessfully = int.TryParse(arg1, out int arg1int); parsedSuccessfully = int.TryParse(arg2, out int arg2int); if (!parsedSuccessfully) { player.SendChatMessage(NotValidArg); return; } if (arg1int < 0 || arg1int > IDs_Items.Length) { player.SendChatMessage($"<color={errorColor}>Error: The ID must be between 1 and {IDs_Items.Length}.</color>"); return; } player.player.TransferItem(DeltaInv.AddToMe, IDs_Items[arg1int - 1], arg2int, true); player.SendChatMessage($"<color={infoColor}>Giving you item ID: </color><color={argColor}>{arg1}</color>"); }
public void AddCooldown(SvPlayer player, string key) { var PlayerCooldowns = GetCooldowns(player); PlayerCooldowns = PlayerCooldowns ?? new Dictionary <string, DateTimeOffset>(); PlayerCooldowns[key] = DateTimeOffset.Now; player.CustomData.AddOrUpdate(CustomDataKey, PlayerCooldowns); }
public static void SavePosition(this SvPlayer player, Vector3 position, Quaternion rotation, int index) { if (!PlayerList.TryGetValue(player.player.ID, out var playerValue)) { return; } playerValue.LastLocation.Update(position, rotation, index); }
public static string TC(this SvPlayer player, string node, params object[] formatting) { var formatter = new CustomFormatter(Core.Instance.Settings.Messages.ArgColor, Core.Instance.Settings.Messages.InfoColor); return($"<color={Core.Instance.Settings.Messages.InfoColor}>" + (Core.Instance.I18n.Localize(formatter, player.language.code, node, formatting) ?? Core.Instance.I18n.Localize(formatter, "EN", node, formatting) ?? $"{node} [{string.Join(", ", formatting)}]") + "</color>"); }
public static void CloseAndResetFunctionMenu(this SvPlayer player) { player.CloseFunctionMenu(); if (PlayerList.TryGetValue(player.player.ID, out var playerListItem)) { return; } playerListItem.LastMenu = CurrentMenu.None; }
public static bool Run(SvPlayer player, bool allow = true) { if (allow || !(player.player.job is Prisoner)) { return(true); } player.SendChatMessage($"{MsgNoJailAllowed}"); return(false); }
public static void Destroy(SvPlayer player) { Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] [LEAVE] {player.player.username}"); if (!PlayerList.ContainsKey(player.player.ID)) { return; } PlayerList.Remove(player.player.ID); }
public static bool SvEnterPlace(SvPlayer svPlayer, ref int door, ref ShPlayer shPlayer) { if (shPlayer.wantedLevel > Vars.MaxWantedLevel && svPlayer.entity.manager.FindByID <ShDoor>(door) is ShApartment) { svPlayer.ShowMessageInChat($"<color={Vars.MessageColor}>{Vars.CantEnterMessage}</color>"); // TODO return(true); } return(false); }
public static bool Run(SvPlayer player, bool allow = true) { if (allow || player.player.wantedLevel <= 0) { return(true); } player.SendChatMessage($"{MsgNoWantedAllowed}"); return(false); }
public static bool Run(SvPlayer player, bool allow = true) { if (allow || !player.player.IsRestrained()) { return(true); } player.SendChatMessage($"{MsgNoCuffedAllowed}"); return(false); }