Ejemplo n.º 1
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;
            }

            if (!HomesHelper.TryRemoveHome(player.CSteamID, home.InteractableBed) || home.InteractableBed == null)
            {
                return;
            }



            BarricadeManager.tryGetInfo(home.InteractableBed.transform, out var x, out var y, out var plant, out var index, out var region);
            if (home.InteractableBed != null)
            {
                BarricadeManager.destroyBarricade(region, x, y, plant, index);
            }

            UnturnedChat.Say(caller, pluginInstance.Translate("DestroyHomeSuccess", home.Name), pluginInstance.MessageColor);
        }
Ejemplo n.º 2
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length < 2)
            {
                UnturnedChat.Say(caller, pluginInstance.Translate("RenameHomeFormat"));
                return;
            }

            var home = HomesHelper.GetPlayerHome(player.CSteamID, command[0]);

            if (home == null)
            {
                UnturnedChat.Say(player, pluginInstance.Translate("HomeNotFound", command[0]), pluginInstance.MessageColor);
                return;
            }

            if (HomesHelper.GetPlayerHome(player.CSteamID, command[1]) != null)
            {
                UnturnedChat.Say(player, pluginInstance.Translate("RenameHomeFail", command[1]), pluginInstance.MessageColor);
                return;
            }

            home.Name = command[1];
            UnturnedChat.Say(player, pluginInstance.Translate("RenameHomeSuccess", command[0], command[1]), pluginInstance.MessageColor);
        }
Ejemplo n.º 3
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.º 4
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            PlayerHome     home;
            UnturnedPlayer player = (UnturnedPlayer)caller;

            home = HomesHelper.GetPlayerHome(player.CSteamID, command.ElementAtOrDefault(0));

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

            if (!ValidateTeleportation(player, home))
            {
                return;
            }

            if (pluginInstance.PlayerCooldowns.TryGetValue(caller.Id, out DateTime cooldownExpire) && cooldownExpire > DateTime.Now)
            {
                UnturnedChat.Say(caller, pluginInstance.Translate("HomeCooldown", System.Math.Round((cooldownExpire - DateTime.Now).TotalSeconds)),
                                 pluginInstance.MessageColor);
                return;
            }

            pluginInstance.PlayerCooldowns[caller.Id] = DateTime.Now.AddSeconds(VipHelper.GetPlayerHomeCooldown(caller.Id));

            float delay = VipHelper.GetPlayerHomeDelay(player.Id);

            if (delay > 0)
            {
                UnturnedChat.Say(caller, pluginInstance.Translate("HomeDelayWarn", delay), pluginInstance.MessageColor);
            }

            TaskDispatcher.QueueOnMainThread(() =>
            {
                if (!ValidateTeleportation(player, home))
                {
                    pluginInstance.PlayerCooldowns.Remove(caller.Id);
                    return;
                }

                if (!player.Player.teleportToLocation(home.LivePosition + new Vector3(0f, pluginInstance.Configuration.Instance.TeleportHeight, 0f), player.Rotation))
                {
                    UnturnedChat.Say(caller, pluginInstance.Translate("HomeTeleportationFailed", home.Name), pluginInstance.MessageColor);
                    pluginInstance.PlayerCooldowns.Remove(caller.Id);
                    return;
                }
                UnturnedChat.Say(caller, pluginInstance.Translate("HomeSuccess", home.Name), pluginInstance.MessageColor);
            }, delay);
        }
Ejemplo n.º 5
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.º 6
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);
        }