Пример #1
0
        public void updatePed(uint id, UpdateDataStruct data, StreamedPed ped)
        {
            var posnew = new Vector3(data.pos_x, data.pos_y, data.pos_z - 1.0f);

            ped.position        = posnew;
            ped.heading         = data.heading;
            ped.direction       = new Vector3(data.rot_x, data.rot_y, data.rot_z);
            ped.cameraDirection = new Vector3(data.camdir_x, data.camdir_y, data.camdir_z);
            if (ped.IsStreamedIn() && data.vehicle_id == 0)
            {
                if (ped.gameReference.isInVehicle())
                {
                    ped.gameReference.CurrentVehicle.PassengersLeaveVehicle(true);
                    //ped.gameReference.CurrentVehicle.Delete();
                }

                float   delta  = posnew.DistanceTo(ped.gameReference.Position);
                Vector3 vdelta = posnew - ped.gameReference.Position;
                //ped.gameReference.Weapons.MP5.Ammo = 999;

                int healthDelta = data.ped_health - ped.gameReference.Health;
                ped.gameReference.Health = data.ped_health;
                ped.last_game_health     = data.ped_health;

                if (data.weapon > 0)
                {
                    if (ped.gameReference.Weapons.Current != (Weapon)data.weapon)
                    {
                        ped.gameReference.Weapons.FromType((Weapon)data.weapon).Ammo       = 999;
                        ped.gameReference.Weapons.FromType((Weapon)data.weapon).AmmoInClip = 999;
                        ped.gameReference.Weapons.Select((Weapon)data.weapon);
                    }
                }
                else
                {
                    ped.gameReference.Weapons.RemoveAll();
                }

                if (healthDelta > 20 && healthDelta < 100)
                {
                    var bpf = new BinaryPacketFormatter(Commands.Player_damage);
                    bpf.Add(id);
                    //Client.instance.chatController.writeChat("damaged " + healthDelta) ;
                    Client.instance.serverConnection.write(bpf.getBytes());
                }

                bool cancelPositionUpdate = false;

                if ((data.state & PlayerState.IsShooting) != 0)
                {
                    ped.animator.playAnimation(PedAnimations.Shoot);
                    cancelPositionUpdate = true;
                }
                else
                if ((data.state & PlayerState.IsAiming) != 0)
                {
                    ped.animator.playAnimation(PedAnimations.Aim);
                    cancelPositionUpdate = true;
                }
                else
                if ((data.state & PlayerState.IsRagdoll) != 0 || data.ped_health <= 0)
                {
                    ped.animator.playAnimation(PedAnimations.Ragdoll);
                    ped.gameReference.Velocity = new Vector3(data.vel_x, data.vel_y, data.vel_z);
                    cancelPositionUpdate       = true;
                }
                else
                if ((data.vstate & VehicleState.IsEnteringVehicle) != 0)
                {
                    ped.animator.playAnimation(PedAnimations.EnterClosestVehicle);
                    cancelPositionUpdate = true;
                }
                else
                if ((data.state & PlayerState.IsCrouching) != 0)
                {
                    ped.animator.playAnimation(PedAnimations.Couch);
                }
                else
                {
                    if ((data.vstate & VehicleState.IsAccelerating) != 0)
                    {
                        if ((data.vstate & VehicleState.IsSprinting) != 0)
                        {
                            ped.animator.playAnimation(PedAnimations.Run);
                        }
                        else
                        {
                            ped.animator.playAnimation(PedAnimations.Walk);
                        }
                    }
                    else
                    {
                        ped.animator.playAnimation(PedAnimations.StandStill);
                    }
                }

                if (!cancelPositionUpdate)
                {
                    ped.gameReference.Position = posnew;
                }
                ped.gameReference.Heading = data.heading;

                //ped.gameReference.Velocity = new Vector3(elemValue.vel_x, elemValue.vel_y, elemValue.vel_z);
                //ped.gameReference.Task.ClearAllImmediately();
            }
        }
Пример #2
0
        public void updateVehicle(uint id, UpdateDataStruct data, StreamedPed ped)
        {
            if (data.vehicle_id > 0)
            {
                var             posnew = new Vector3(data.pos_x, data.pos_y, data.pos_z);
                StreamedVehicle veh    = vehicleController.GetInstance(data.vehicle_id);
                if (veh != null)
                {
                    if (veh.IsStreamedIn())
                    {
                        if (ped != null && ped.IsStreamedIn() && !ped.gameReference.isInVehicle())
                        {
                            if ((data.state & PlayerState.IsPassenger1) != 0)
                            {
                                ped.gameReference.WarpIntoVehicle(veh.gameReference, VehicleSeat.RightFront);
                            }
                            else if ((data.state & PlayerState.IsPassenger2) != 0)
                            {
                                ped.gameReference.WarpIntoVehicle(veh.gameReference, VehicleSeat.LeftRear);
                            }
                            else if ((data.state & PlayerState.IsPassenger3) != 0)
                            {
                                ped.gameReference.WarpIntoVehicle(veh.gameReference, VehicleSeat.RightFront);
                            }
                            else
                            {
                                ped.gameReference.WarpIntoVehicle(veh.gameReference, VehicleSeat.Driver);
                            }
                        }

                        int healthDelta = data.ped_health - ped.gameReference.Health;
                        ped.gameReference.Health = data.ped_health;
                        ped.last_game_health     = data.ped_health;

                        if (healthDelta > 20 && healthDelta < 100)
                        {
                            var bpf = new BinaryPacketFormatter(Commands.Player_damage);
                            bpf.Add(id);
                            //Client.instance.chatController.writeChat("damaged " + healthDelta) ;
                            Client.instance.serverConnection.write(bpf.getBytes());
                        }

                        int vehicleHealthDelta = data.vehicle_health - veh.gameReference.Health;
                        veh.gameReference.Health = data.vehicle_health;
                        veh.last_game_health     = data.vehicle_health;

                        if (vehicleHealthDelta > 20 && vehicleHealthDelta < 2000 && data.vehicle_id > 0)
                        {
                            var bpf = new BinaryPacketFormatter(Commands.Vehicle_damage, id, data.vehicle_id, vehicleHealthDelta);
                            Client.instance.serverConnection.write(bpf.getBytes());
                        }

                        if ((data.vstate & VehicleState.IsAsPassenger) != 0)
                        {
                            return;
                        }
                        veh.position = posnew;
                        if (veh.gameReference.Position.DistanceTo(posnew) > 1.0f)
                        {
                            veh.gameReference.Position = posnew;
                        }
                        //veh.gameReference.Position = posnew;
                        veh.orientation = new Quaternion(data.rot_x, data.rot_y, data.rot_z, data.rot_a);
                        //veh.gameReference.ApplyForce(, Vector3.Zero);
                        veh.gameReference.RotationQuaternion = veh.orientation;
                        var vel = new Vector3(data.vel_x, data.vel_y, data.vel_z);
                        if (System.Math.Abs(veh.gameReference.Velocity.Length() - vel.Length()) > 6.0f)
                        {
                            veh.gameReference.ApplyForce(vel);
                        }
                        if ((data.vstate & VehicleState.IsBraking) == 0)
                        {
                            ped.gameReference.Task.DrivePointRoute(veh.gameReference, 999.0f, posnew - veh.gameReference.Velocity);
                        }
                        else
                        {
                            ped.gameReference.Task.DrivePointRoute(veh.gameReference, 999.0f, posnew + veh.gameReference.Velocity);
                        }
                        if ((data.state & PlayerState.IsShooting) != 0)
                        {
                            Vector3 pos = veh.gameReference.Position + veh.gameReference.Direction;
                            GTA.Native.Function.Call("FIRE_PED_WEAPON", ped.gameReference, pos.X, pos.Y, pos.Z);
                            GTA.Native.Function.Call("TASK_SHOOT_AT_COORD", ped.gameReference, pos.X, pos.Y, pos.Z, (Int32)4, 999992);
                        }
                    }
                }
            }
        }
        public void updatePed(uint id, UpdateDataStruct data, StreamedPed ped)
        {
            var posnew = new Vector3(data.pos_x, data.pos_y, data.pos_z - 1.0f);
            ped.position = posnew;
            ped.heading = data.heading;
            ped.direction = new Vector3(data.rot_x, data.rot_y, data.rot_z);
            ped.cameraDirection = new Vector3(data.camdir_x, data.camdir_y, data.camdir_z);
            if (ped.IsStreamedIn() && data.vehicle_id == 0)
            {
                if (ped.gameReference.isInVehicle())
                {
                    ped.gameReference.CurrentVehicle.PassengersLeaveVehicle(true);
                    //ped.gameReference.CurrentVehicle.Delete();
                }

                float delta = posnew.DistanceTo(ped.gameReference.Position);
                Vector3 vdelta = posnew - ped.gameReference.Position;
                //ped.gameReference.Weapons.MP5.Ammo = 999;

                int healthDelta = data.ped_health - ped.gameReference.Health;
                ped.gameReference.Health = data.ped_health;
                ped.last_game_health = data.ped_health;

                if (data.weapon > 0)
                {
                    if (ped.gameReference.Weapons.Current != (Weapon)data.weapon)
                    {
                        ped.gameReference.Weapons.FromType((Weapon)data.weapon).Ammo = 999;
                        ped.gameReference.Weapons.FromType((Weapon)data.weapon).AmmoInClip = 999;
                        ped.gameReference.Weapons.Select((Weapon)data.weapon);
                    }
                }
                else
                {
                    ped.gameReference.Weapons.RemoveAll();
                }

                if (healthDelta > 20 && healthDelta < 100)
                {
                    var bpf = new BinaryPacketFormatter(Commands.Player_damage);
                    bpf.Add(id);
                    //Client.instance.chatController.writeChat("damaged " + healthDelta) ;
                    Client.instance.serverConnection.write(bpf.getBytes());
                }

                bool cancelPositionUpdate = false;

                if ((data.state & PlayerState.IsShooting) != 0)
                {
                    ped.animator.playAnimation(PedAnimations.Shoot);
                    cancelPositionUpdate = true;
                }
                else
                    if ((data.state & PlayerState.IsAiming) != 0)
                    {
                        ped.animator.playAnimation(PedAnimations.Aim);
                        cancelPositionUpdate = true;
                    }
                    else
                        if ((data.state & PlayerState.IsRagdoll) != 0 || data.ped_health <= 0)
                        {
                            ped.animator.playAnimation(PedAnimations.Ragdoll);
                            ped.gameReference.Velocity = new Vector3(data.vel_x, data.vel_y, data.vel_z);
                            cancelPositionUpdate = true;
                        }
                        else
                            if ((data.vstate & VehicleState.IsEnteringVehicle) != 0)
                            {
                                ped.animator.playAnimation(PedAnimations.EnterClosestVehicle);
                                cancelPositionUpdate = true;
                            }
                            else
                                if ((data.state & PlayerState.IsCrouching) != 0)
                                {
                                    ped.animator.playAnimation(PedAnimations.Couch);
                                }
                                else
                                {
                                    if ((data.vstate & VehicleState.IsAccelerating) != 0)
                                    {
                                        if ((data.vstate & VehicleState.IsSprinting) != 0)
                                        {
                                            ped.animator.playAnimation(PedAnimations.Run);
                                        }
                                        else
                                        {
                                            ped.animator.playAnimation(PedAnimations.Walk);
                                        }
                                    }
                                    else
                                    {
                                        ped.animator.playAnimation(PedAnimations.StandStill);
                                    }
                                }

                if (!cancelPositionUpdate)
                {
                    ped.gameReference.Position = posnew;
                }
                ped.gameReference.Heading = data.heading;

                //ped.gameReference.Velocity = new Vector3(elemValue.vel_x, elemValue.vel_y, elemValue.vel_z);
                //ped.gameReference.Task.ClearAllImmediately();
            }
        }
        public void updateVehicle(uint id, UpdateDataStruct data, StreamedPed ped)
        {
            if (data.vehicle_id > 0)
            {
                var posnew = new Vector3(data.pos_x, data.pos_y, data.pos_z);
                StreamedVehicle veh = vehicleController.GetInstance(data.vehicle_id);
                if (veh != null)
                {
                    if (veh.IsStreamedIn())
                    {
                        if (ped != null && ped.IsStreamedIn() && !ped.gameReference.isInVehicle())
                        {
                            if ((data.state & PlayerState.IsPassenger1) != 0)
                            {
                                ped.gameReference.WarpIntoVehicle(veh.gameReference, VehicleSeat.RightFront);
                            }
                            else if ((data.state & PlayerState.IsPassenger2) != 0)
                            {
                                ped.gameReference.WarpIntoVehicle(veh.gameReference, VehicleSeat.LeftRear);
                            }
                            else if ((data.state & PlayerState.IsPassenger3) != 0)
                            {
                                ped.gameReference.WarpIntoVehicle(veh.gameReference, VehicleSeat.RightFront);
                            }
                            else
                            {
                                ped.gameReference.WarpIntoVehicle(veh.gameReference, VehicleSeat.Driver);
                            }
                        }

                        int healthDelta = data.ped_health - ped.gameReference.Health;
                        ped.gameReference.Health = data.ped_health;
                        ped.last_game_health = data.ped_health;

                        if (healthDelta > 20 && healthDelta < 100)
                        {
                            var bpf = new BinaryPacketFormatter(Commands.Player_damage);
                            bpf.Add(id);
                            //Client.instance.chatController.writeChat("damaged " + healthDelta) ;
                            Client.instance.serverConnection.write(bpf.getBytes());
                        }

                        int vehicleHealthDelta = data.vehicle_health - veh.gameReference.Health;
                        veh.gameReference.Health = data.vehicle_health;
                        veh.last_game_health = data.vehicle_health;

                        if (vehicleHealthDelta > 20 && vehicleHealthDelta < 2000 && data.vehicle_id > 0)
                        {
                            var bpf = new BinaryPacketFormatter(Commands.Vehicle_damage, id, data.vehicle_id, vehicleHealthDelta);
                            Client.instance.serverConnection.write(bpf.getBytes());
                        }

                        if ((data.vstate & VehicleState.IsAsPassenger) != 0) return;
                        veh.position = posnew;
                        if (veh.gameReference.Position.DistanceTo(posnew) > 1.0f)
                        {
                            veh.gameReference.Position = posnew;
                        }
                        //veh.gameReference.Position = posnew;
                        veh.orientation = new Quaternion(data.rot_x, data.rot_y, data.rot_z, data.rot_a);
                        //veh.gameReference.ApplyForce(, Vector3.Zero);
                        veh.gameReference.RotationQuaternion = veh.orientation;
                        var vel = new Vector3(data.vel_x, data.vel_y, data.vel_z);
                        if (System.Math.Abs(veh.gameReference.Velocity.Length() - vel.Length()) > 6.0f)
                        {
                            veh.gameReference.ApplyForce(vel);
                        }
                        if ((data.vstate & VehicleState.IsBraking) == 0)
                        {
                            ped.gameReference.Task.DrivePointRoute(veh.gameReference, 999.0f, posnew - veh.gameReference.Velocity);
                        }
                        else
                        {
                            ped.gameReference.Task.DrivePointRoute(veh.gameReference, 999.0f, posnew + veh.gameReference.Velocity);
                        }
                        if ((data.state & PlayerState.IsShooting) != 0)
                        {
                            Vector3 pos = veh.gameReference.Position + veh.gameReference.Direction;
                            GTA.Native.Function.Call("FIRE_PED_WEAPON", ped.gameReference, pos.X, pos.Y, pos.Z);
                            GTA.Native.Function.Call("TASK_SHOOT_AT_COORD", ped.gameReference, pos.X, pos.Y, pos.Z, (Int32)4, 999992);
                        }
                    }
                }
            }
        }
        public void playAnimation(PedAnimations anim, params object[] param)
        {
            lastParams = param;
            if (!ped.IsStreamedIn())
            {
                currentAnimation = PedAnimations.NotStreamed;
                return;
            }
            if (currentAnimation != anim)
            {
                lastAnimationStarted = DateTime.Now;
                currentAnimation     = anim;
                if (anim == PedAnimations.RunTo && ped.gameReference.Position.DistanceTo((Vector3)param[0]) > 1.0f)
                {
                    if ((lastRunToCoord).DistanceTo((Vector3)param[0]) > 1.0f)
                    {
                        //ped.gameReference.Animation.Play(animset, "holster_2_aim", 1.0f, AnimationFlags.Unknown01 | AnimationFlags.Unknown05);
                        ped.gameReference.Task.RunTo((Vector3)param[0]);
                        lastRunToCoord = (Vector3)param[0];
                    }
                    return;
                }
                if (anim == PedAnimations.WalkTo && ped.gameReference.Position.DistanceTo((Vector3)param[0]) > 1.0f)
                {
                    if ((lastWalkToCoord).DistanceTo((Vector3)param[0]) > 1.0f)
                    {
                        //ped.gameReference.Animation.Play(animset, "holster_2_aim", 1.0f, AnimationFlags.Unknown01 | AnimationFlags.Unknown05);
                        ped.gameReference.Task.GoTo((Vector3)param[0]);
                        lastWalkToCoord = (Vector3)param[0];
                    }
                    return;
                }
                ped.gameReference.PreventRagdoll = true;
                ped.gameReference.Task.ClearAllImmediately();
                switch (anim)
                {
                case PedAnimations.Run: ped.gameReference.Animation.Play(animset, "sprint", 1.0f, AnimationFlags.Unknown01 | AnimationFlags.Unknown05);
                    break;

                case PedAnimations.Aim:
                    //ped.gameReference.Animation.Play(animset, "holster_2_aim", 1.0f, AnimationFlags.Unknown01 | AnimationFlags.Unknown05);
                    ped.gameReference.Task.AimAt(ped.gameReference.Position + (ped.cameraDirection * 100.0f), 9999999);
                    ped.gameReference.Position = ped.position;
                    currentAnimation           = PedAnimations.NotStreamed;
                    break;

                case PedAnimations.Couch: ped.gameReference.Animation.Play(animset2, "unholster_crouch", 1.0f, AnimationFlags.Unknown01 | AnimationFlags.Unknown05);
                    break;

                case PedAnimations.Climb:
                    GTA.Native.Function.Call("TASK_CLIMB", ped.gameReference, 1);
                    GTA.Native.Function.Call("TASK_CLIMB", ped.gameReference, true);
                    break;

                case PedAnimations.Jump:
                    GTA.Native.Function.Call("TASK_JUMP", ped.gameReference, 1);
                    GTA.Native.Function.Call("TASK_JUMP", ped.gameReference, true);
                    break;

                case PedAnimations.Shoot:
                    ped.gameReference.Accuracy = 99;
                    //ped.gameReference.Task.ShootAt(Client.instance.getPlayerPed(), ShootMode.Continuous, 9992);
                    //ped.gameReference.ShootAt(ped.gameReference.Position + ped.gameReference.Direction);
                    Vector3 pos = ped.gameReference.Position + (ped.cameraDirection * 100.0f);
                    ped.gameReference.Position = ped.position;
                    //GTA.Native.Function.Call("TRIGGER_PTFX_ON_PED_BONE", "muz_smg", Player.Character, 0.3, 0.0, -0.12, 90.0, 0.0, 0.0, 0x38A1, 0.5);
                    GTA.Native.Function.Call("FIRE_PED_WEAPON", ped.gameReference, pos.X, pos.Y, pos.Z);
                    GTA.Native.Function.Call("TASK_SHOOT_AT_COORD", ped.gameReference, pos.X, pos.Y, pos.Z, (Int32)4, 999992);
                    //AlternateHook.call(MIVSDK.AlternateHookRequest.PedCommands.FIRE_PED_WEAPON, ped.gameReference, pos.X, pos.Y, pos.Z);
                    ped.gameReference.Heading = ped.heading;
                    ped.gameReference.Task.AimAt(ped.gameReference.Position + (ped.cameraDirection * 100.0f), 9999999);
                    currentAnimation = PedAnimations.Aim;
                    break;

                case PedAnimations.EnterClosestVehicle:
                    //ped.gameReference.Task.ShootAt(Client.instance.getPlayerPed(), ShootMode.Continuous, 9992);
                    ped.gameReference.Task.EnterVehicle(World.GetClosestVehicle(ped.gameReference.Position, 10.0f), VehicleSeat.Driver);
                    break;

                case PedAnimations.Ragdoll: ped.gameReference.ForceRagdoll(1000, false);
                    break;

                case PedAnimations.Walk: ped.gameReference.Animation.Play(animset, "walk", 1.0f, AnimationFlags.Unknown01 | AnimationFlags.Unknown05);
                    break;

                case PedAnimations.StandStill: ped.gameReference.Animation.Play(animset, "idle", 1.0f, AnimationFlags.Unknown01 | AnimationFlags.Unknown05);
                    break;
                }
            }
        }
Пример #6
0
        public override void UpdateGfx()
        {
            if (!client.getPlayerPed().Exists())
            {
                return;
            }
            var player_projected = (Vector2)World.WorldToScreenProject(client.getPlayerPed().Position);

            for (int i = 0; i < instances.Count; i++)
            {
                StreamedPed ped = (StreamedPed)instances[i];
                try
                {
                    if (ped.IsStreamedIn())
                    {
                        Vector2 projected = new Vector2();
                        if (client.getPlayerPed().Exists() && ped.gameReference.Exists())
                        {
                            projected = (Vector2)World.WorldToScreenProject(ped.gameReference.Position);
                        }
                        else
                        {
                            return;
                        }
                        Vector3 peddelta = Vector3.Zero;
                        if (client.getPlayerPed().Exists() && ped.gameReference.Exists())
                        {
                            peddelta = ped.gameReference.Position - client.getPlayerPed().Position;
                        }
                        else
                        {
                            return;
                        }
                        float distance = peddelta.Length();
                        //float distance_from_centerscreen = (projected - new Vector2(Game.Resolution.Width, Game.Resolution.Height)).Length();
                        int alpha = (int)Math.Round((255.0f * (distance / -DrawDistance + 1.0f)));
                        if (alpha > 255)
                        {
                            alpha = 255;
                        }
                        if (alpha < 0)
                        {
                            alpha = 0;
                        }
                        if (!ped.gameReference.Exists())
                        {
                            return;
                        }
                        if (projected.X < -120 || projected.X > Game.Resolution.Width || projected.Y < -50 || projected.Y > Game.Resolution.Height ||
                            (peddelta + Game.CurrentCamera.Direction).Length() < distance || (checkLOS && !Game.CurrentCamera.isSphereVisible(ped.gameReference.Position, 3.0f)))
                        {
                            if (!ped.gameReference.Exists())
                            {
                                return;
                            }
                            ped.nickDraw.destroy();
                            ped.healthDraw.destroy();
                            ped.healthDraw2.destroy();
                            if (ped.carHealthDraw != null)
                            {
                                ped.carHealthDraw.destroy();
                            }
                            if (ped.carHealthDraw2 != null)
                            {
                                ped.carHealthDraw2.destroy();
                            }
                            ped.chatDraw.destroy();
                            ped.nickDraw       = null;
                            ped.healthDraw     = null;
                            ped.healthDraw2    = null;
                            ped.carHealthDraw  = null;
                            ped.carHealthDraw2 = null;
                            ped.chatDraw       = null;
                        }
                        else
                        {
                            var rect = new System.Drawing.RectangleF(projected.X - 100, projected.Y - 50, 200, 30);

                            var rect2  = new System.Drawing.RectangleF(projected.X - 37, projected.Y - 22, 37 * 2, 11);
                            var rect22 = new System.Drawing.RectangleF(projected.X - 35, projected.Y - 20, (35.0f * 2.0f) * (ped.last_game_health < 0 ? 0 : ped.last_game_health / 100.0f), 7);

                            var rect3 = new System.Drawing.RectangleF(projected.X - 300, projected.Y - 10, 600, 130);

                            System.Drawing.RectangleF carrect1 = System.Drawing.RectangleF.Empty;
                            System.Drawing.RectangleF carrect2 = System.Drawing.RectangleF.Empty;
                            bool invehicle = ped.gameReference.isInVehicle();
                            if (invehicle)
                            {
                                carrect1 = new System.Drawing.RectangleF(projected.X - 37, projected.Y - 2, 37 * 2, 11);
                                carrect2 = new System.Drawing.RectangleF(projected.X - 35, projected.Y, (35.0f * 2.0f) * (ped.gameReference.CurrentVehicle.Health < 0 ? 0 : ped.gameReference.CurrentVehicle.Health / 1000.0f), 7);
                            }

                            var chaticonframe = new System.Drawing.RectangleF(projected.X - 30, projected.Y - 80, 60, 30);
                            if (ped.nickDraw == null)
                            {
                                ped.nickDraw    = new ClientTextView(rect, TextAlignment.Center, ped.networkname, nickfont, System.Drawing.Color.FromArgb(alpha, 255, 255, 255));
                                ped.healthDraw  = new ClientRectangleView(rect2, System.Drawing.Color.FromArgb(alpha, 0, 0, 0));
                                ped.healthDraw2 = new ClientRectangleView(rect22, System.Drawing.Color.FromArgb(alpha, 80, 80, 255));
                                ped.chatDraw    = new ClientTextView(rect3, TextAlignment.Center, ped.CurrentChatMessage, nickfont, System.Drawing.Color.FromArgb(alpha, 255, 255, 255));
                                if (invehicle)
                                {
                                    ped.carHealthDraw  = new ClientRectangleView(carrect1, System.Drawing.Color.FromArgb(alpha, 0, 0, 0));
                                    ped.carHealthDraw2 = new ClientRectangleView(carrect2, System.Drawing.Color.FromArgb(alpha, 255, 80, 80));
                                }
                            }
                            else
                            {
                                ped.nickDraw.Box      = rect;
                                ped.nickDraw.color    = System.Drawing.Color.FromArgb(alpha, 255, 255, 255);
                                ped.healthDraw.Box    = rect2;
                                ped.healthDraw.color  = System.Drawing.Color.FromArgb(alpha, 0, 0, 0);
                                ped.healthDraw2.Box   = rect22;
                                ped.healthDraw2.color = System.Drawing.Color.FromArgb(alpha, 80, 80, 255);
                                ped.chatDraw.Box      = rect3;
                                ped.chatDraw.text     = ped.CurrentChatMessage;
                                ped.chatDraw.color    = System.Drawing.Color.FromArgb(alpha, 255, 255, 255);
                                if (invehicle)
                                {
                                    if (ped.carHealthDraw != null)
                                    {
                                        ped.carHealthDraw.Box    = carrect1;
                                        ped.carHealthDraw.color  = System.Drawing.Color.FromArgb(alpha, 0, 0, 0);
                                        ped.carHealthDraw2.Box   = carrect2;
                                        ped.carHealthDraw2.color = System.Drawing.Color.FromArgb(alpha, 255, 80, 80);
                                    }
                                    else
                                    {
                                        ped.carHealthDraw  = new ClientRectangleView(carrect1, System.Drawing.Color.FromArgb(alpha, 0, 0, 0));
                                        ped.carHealthDraw2 = new ClientRectangleView(carrect2, System.Drawing.Color.FromArgb(alpha, 255, 80, 80));
                                    }
                                }
                                else
                                {
                                    if (ped.carHealthDraw != null)
                                    {
                                        ped.carHealthDraw.destroy();
                                    }
                                    if (ped.carHealthDraw2 != null)
                                    {
                                        ped.carHealthDraw2.destroy();
                                    }
                                    ped.carHealthDraw  = null;
                                    ped.carHealthDraw2 = null;
                                }
                            }
                        }
                    }
                }
                catch
                { }
            }
        }