コード例 #1
0
        public static VehicleData ReadLightVehicleSync(byte[] array)
        {
            var data = new VehicleData();
            var r    = new BitReader(array);

            // Read player nethandle
            data.NetHandle = r.ReadInt32();

            // read model
            data.PedModelHash = r.ReadInt32();

            // read vehicle handle
            data.VehicleHandle = r.ReadInt32();

            // read vehicle seat
            data.VehicleSeat = (sbyte)r.ReadByte();

            // read gun model.
            data.WeaponHash = r.ReadInt32();

            // Read vehicle damage model
            if (r.ReadBoolean())
            {
                data.DamageModel               = new VehicleDamageModel();
                data.DamageModel.BrokenDoors   = r.ReadByte();
                data.DamageModel.BrokenWindows = r.ReadByte();
                data.DamageModel.BrokenLights  = r.ReadInt32();
            }

            // Does he have a traielr?
            if (r.ReadBoolean())
            {
                Vector3 trailerPos = new Vector3();

                trailerPos.X = r.ReadSingle();
                trailerPos.Y = r.ReadSingle();
                trailerPos.Z = r.ReadSingle();

                data.Trailer = trailerPos;
            }

            // Try to read latency
            if (r.CanRead(2))
            {
                var latency = r.ReadInt16();
                data.Latency = latency / 1000f;
            }

            return(data);
        }
コード例 #2
0
        public static VehicleData ReadUnoccupiedVehicleSync(byte[] array)
        {
            var r    = new BitReader(array);
            var data = new VehicleData();

            // Read vehicle's nethandle.
            data.VehicleHandle = r.ReadInt32();

            // Read position, rotation and velocity.
            Vector3 position = new Vector3();
            Vector3 rotation = new Vector3();
            Vector3 velocity = new Vector3();

            position.X = r.ReadSingle();
            position.Y = r.ReadSingle();
            position.Z = r.ReadSingle();

            rotation.X = r.ReadSingle();
            rotation.Y = r.ReadSingle();
            rotation.Z = r.ReadSingle();

            velocity.X = r.ReadSingle();
            velocity.Y = r.ReadSingle();
            velocity.Z = r.ReadSingle();

            data.Position   = position;
            data.Quaternion = rotation;
            data.Velocity   = velocity;

            // Read vehicle health
            data.VehicleHealth = r.ReadInt16();

            // Read is dead
            if (r.ReadBoolean())
            {
                data.Flag = (short)VehicleDataFlags.VehicleDead;
            }
            else
            {
                data.Flag = 0;
            }

            // Read tyre states
            data.PlayerHealth = r.ReadByte();

            // Read vehicle damage model
            data.DamageModel               = new VehicleDamageModel();
            data.DamageModel.BrokenDoors   = r.ReadByte();
            data.DamageModel.BrokenWindows = r.ReadByte();

            return(data);
        }
コード例 #3
0
        public static bool ReadBulletSync(byte[] array, out int netHandle, out int netHandleTarget)
        {
            var r = new BitReader(array);

            // read netHandle
            netHandle = r.ReadInt32();

            // read whether he's shooting
            bool output = r.ReadBoolean();

            netHandleTarget = 0;

            // read aiming point
            if (output)
            {
                netHandleTarget = r.ReadInt32();
            }
            return(output);
        }
コード例 #4
0
        public static bool ReadBulletSync(byte[] array, out int netHandle, out Vector3 position)
        {
            var r = new BitReader(array);

            // read netHandle
            netHandle = r.ReadInt32();

            // read whether he's shooting
            bool output = r.ReadBoolean();

            position = new Vector3();

            // read aiming point
            if (output)
            {
                position.X = r.ReadSingle();
                position.Y = r.ReadSingle();
                position.Z = r.ReadSingle();
            }
            return(output);
        }