private void ViewBackpack(BasePlayer player, string cmd, string[] args) { if (!permission.UserHasPermission(player.UserIDString, "backpacks.admin")) { PrintToChat(player, lang.GetMessage("No Permission", this, player.UserIDString)); return; } if (args.Length != 1) { PrintToChat(player, "Syntax: /viewbackpack <steamid>"); return; } ulong id; if (!ulong.TryParse(args[0], out id) || !args[0].StartsWith("7656119") || args[0].Length != 17) { PrintToChat(player, $"{args[0]} is not a valid SteamID (64)!"); return; } Backpack backpack = Backpack.LoadOrCreate(id); if (backpack.IsOpen) { PrintToChat(player, lang.GetMessage("Backpack Already Open", this, player.UserIDString)); return; } timer.Once(0.5f, () => backpack.Open(player)); }
private void OpenBackpackChatCommand(BasePlayer player, string cmd, string[] args) { if (permission.UserHasPermission(player.UserIDString, "backpacks.use")) { timer.Once(0.1f, () => Backpack.LoadOrCreate(player.userID).Open(player)); } else { PrintToChat(player, lang.GetMessage("No Permission", this, player.UserIDString)); } }
private void OpenBackpackConsoleCommand(ConsoleSystem.Arg arg) { if (arg.Player() == null) { return; } BasePlayer player = arg.Player(); if (permission.UserHasPermission(player.UserIDString, "backpacks.use")) { Backpack.LoadOrCreate(player.userID).Open(player); } }
private void OnPlayerInit(BasePlayer player) { Backpack backpack = Backpack.LoadOrCreate(player.userID); if (permission.UserHasPermission(player.UserIDString, "backpacks.use") && Configuration.ShowOnBack) { if (backpack.Inventory.Items.Count == 0 && Configuration.HideOnBackIfEmpty) { return; } backpack.SpawnVisual(player); } }
private void OnUserPermissionGranted(string id, string perm) { if (perm == "backpacks.use" && Configuration.ShowOnBack) { BasePlayer player = BasePlayer.Find(id); Backpack backpack = Backpack.LoadOrCreate(player.userID); if (backpack.Inventory.Items.Count == 0 && Configuration.HideOnBackIfEmpty) { return; } backpack.SpawnVisual(player); } }
private void OnPlayerInit(BasePlayer player) { Backpack backpack = Backpack.LoadOrCreate(player.userID); //=====> Bind hotkey player.SendConsoleCommand($"bind {Configuration.BackpackHotkey} backpack.open"); //=====> Spawn visual backpack if (permission.UserHasPermission(player.UserIDString, "backpacks.use") && Configuration.ShowOnBack) { if (backpack.Inventory.Items.Count == 0 && Configuration.HideOnBackIfEmpty) { return; } backpack.SpawnVisual(player); } }
private void OnEntityDeath(BaseCombatEntity victim, HitInfo info) { if (victim is BasePlayer) { BasePlayer player = (BasePlayer)victim; Backpack backpack = Backpack.LoadOrCreate(player.userID); backpack.ForceClose(); if (Configuration.EraseOnDeath) { backpack.EraseContents(); } else if (Configuration.DropOnDeath) { backpack.Drop(player.transform.position); } } }
private void OnEntityDeath(BaseCombatEntity victim, HitInfo info) { if (victim is BasePlayer && !(victim is NPCPlayer || victim is NPCPlayerApex || victim is NPCPlayer || victim is NPCMurderer || victim.name.Contains("/npc/scientist/htn"))) { var player = (BasePlayer)victim; var backpack = Backpack.LoadOrCreate(player.userID); backpack.ForceClose(); if (Configuration.EraseOnDeath) { backpack.EraseContents(); } else if (Configuration.DropOnDeath) { backpack.Drop(player.transform.position); } } }