public static bool AskClaimBed_Prefix(BarricadeManager __instance, CSteamID steamID, byte x, byte y, ushort plant, ushort index) { BarricadeRegion barricadeRegion; if (Provider.isServer && BarricadeManager.tryGetRegion(x, y, plant, out barricadeRegion)) { Player player = PlayerTool.getPlayer(steamID); if (player == null) { return(false); } if (player.life.isDead) { return(false); } if (index >= barricadeRegion.drops.Count) { return(false); } if ((barricadeRegion.drops[index].model.transform.position - player.transform.position).sqrMagnitude > 400f) { return(false); } InteractableBed interactableBed = barricadeRegion.drops[index].interactable as InteractableBed; if (interactableBed != null && interactableBed.isClaimable && interactableBed.checkClaim(player.channel.owner.playerID.steamID)) { if (interactableBed.isClaimed) { var home = HomesHelper.GetPlayerHome(steamID, interactableBed); HomesHelper.RemoveHome(steamID, home); home.Unclaim(); } else { var playerData = HomesHelper.GetOrCreatePlayer(steamID); int maxHomes = VipHelper.GetPlayerMaxHomes(steamID.ToString()); if (maxHomes == 1 && playerData.Homes.Count == 1) { foreach (var home in playerData.Homes.ToArray()) { HomesHelper.RemoveHome(steamID, home); home.Unclaim(); } } else if (maxHomes <= playerData.Homes.Count) { UnturnedChat.Say(steamID, MoreHomesPlugin.Instance.Translate("MaxHomesWarn"), MoreHomesPlugin.Instance.MessageColor); return(false); } var playerHome = new PlayerHome(playerData.GetUniqueHomeName(), interactableBed); playerData.Homes.Add(playerHome); playerHome.Claim(steamID); UnturnedChat.Say(steamID, MoreHomesPlugin.Instance.Translate("HomeClaimed", playerHome.Name), MoreHomesPlugin.Instance.MessageColor); } } } return(false); }
public void Execute(IRocketPlayer caller, string[] command) { int num = 0; HomesHelper.ClearHomes(); foreach (BarricadeRegion region in BarricadeManager.regions) { foreach (BarricadeDrop drop in region.drops) { InteractableBed interactableBed = drop.interactable as InteractableBed; if (interactableBed != null && interactableBed.isClaimed) { var player = HomesHelper.GetOrCreatePlayer(interactableBed.owner); var playerHome = new PlayerHome(player.GetUniqueHomeName(), interactableBed); player.Homes.Add(playerHome); num++; } } } pluginInstance.DataService.SaveData(); UnturnedChat.Say(caller, pluginInstance.Translate("RestoreHomesSuccess", num), pluginInstance.MessageColor); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; PlayerData playerData = HomesHelper.GetOrCreatePlayer(player.CSteamID); if (playerData.Homes.Count == 0) { UnturnedChat.Say(caller, pluginInstance.Translate("NoHomes"), pluginInstance.MessageColor); return; } StringBuilder sb = new StringBuilder(pluginInstance.Translate("HomeList")); foreach (PlayerHome home in playerData.Homes) { sb.Append($"{home.Name}, "); } string msg = sb.ToString().TrimEnd(',', ' '); UnturnedChat.Say(caller, msg, pluginInstance.MessageColor); }