Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public static void TellTakeBarricade_Prefix(byte x, byte y, ushort plant, ushort index)
 {
     if (BarricadeManager.tryGetRegion(x, y, plant, out BarricadeRegion barricadeRegion))
     {
         InteractableBed interactableBed = barricadeRegion.drops[index].interactable as InteractableBed;
         if (interactableBed != null)
         {
             var home = HomesHelper.GetPlayerHome(interactableBed.owner, interactableBed);
             if (home != null)
             {
                 HomesHelper.RemoveHome(interactableBed.owner, home);
                 if (PlayerTool.getPlayer(interactableBed.owner) != null)
                 {
                     UnturnedChat.Say(interactableBed.owner, MoreHomesPlugin.Instance.Translate("HomeDestroyed", home.Name),
                                      MoreHomesPlugin.Instance.MessageColor);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        private bool ValidateTeleportation(UnturnedPlayer player, PlayerHome home)
        {
            if (home.InteractableBed == null || home.InteractableBed.owner != player.CSteamID)
            {
                HomesHelper.RemoveHome(player.CSteamID, home);
                UnturnedChat.Say(player, pluginInstance.Translate("BedDestroyed"), pluginInstance.MessageColor);
                return(false);
            }

            if (player.Stance == EPlayerStance.DRIVING)
            {
                UnturnedChat.Say(player, pluginInstance.Translate("WhileDriving"), pluginInstance.MessageColor);
                return(false);
            }

            if (pluginInstance.TeleportationPlugin != null)
            {
                if (!ValitedateRaidAndCombat(player))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player   = (UnturnedPlayer)caller;
            string         homeName = command.ElementAtOrDefault(0);

            if (homeName == null)
            {
                UnturnedChat.Say(caller, pluginInstance.Translate("DestroyHomeFormat"), pluginInstance.MessageColor);
                return;
            }

            PlayerHome home = HomesHelper.GetPlayerHome(player.CSteamID, homeName);

            if (home == null)
            {
                UnturnedChat.Say(caller, pluginInstance.Translate("HomeNotFound", home.Name), pluginInstance.MessageColor);
                return;
            }

            HomesHelper.RemoveHome(player.CSteamID, home);
            home.Destroy();

            UnturnedChat.Say(caller, pluginInstance.Translate("DestroyHomeSuccess", home.Name), pluginInstance.MessageColor);
        }