Exemple #1
0
        public void OnEvent(ShPlayer player, string message)
        {
            if (chatted.Limit(player))
            {
                return;
            }

            if (player.GetExtendedPlayer().Muted)
            {
                player.TS("muted_player");
                return;
            }

            if (CommandHandler.OnEvent(player, message)) // 'true' if message starts with command prefix
            {
                return;
            }

            Core.Instance.Logger.LogInfo($"[GLOBAL] {player.username}: {message}");

            switch (player.GetExtendedPlayer().CurrentChat)
            {
            case Chat.StaffChat:
                ChatUtils.SendStaffChatMessage(player, message);
                return;

            case Chat.Disabled:
                player.TS("chat_disabled");
                return;

            default:
                ChatUtils.SendToAllEnabledChat(ChatUtils.FormatMessage(player, message), false);
                return;
            }
        }
Exemple #2
0
        public void Invoke(ShPlayer player, ShPlayer target)
        {
            var lastlocation = target.GetExtendedPlayer().LastLocation;

            if (!lastlocation.HasPositionSet())
            {
                player.TS("no_tp_location");
                return;
            }
            target.GetExtendedPlayer().ResetAndSavePosition(lastlocation.Position, lastlocation.Rotation, lastlocation.PlaceIndex);
            target.SendChatMessage("You've been teleported to your last known location.");
        }
Exemple #3
0
        public void Invoke(ShPlayer player)
        {
            var ePlayer = player.GetExtendedPlayer();

            ePlayer.CurrentChat = ePlayer.CurrentChat == Chat.Disabled ? Chat.Global : Chat.Disabled;
            player.TS("chat_mode_set", ePlayer.CurrentChat.ToString().ToLowerInvariant());
        }
Exemple #4
0
        public void Invoke(ShPlayer player, string message)
        {
            var ePlayer = player.GetExtendedPlayer();

            if (ePlayer.ReplyToUser == null)
            {
                player.TS("no_user_found_or_offline");
                return;
            }
            var eTarget = ePlayer.ReplyToUser.GetExtendedPlayer();

            if (eTarget.CurrentChat == Chat.Disabled)
            {
                player.SendChatMessage($"{player.T("user_has_chat_disabled")} {player.T("message_not_sent")}");
                return;
            }
            player.GetExtendedPlayer().SendPmMessage(eTarget, message);
        }
Exemple #5
0
        public void Invoke(ShPlayer player, ShPlayer target = null)
        {
            target = target ?? player;
            var eTarget = target.GetExtendedPlayer();

            eTarget.HasGodmode = !eTarget.HasGodmode;
            player.TS("godmode_toggle", target.username.SanitizeString(),
                      eTarget.HasGodmode.Stringify(player.T("enabled"), player.T("disabled"))
                      );
        }
 public void Invoke(ShPlayer player, float x, float y, float z, int placeIndex = 0)
 {
     if (placeIndex < 0 || placeIndex > (Core.Instance.SvManager.fixedPlaces.Count + Core.Instance.SvManager.apartments.Count))
     {
         player.TS("TeleportCoordinates_invalidPlaceIndex", placeIndex.ToString());
         return;
     }
     player.GetExtendedPlayer().ResetAndSavePosition(new Vector3(x, y, z), player.GetRotation, placeIndex);
     player.TS("TeleportCoordinates", x.ToString(CultureInfo.InvariantCulture), y.ToString(CultureInfo.InvariantCulture), z.ToString(CultureInfo.InvariantCulture), placeIndex.ToString());
 }
Exemple #7
0
 public void OnEvent(ShPlayer player, DamageIndex damageIndex, float amount, ShPlayer attacker, Collider collider)
 {
     if (!player.isHuman)
     {
         return;
     }
     if (player.GetExtendedPlayer().HasGodmode)
     {
         player.SendChatMessage($"Damage blocked: {amount}HP. (Attacker: {attacker.ID}: {attacker.username.SanitizeString()})");
     }
 }
Exemple #8
0
        public void Invoke(ShPlayer player, string warp)
        {
            var obj = Core.Instance.WarpHandler.List.FirstOrDefault(x => x.Name.Equals(warp, StringComparison.OrdinalIgnoreCase));

            if (obj == null)
            {
                if (Core.Instance.Settings.Levenshtein.WarpMode == Configuration.Models.SettingsModel.LevenshteinMode.None)
                {
                    player.TS("expFileHandler_error_notFound", player.T(Core.Instance.WarpHandler.Name), warp);
                    return;
                }
                obj = Core.Instance.WarpHandler.List.OrderByDescending(x => LevenshteinDistance.CalculateSimilarity(x.Name, warp)).FirstOrDefault();

                if (Core.Instance.Settings.Levenshtein.WarpMode == Configuration.Models.SettingsModel.LevenshteinMode.Suggest)
                {
                    player.TS("expFileHandler_error_notFound", player.T(Core.Instance.WarpHandler.Name), warp);
                    player.TS("levenshteinSuggest", obj.Name);
                    return;
                }
            }
            if (!player.svPlayer.HasPermission($"{Core.Instance.Info.GroupNamespace}.{Core.Instance.WarpHandler.Name}.{obj.Name}"))
            {
                player.TS("expFileHandler_error_noPermission", player.T(Core.Instance.WarpHandler.Name), obj.Name);
                return;
            }
            if (obj.Disabled)
            {
                player.TS("expFileHandler_error_disabled", player.T(Core.Instance.WarpHandler.Name), obj.Name);
                return;
            }
            if (Core.Instance.WarpsCooldownHandler.IsCooldown(player.svPlayer, obj.Name, obj.Delay))
            {
                player.TS("expFileHandler_error_cooldown", player.T(Core.Instance.WarpHandler.Name), Core.Instance.WarpsCooldownHandler.GetCooldown(player.svPlayer, obj.Name, obj.Delay).ToString());
                return;
            }
            if (obj.Price > 0)
            {
                if (player.MyMoneyCount < obj.Price)
                {
                    player.TS("expFileHandler_error_price", player.T(Core.Instance.WarpHandler.Name), obj.Price.ToString(), player.MyMoneyCount.ToString());
                    return;
                }
                player.TransferMoney(DeltaInv.RemoveFromMe, obj.Price, true);
            }
            player.GetExtendedPlayer().ResetAndSavePosition(obj.Position.SerializableVector3.ToVector3(), obj.SerializableQuaternion.ToQuaternion(), obj.Position.PlaceIndex);
            if (obj.Delay > 0)
            {
                Core.Instance.WarpsCooldownHandler.AddCooldown(player.svPlayer, obj.Name);
            }
            player.SendChatMessage(
                player.TC(Core.Instance.WarpHandler.Name + "_teleported", obj.Name) +
                (obj.Price > 0 ? player.TC(Core.Instance.WarpHandler.Name + "_telported_Price", obj.Price.ToString()) : "") +
                (obj.Delay > 0 ? player.TC(Core.Instance.WarpHandler.Name + "_telported_Delay", obj.Delay.ToString()) : ""));
        }
Exemple #9
0
        public void Invoke(ShPlayer player, ShPlayer target, string message)
        {
            var eTarget = target.GetExtendedPlayer();

            if (eTarget.CurrentChat == Chat.Disabled)
            {
                player.SendChatMessage($"{player.T("user_has_chat_disabled")} {player.T("message_not_sent")}");
                return;
            }
            player.GetExtendedPlayer().SendPmMessage(eTarget, message);
        }
Exemple #10
0
        public void Invoke(ShPlayer player, ShPlayer target)
        {
            var eTarget = target.GetExtendedPlayer();

            eTarget.TpaUser = player;
            player.SendChatMessage($"{player.T("player_tpa_sent", target.username.CleanerMessage())}  {(eTarget.CurrentChat == Chat.Disabled ? player.T("player_tpa_chat_disabled") : "")}");
            if (eTarget.CurrentChat == Chat.Disabled)
            {
                return;
            }
            target.TS("target_tpa_sent", player.username.CleanerMessage());
        }
Exemple #11
0
        public void Invoke(ShPlayer player)
        {
            var ePlayer = player.GetExtendedPlayer();

            if (ePlayer.TpaUser == null)
            {
                player.TS("no_tpa_requests");
                return;
            }
            ePlayer.TpaUser.TS("TpaUser_tpa_denied", player.username.SanitizeString());
            player.TS("player_tpa_denied", ePlayer.TpaUser.username.SanitizeString());
            ePlayer.TpaUser = null;
        }
Exemple #12
0
        public void Invoke(ShPlayer player)
        {
            var ePlayer = player.GetExtendedPlayer();

            ePlayer.EnabledBypass = !ePlayer.EnabledBypass;
            if (ePlayer.EnabledBypass)
            {
                player.TS("bypass_enabled");
            }
            else
            {
                player.TS("bypass_disabled");
            }
        }
Exemple #13
0
        public void Invoke(ShPlayer player)
        {
            var ePlayer = player.GetExtendedPlayer();

            if (ePlayer.TpaUser == null)
            {
                player.TS("no_tpa_requests");
                return;
            }
            ePlayer.TpaUser.TS("TpaUser_tpa_accepted", player.username.SanitizeString());
            player.TS("player_tpa_accepted", ePlayer.TpaUser.username.SanitizeString());
            ePlayer.TpaUser.GetExtendedPlayer().ResetAndSavePosition(player);
            ePlayer.TpaUser = null;
        }
Exemple #14
0
        public void Invoke(ShPlayer player)
        {
            var ePlayer = player.GetExtendedPlayer();

            ePlayer.EnabledSpychat = !ePlayer.EnabledSpychat;
            if (ePlayer.EnabledSpychat)
            {
                player.TS("spy_chat_enabled");
            }
            else
            {
                player.TS("spy_chat_disabled");
            }
        }
Exemple #15
0
        public void Invoke(ShPlayer player, ShPlayer target)
        {
            var eTarget = target.GetExtendedPlayer();

            if (eTarget.CurrentChat == Enums.Chat.Muted)
            {
                eTarget.CurrentChat = Enums.Chat.Global;
                player.TS("player_unmuted", target.username);
            }
            else
            {
                eTarget.CurrentChat = Enums.Chat.Muted;
                player.TS("player_muted", target.username);
            }
        }
Exemple #16
0
        public void Invoke(ShPlayer player, ShPlayer target)
        {
            var eTarget = target.GetExtendedPlayer();

            if (eTarget.Muted)
            {
                player.TS("player_unmuted", target.username);
            }
            else
            {
                player.TS("player_muted", target.username);
            }

            eTarget.Muted = !eTarget.Muted;
        }
Exemple #17
0
        public void Invoke(ShPlayer player, string warp)
        {
            var obj = Core.Instance.WarpHandler.List.FirstOrDefault(x => x.Name == warp);

            if (obj == null)
            {
                player.TS("expFileHandler_error_notFound", player.T(Core.Instance.WarpHandler.Name), warp);
                return;
            }
            if (!player.svPlayer.HasPermission($"{Core.Instance.Info.GroupNamespace}.{Core.Instance.WarpHandler.Name}.{warp}"))
            {
                player.TS("expFileHandler_error_noPermission", player.T(Core.Instance.WarpHandler.Name), warp);
                return;
            }
            if (obj.Disabled)
            {
                player.TS("expFileHandler_error_disabled", player.T(Core.Instance.WarpHandler.Name), warp);
                return;
            }
            if (player.HasCooldown(Core.Instance.WarpHandler.Name, warp))
            {
                player.TS("expFileHandler_error_cooldown", player.T(Core.Instance.WarpHandler.Name), player.GetCooldown(Core.Instance.WarpHandler.Name, warp).ToString());
                return;
            }
            if (obj.Price > 0)
            {
                if (player.MyMoneyCount() < obj.Price)
                {
                    player.TS("expFileHandler_error_price", player.T(Core.Instance.WarpHandler.Name), obj.Price.ToString(), player.MyMoneyCount().ToString());
                    return;
                }
                player.TransferMoney(DeltaInv.RemoveFromMe, obj.Price, true);
            }
            player.GetExtendedPlayer().ResetAndSavePosition(obj.Position.SerializableVector3.ToVector3(), obj.SerializableQuaternion.ToQuaternion(), obj.Position.PlaceIndex);
            if (obj.Delay > 0)
            {
                player.AddCooldown(Core.Instance.WarpHandler.Name, warp, obj.Delay);
            }
            player.SendChatMessage(
                player.T(Core.Instance.WarpHandler.Name + "_teleported", warp) +
                (obj.Price > 0 ? player.T(Core.Instance.WarpHandler.Name + "_telported_Price", obj.Price.ToString()) : "") +
                (obj.Delay > 0 ? player.T(Core.Instance.WarpHandler.Name + "_telported_Delay", obj.Delay.ToString()) : ""));
        }
Exemple #18
0
        public void Invoke(ShPlayer player, string text = "")
        {
            var ePlayer = player.GetExtendedPlayer();

            if (string.IsNullOrWhiteSpace(text))
            {
                if (ePlayer.CurrentChat == Enums.Chat.StaffChat)
                {
                    ePlayer.CurrentChat = Enums.Chat.Global;
                    player.TS("staff_chat_disabled");
                }
                else
                {
                    ePlayer.CurrentChat = Enums.Chat.StaffChat;
                    player.TS("staff_chat_enabled");
                }
                return;
            }
            ChatUtils.SendStaffChatMessage(player, text);
        }
Exemple #19
0
        public void OnEvent(ShPlayer player, string message)
        {
            if (message.StartsWith(CommandHandler.Prefix))
            {
                return;
            }
            Core.Instance.Logger.LogInfo($"[GLOBAL] {player.username}: {message}");
            switch (player.GetExtendedPlayer().CurrentChat)
            {
            case Chat.StaffChat:
                ChatUtils.SendStaffChatMessage(player, message);
                return;

            case Chat.Disabled:
                player.TS("chat_disabled");
                return;

            default:
                ChatUtils.SendToAllEnabledChat(ChatUtils.FormatMessage(player, message), false);
                return;
            }
        }
Exemple #20
0
        public void Invoke(ShPlayer player, ShPlayer target, float timeInSeconds)
        {
            var jail = Core.Instance.SvManager.jails.GetRandom();

            if (jail == null)
            {
                return;
            }
            if (target.IsDead || target.svPlayer.job.info.shared.jobIndex == BPAPI.Instance.PrisonerIndex)
            {
                return;
            }
            var getPositionT = jail.mainT;

            target.svPlayer.SvTrySetJob(BPAPI.Instance.PrisonerIndex, true, false);
            target.GetExtendedPlayer().ResetAndSavePosition(getPositionT.position, getPositionT.rotation, 0);
            target.svPlayer.SvClearCrimes();
            target.svPlayer.RemoveItemsJail();
            target.StartCoroutine(target.svPlayer.JailTimer(timeInSeconds));
            target.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowTimer, timeInSeconds);
            player.TS("player_jail", target.username.CleanerMessage(), timeInSeconds);
            target.TS("target_jail", player.username.CleanerMessage(), timeInSeconds);
        }
Exemple #21
0
        public void Invoke(ShPlayer player, int homeNumber = 1)
        {
            var apartments = new List <ShApartment>(player.ownedApartments.Keys);

            if (apartments.Count < homeNumber)
            {
                player.TS("you_only_own", apartments.Count.ToString());
                return;
            }

            if (apartments.Count == 0)
            {
                player.TS("no_appartments");
                return;
            }
            var offset    = new Vector3(-1, 0, -1);
            var apartment = apartments[Math.Max(0, --homeNumber)];

            if (apartment.GetRotation.y < 0.9)
            {
                offset = new Vector3(1, 0, 2);
            }
            player.GetExtendedPlayer().ResetAndSavePosition(apartment.GetPosition + offset, apartment.GetRotation, apartment.GetPlaceIndex);
        }
Exemple #22
0
 public void Invoke(ShPlayer player, ShPlayer target)
 {
     player.GetExtendedPlayer().ResetAndSavePosition(target);
     player.TS("tp_to", target.username.SanitizeString());
 }
Exemple #23
0
 public void Invoke(ShPlayer player, ShPlayer target)
 {
     target.GetExtendedPlayer().ResetAndSavePosition(player);
     player.TS("player_tph", target.username.SanitizeString());
     target.TS("target_tph", player.username.SanitizeString());
 }
Exemple #24
0
 public void Invoke(ShPlayer player, ShPlayer target)
 {
     target.GetExtendedPlayer().ResetAndSavePosition(player);
     player.TS("player_tph", target.username.CleanerMessage());
     target.TS("target_tph", player.username.CleanerMessage());
 }
Exemple #25
0
 public void Invoke(ShPlayer player, ShPlayer target)
 {
     player.GetExtendedPlayer().ResetAndSavePosition(target);
     player.TS("tp_to", target.username.CleanerMessage());
 }