Ejemplo n.º 1
0
        public void askChat(CSteamID steamID, byte mode, string text)
        {
            // Set the variables
            bool           cancel = false;
            UnturnedPlayer player = UnturnedPlayer.Get(steamID);

            // Run methods
            ChatEvents.RunChatted(ref player, ref mode, ref text, ref cancel);

            // Do checks
            if (player?.SteamID == null || player.SteamID == CSteamID.Nil)
            {
                return;
            }
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            if (cancel)
            {
                return;
            }

            // Restore original
            DetourManager.CallOriginal(typeof(CM).GetMethod("askChat", BindingFlags.Public | BindingFlags.Instance), CM.instance, player.SteamID, mode, text);
        }
Ejemplo n.º 2
0
        private void OnPacketSend(ref CSteamID steamID, ref ESteamPacket type, ref byte[] packet, ref int size, ref int channel, ref bool cancel)
        {
            if (type != ESteamPacket.CONNECTED)
            {
                return;
            }

            object[] info = SteamPacker.getObjects(steamID, 0, 0, packet, new Type[]
            {
                Types.BYTE_TYPE,
                Types.STEAM_ID_TYPE,
                Types.BYTE_TYPE,
                Types.STRING_TYPE,
                Types.STRING_TYPE,
                Types.VECTOR3_TYPE,
                Types.BYTE_TYPE,
                Types.BOOLEAN_TYPE,
                Types.BOOLEAN_TYPE,
                Types.INT32_TYPE,
                Types.STEAM_ID_TYPE,
                Types.STRING_TYPE,
                Types.BYTE_TYPE,
                Types.BYTE_TYPE,
                Types.BYTE_TYPE,
                Types.COLOR_TYPE,
                Types.COLOR_TYPE,
                Types.BOOLEAN_TYPE,
                Types.INT32_TYPE,
                Types.INT32_TYPE,
                Types.INT32_TYPE,
                Types.INT32_TYPE,
                Types.INT32_TYPE,
                Types.INT32_TYPE,
                Types.INT32_TYPE,
                Types.INT32_ARRAY_TYPE,
                Types.BYTE_TYPE,
                Types.STRING_TYPE
            });
            UnturnedPlayer player = UnturnedPlayer.Get((CSteamID)info[1]);

            if (player.SteamID != steamID)
            {
                info[3]  = player.PlayerName;
                info[4]  = player.CharacterName;
                info[11] = player.NickName;
            }
            else
            {
                info[3]  = player.PlayerName;
                info[4]  = player.UnturnedCharacterName;
                info[11] = player.UnturnedNickName;
            }

            packet = SteamPacker.getBytes(0, out size, info);
        }
Ejemplo n.º 3
0
        private void OnUnturnedCommand(SteamPlayer player, string text, ref bool shouldExecuteCommand, ref bool shouldList)
        {
            shouldExecuteCommand = false;
            if (!text.StartsWith("/") && !text.StartsWith("@"))
            {
                return;
            }
            shouldList = false;

            CM.ExecuteCommand(text, UnturnedPlayer.Get(player));
        }
Ejemplo n.º 4
0
        private void OnPlayerChat(SteamPlayer player, EChatMode mode, ref UnityEngine.Color color, string text, ref bool visible)
        {
            UnturnedPlayer ply = UnturnedPlayer.Get(player);

            UnityEngine.Color c = ply.GetColor();

            if (c != UnityEngine.Color.clear)
            {
                color = c;
            }
        }
Ejemplo n.º 5
0
        private static void doDamage(this PlayerLife life, byte amount, Vector3 newRagdoll, EDeathCause newCause, ELimb newLimb, CSteamID newKiller, out EPlayerKill kill)
        {
            UnturnedPlayer ply    = UnturnedPlayer.Get(newKiller);
            bool           cancel = false;

            kill = EPlayerKill.NONE;

            PlayerEvents.RunPlayerHurt(life.channel.owner, ref amount, ref newCause, ref newLimb, ref ply, ref cancel);

            if (cancel)
            {
                return;
            }

            object[] paramaters = new object[] { amount, newRagdoll, newCause, newLimb, newKiller, null };
            DetourManager.CallOriginal(typeof(PlayerLife).GetMethod("doDamage", BindingFlags.NonPublic | BindingFlags.Instance), life, paramaters);
            kill = (EPlayerKill)paramaters[5];
        }
Ejemplo n.º 6
0
        public static void tellSkill(this PlayerSkills Skills, CSteamID steamID, byte speciality, byte index, byte level)
        {
            if (!Skills.channel.checkServer(steamID))
            {
                return;
            }
            if (index >= Skills.skills[speciality].Length)
            {
                return;
            }

            UnturnedPlayer Player = UnturnedPlayer.Get(Skills.player);

            PlayerEvents.RunPlayerSkillUpgrade(Player, speciality, index, level);

            DetourManager.CallOriginal(typeof(PlayerSkills).GetMethod("tellSkill", BindingFlags.Instance | BindingFlags.Public),
                                       Skills, steamID, speciality, index, level);
        }
Ejemplo n.º 7
0
        private void OnPacketSent(ref CSteamID steamID, ref ESteamPacket type, ref byte[] packet, ref int size, ref int channel, ref bool cancel)
        {
            if (type == ESteamPacket.CONNECTED)
            {
                object[] info = SteamPacker.getObjects(steamID, 0, 0, packet, new Type[]
                {
                    Typ.BYTE_TYPE,
                    Typ.STEAM_ID_TYPE,
                    Typ.BYTE_TYPE,
                    Typ.STRING_TYPE,
                    Typ.STRING_TYPE,
                    Typ.VECTOR3_TYPE,
                    Typ.BYTE_TYPE,
                    Typ.BOOLEAN_TYPE,
                    Typ.BOOLEAN_TYPE,
                    Typ.INT32_TYPE,
                    Typ.STEAM_ID_TYPE,
                    Typ.STRING_TYPE,
                    Typ.BYTE_TYPE,
                    Typ.BYTE_TYPE,
                    Typ.BYTE_TYPE,
                    Typ.COLOR_TYPE,
                    Typ.COLOR_TYPE,
                    Typ.BOOLEAN_TYPE,
                    Typ.INT32_TYPE,
                    Typ.INT32_TYPE,
                    Typ.INT32_TYPE,
                    Typ.INT32_TYPE,
                    Typ.INT32_TYPE,
                    Typ.INT32_TYPE,
                    Typ.INT32_TYPE,
                    Typ.INT32_ARRAY_TYPE,
                    Typ.BYTE_TYPE,
                    Typ.STRING_TYPE
                });
                UnturnedPlayer player = UnturnedPlayer.Get((CSteamID)info[1]);

                if (player.Metadata.ContainsKey("Vanish"))
                {
                    cancel = true;
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Tries to convert the steam id to unturned player instance
 /// </summary>
 /// <param name="player">The steam id instance</param>
 /// <returns>The unturned player instance gotten from the steam id instance</returns>
 public static UnturnedPlayer ToUnturnedPlayer(this CSteamID player) => UnturnedPlayer.Get(player);
Ejemplo n.º 9
0
 /// <summary>
 /// Tries to convert the arena player to unturned player instance
 /// </summary>
 /// <param name="player">The arena player instance</param>
 /// <returns>The unturned player instance gotten from the arena player instance</returns>
 public static UnturnedPlayer ToUnturnedPlayer(this ArenaPlayer player) => UnturnedPlayer.Get(player);
Ejemplo n.º 10
0
 /// <summary>
 /// Tries to convert the player to unturned player instance
 /// </summary>
 /// <param name="player">The player instance</param>
 /// <returns>The unturned player instance gotten from the player instance</returns>
 public static UnturnedPlayer ToUnturnedPlayer(this SDG.Unturned.Player player) => UnturnedPlayer.Get(player);
Ejemplo n.º 11
0
 /// <summary>
 /// Tries to convert the steam player to unturned player instance
 /// </summary>
 /// <param name="player">The steam player instance</param>
 /// <returns>The unturned player instance gotten from the steam player</returns>
 public static UnturnedPlayer ToUnturnedPlayer(this SteamPlayer player) => UnturnedPlayer.Get(player);