public void DisplayLocally() { try { const float hRange = 200f; var gPos = IsInVehicle ? VehiclePosition : Position; var inRange = Game.Player.Character.IsInRangeOf(gPos, hRange); if (inRange && !_isStreamedIn) { _isStreamedIn = true; if (_mainBlip != null) { _mainBlip.Remove(); _mainBlip = null; } } else if (!inRange && _isStreamedIn) { Clear(); _isStreamedIn = false; } if (!inRange) { if (_mainBlip == null && _blip) { _mainBlip = World.CreateBlip(gPos); _mainBlip.Color = BlipColor.White; _mainBlip.Scale = 0.8f; SetBlipNameFromTextFile(_mainBlip, Name == null ? "<nameless>" : Name); } if (_blip && _mainBlip != null) { _mainBlip.Position = gPos; } return; } if (Character == null || !Character.Exists() || !Character.IsInRangeOf(gPos, hRange) || Character.Model.Hash != ModelHash || (Character.IsDead && PedHealth > 0)) { if (Character != null) { Character.Delete(); } Character = World.CreatePed(new Model(ModelHash), gPos, Rotation.Z); if (Character == null) { return; } Character.BlockPermanentEvents = true; Character.IsInvincible = true; Character.CanRagdoll = false; Character.RelationshipGroup = _relGroup; if (_blip) { Character.AddBlip(); if (Character.CurrentBlip == null) { return; } Character.CurrentBlip.Color = BlipColor.White; Character.CurrentBlip.Scale = 0.8f; SetBlipNameFromTextFile(Character.CurrentBlip, Name); } return; } if (!Character.IsOccluded && Character.IsInRangeOf(Game.Player.Character.Position, 20f)) { var oldPos = UI.WorldToScreen(Character.Position + new Vector3(0, 0, 1.5f)); if (oldPos.X != 0 && oldPos.Y != 0) { var res = UIMenu.GetScreenResolutionMantainRatio(); var pos = new Point((int)((oldPos.X / (float)UI.WIDTH) * res.Width), (int)((oldPos.Y / (float)UI.HEIGHT) * res.Height)); new UIResText(Name == null ? "<nameless>" : Name, pos, 0.3f, Color.WhiteSmoke, Font.ChaletLondon, UIResText.Alignment.Centered) { Outline = true, }.Draw(); } } if ((!_lastVehicle && IsInVehicle && VehicleHash != 0) || (_lastVehicle && IsInVehicle && (MainVehicle == null || !Character.IsInVehicle(MainVehicle) || MainVehicle.Model.Hash != VehicleHash || VehicleSeat != Util.GetPedSeat(Character)))) { if (MainVehicle != null && Util.IsVehicleEmpty(MainVehicle)) { MainVehicle.Delete(); } var vehs = World.GetAllVehicles().OrderBy(v => { if (v == null) { return(float.MaxValue); } return((v.Position - Character.Position).Length()); }).ToList(); if (vehs.Any() && vehs[0].Model.Hash == VehicleHash && vehs[0].IsInRangeOf(gPos, 3f)) { MainVehicle = vehs[0]; if (Game.Player.Character.IsInVehicle(MainVehicle) && VehicleSeat == Util.GetPedSeat(Game.Player.Character)) { Game.Player.Character.Task.WarpOutOfVehicle(MainVehicle); UI.Notify("~r~Car jacked!"); } } else { MainVehicle = World.CreateVehicle(new Model(VehicleHash), gPos, 0); } if (MainVehicle != null) { MainVehicle.PrimaryColor = (VehicleColor)VehiclePrimaryColor; MainVehicle.SecondaryColor = (VehicleColor)VehicleSecondaryColor; MainVehicle.Quaternion = VehicleRotation; MainVehicle.IsInvincible = true; Character.Task.WarpIntoVehicle(MainVehicle, (VehicleSeat)VehicleSeat); /*if (_playerSeat != -2 && !Game.Player.Character.IsInVehicle(_mainVehicle)) * { // TODO: Fix me. * Game.Player.Character.Task.WarpIntoVehicle(_mainVehicle, (VehicleSeat)_playerSeat); * }*/ } _lastVehicle = true; _justEnteredVeh = true; _enterVehicleStarted = DateTime.Now; return; } if (_lastVehicle && _justEnteredVeh && IsInVehicle && !Character.IsInVehicle(MainVehicle) && DateTime.Now.Subtract(_enterVehicleStarted).TotalSeconds <= 4) { return; } _justEnteredVeh = false; if (_lastVehicle && !IsInVehicle && MainVehicle != null) { if (Character != null) { Character.Task.LeaveVehicle(MainVehicle, true); } } Character.Health = PedHealth; _switch++; if (IsInVehicle) { if (VehicleSeat == (int)GTA.VehicleSeat.Driver || MainVehicle.GetPedOnSeat(GTA.VehicleSeat.Driver) == null) { MainVehicle.Health = VehicleHealth; if (MainVehicle.Health <= 0) { MainVehicle.IsInvincible = false; //_mainVehicle.Explode(); } else { MainVehicle.IsInvincible = true; if (MainVehicle.IsDead) { MainVehicle.Repair(); } } MainVehicle.PrimaryColor = (VehicleColor)VehiclePrimaryColor; MainVehicle.SecondaryColor = (VehicleColor)VehicleSecondaryColor; if (VehicleMods != null && _modSwitch % 50 == 0 && Game.Player.Character.IsInRangeOf(VehiclePosition, 30f)) { var id = _modSwitch / 50; if (VehicleMods.ContainsKey(id) && VehicleMods[id] != MainVehicle.GetMod((VehicleMod)id)) { Function.Call(Hash.SET_VEHICLE_MOD_KIT, MainVehicle.Handle, 0); MainVehicle.SetMod((VehicleMod)id, VehicleMods[id], false); Function.Call(Hash.RELEASE_PRELOAD_MODS, id); } } _modSwitch++; if (_modSwitch >= 2500) { _modSwitch = 0; } if (IsHornPressed && !_lastHorn) { _lastHorn = true; MainVehicle.SoundHorn(99999); } if (!IsHornPressed && _lastHorn) { _lastHorn = false; MainVehicle.SoundHorn(1); } if (MainVehicle.SirenActive && !Siren) { MainVehicle.SirenActive = Siren; } else if (!MainVehicle.SirenActive && Siren) { MainVehicle.SirenActive = Siren; } var dir = VehiclePosition - _lastVehiclePos; dir.Normalize(); var range = Math.Max(20f, Speed * Math.Ceiling(DateTime.Now.Subtract(LastUpdateReceived).TotalSeconds)); if (MainVehicle.IsInRangeOf(VehiclePosition, (float)range)) { var timeElapsed = (float)DateTime.Now.Subtract(LastUpdateReceived).TotalSeconds; var acceleration = Speed - _lastSpeed; MainVehicle.Position = _lastVehiclePos + dir * (Speed * timeElapsed) + dir * (0.5f * acceleration * (float)Math.Pow(timeElapsed, 2)); } else { MainVehicle.Position = VehiclePosition; _lastVehiclePos = VehiclePosition - (dir * 0.5f); } #if DEBUG if (MainVehicle.Heading < 270) { MainVehicle.Quaternion = Util.LerpQuaternion(MainVehicle.Quaternion, VehicleRotation, 0.1f); } else if (MainVehicle.Heading >= 270) { MainVehicle.Quaternion = Util.LerpQuaternion(VehicleRotation, MainVehicle.Quaternion, 0.1f); } #else MainVehicle.Quaternion = VehicleRotation; #endif } } else { if (PedProps != null && _clothSwitch % 50 == 0 && Game.Player.Character.IsInRangeOf(Position, 30f)) { var id = _clothSwitch / 50; if (PedProps.ContainsKey(id) && PedProps[id] != Function.Call <int>(Hash.GET_PED_DRAWABLE_VARIATION, Character.Handle, id)) { Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Character.Handle, id, PedProps[id], 0, 0); } } _clothSwitch++; if (_clothSwitch >= 750) { _clothSwitch = 0; } if (Character.Weapons.Current.Hash != (WeaponHash)CurrentWeapon) { var wep = Character.Weapons.Give((WeaponHash)CurrentWeapon, 9999, true, true); Character.Weapons.Select(wep); } if (!_lastJumping && IsJumping) { Character.Task.Jump(); } if (IsParachuteOpen) { if (_parachuteProp == null) { _parachuteProp = World.CreateProp(new Model(1740193300), Character.Position, Character.Rotation, false, false); _parachuteProp.FreezePosition = true; Function.Call(Hash.SET_ENTITY_COLLISION, _parachuteProp.Handle, false, 0); } Character.FreezePosition = true; Character.Position = Position - new Vector3(0, 0, 1); Character.Quaternion = Rotation; _parachuteProp.Position = Character.Position + new Vector3(0, 0, 3.7f); _parachuteProp.Quaternion = Character.Quaternion; Character.Task.PlayAnimation("skydive@parachute@first_person", "chute_idle_right", 8f, 5000, false, 8f); } else { var dest = Position; Character.FreezePosition = false; if (_parachuteProp != null) { _parachuteProp.Delete(); _parachuteProp = null; } const int threshold = 50; if (IsAiming && !IsShooting && !Character.IsInRangeOf(Position, 0.5f) && _switch % threshold == 0) { Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, Character.Handle, dest.X, dest.Y, dest.Z, AimCoords.X, AimCoords.Y, AimCoords.Z, 2f, 0, 0x3F000000, 0x40800000, 1, 512, 0, (uint)FiringPattern.FullAuto); } else if (IsAiming && !IsShooting && Character.IsInRangeOf(Position, 0.5f)) { Character.Task.AimAt(AimCoords, 100); } if (!Character.IsInRangeOf(Position, 0.5f) && ((IsShooting && !_lastShooting) || (IsShooting && _lastShooting && _switch % (threshold * 2) == 0))) { Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, Character.Handle, dest.X, dest.Y, dest.Z, AimCoords.X, AimCoords.Y, AimCoords.Z, 2f, 1, 0x3F000000, 0x40800000, 1, 0, 0, (uint)FiringPattern.FullAuto); } else if ((IsShooting && !_lastShooting) || (IsShooting && _lastShooting && _switch % (threshold / 2) == 0)) { Function.Call(Hash.TASK_SHOOT_AT_COORD, Character.Handle, AimCoords.X, AimCoords.Y, AimCoords.Z, 1500, (uint)FiringPattern.FullAuto); } if (!IsAiming && !IsShooting && !IsJumping) { switch (SyncMode) { case SynchronizationMode.Tasks: if (!Character.IsInRangeOf(Position, 0.5f)) { Character.Task.RunTo(Position, true, 500); //var targetAngle = Rotation.Z/Math.Sqrt(1 - Rotation.W*Rotation.W); //Function.Call(Hash.TASK_GO_STRAIGHT_TO_COORD, Character.Handle, Position.X, Position.Y, Position.Z, 5f, 3000, targetAngle, 0); } if (!Character.IsInRangeOf(Position, 5f)) { Character.Position = dest - new Vector3(0, 0, 1f); Character.Quaternion = Rotation; } break; case SynchronizationMode.Teleport: Character.Position = dest - new Vector3(0, 0, 1f); Character.Quaternion = Rotation; break; } } } _lastJumping = IsJumping; _lastShooting = IsShooting; _lastAiming = IsAiming; } _lastVehicle = IsInVehicle; } catch (Exception ex) { UI.Notify("Sync error: " + ex.Message); } }
public void DisplayLocally() { try { const float hRange = 200f; var gPos = IsInVehicle ? VehiclePosition : Position; var inRange = Game.Player.Character.IsInRangeOf(gPos, hRange); if (inRange && !_isStreamedIn) { _isStreamedIn = true; if (_mainBlip != null) { _mainBlip.Remove(); _mainBlip = null; } } else if (!inRange && _isStreamedIn) { Clear(); _isStreamedIn = false; } if (!inRange) { if (_mainBlip == null && _blip) { _mainBlip = World.CreateBlip(gPos); _mainBlip.Color = BlipColor.White; _mainBlip.Scale = 0.8f; SetBlipName(_mainBlip, Name == null ? "<nameless>" : Name); } if (_blip && _mainBlip != null) { _mainBlip.Position = gPos; } return; } if (Character == null || !Character.Exists() || (!Character.IsInRangeOf(gPos, hRange) && Environment.TickCount - LastUpdateReceived < 5000) || Character.Model.Hash != ModelHash || (Character.IsDead && PedHealth > 0)) { if (Character != null) { Character.Delete(); } Character = World.CreatePed(new Model(ModelHash), gPos, Rotation.Z); if (Character == null) { return; } Character.BlockPermanentEvents = true; Character.IsInvincible = true; Character.CanBeDraggedOutOfVehicle = false; Character.CanRagdoll = false; Character.RelationshipGroup = _relGroup; if (_blip) { Character.AddBlip(); if (Character.CurrentBlip == null) { return; } Character.CurrentBlip.Color = BlipColor.White; Character.CurrentBlip.Scale = 0.8f; SetBlipName(Character.CurrentBlip, Name); } if (PedProps != null) { foreach (KeyValuePair <int, int> pedprop in PedProps) { Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Character.Handle, pedprop.Key, pedprop.Value, 0, 0); } } return; } if (!Character.IsOccluded && Character.IsInRangeOf(Game.Player.Character.Position, 20f)) { Vector3 targetPos = Character.GetBoneCoord(Bone.IK_Head) + new Vector3(0, 0, 0.5f); targetPos += Character.Velocity / Game.FPS; Function.Call(Hash.SET_DRAW_ORIGIN, targetPos.X, targetPos.Y, targetPos.Z, 0); float sizeOffset = Math.Max(1f - ((GameplayCamera.Position - Character.Position).Length() / 30f), 0.3f); new UIResText(Name ?? "<Nameless>", new Point(0, 0), 0.4f * sizeOffset, Color.WhiteSmoke, Font.ChaletLondon, UIResText.Alignment.Centered) { Outline = true, }.Draw(); Function.Call(Hash.CLEAR_DRAW_ORIGIN); } if (!_lastVehicle && IsInVehicle && MainVehicle != null && Character.IsInVehicle(MainVehicle)) { _lastVehicle = true; } if ((!_lastVehicle && IsInVehicle && VehicleHash != 0) || (_lastVehicle && IsInVehicle && (MainVehicle == null || !Character.IsInVehicle(MainVehicle) || MainVehicle.Model.Hash != VehicleHash || VehicleSeat != Util.GetPedSeat(Character)))) { if (MainVehicle != null && Util.IsVehicleEmpty(MainVehicle)) { MainVehicle.Delete(); } var vehs = World.GetAllVehicles().OrderBy(v => { if (v == null) { return(float.MaxValue); } return((v.Position - Character.Position).Length()); }).ToList(); if (vehs.Any() && vehs[0].Model.Hash == VehicleHash && vehs[0].IsInRangeOf(gPos, 3f) && !Game.Player.Character.IsInVehicle(vehs[0])) { MainVehicle = vehs[0]; /*if (Game.Player.Character.IsInVehicle(MainVehicle) && * VehicleSeat == Util.GetPedSeat(Game.Player.Character)) * { * Game.Player.Character.Task.WarpOutOfVehicle(MainVehicle); * UI.Notify("~r~Car jacked!"); * }*/ } else { MainVehicle = World.CreateVehicle(new Model(VehicleHash), gPos, 0); } if (MainVehicle != null) { MainVehicle.PrimaryColor = (VehicleColor)VehiclePrimaryColor; MainVehicle.SecondaryColor = (VehicleColor)VehicleSecondaryColor; MainVehicle.Quaternion = VehicleRotation.ToQuaternion(); MainVehicle.IsInvincible = true; Character.Task.WarpIntoVehicle(MainVehicle, (VehicleSeat)VehicleSeat); /*if (_playerSeat != -2 && !Game.Player.Character.IsInVehicle(_mainVehicle)) * { // TODO: Fix me. * Game.Player.Character.Task.WarpIntoVehicle(_mainVehicle, (VehicleSeat)_playerSeat); * }*/ } _lastVehicle = true; _justEnteredVeh = true; _enterVehicleStarted = DateTime.Now; return; } if (_lastVehicle && _justEnteredVeh && IsInVehicle && !Character.IsInVehicle(MainVehicle) && DateTime.Now.Subtract(_enterVehicleStarted).TotalSeconds <= 4) { return; } _justEnteredVeh = false; if (_lastVehicle && !IsInVehicle && MainVehicle != null) { if (Character != null) { Character.Task.LeaveVehicle(MainVehicle, true); } } Character.Health = PedHealth; _switch++; if (!inRange) { if (Character != null && Environment.TickCount - LastUpdateReceived < 10000) { if (!IsInVehicle) { Character.PositionNoOffset = gPos; } else if (MainVehicle != null && GetResponsiblePed(MainVehicle).Handle == Character.Handle) { MainVehicle.Position = VehiclePosition; MainVehicle.Rotation = VehicleRotation; } } return; } if (IsInVehicle) { if (GetResponsiblePed(MainVehicle).Handle == Character.Handle) { MainVehicle.Health = VehicleHealth; if (MainVehicle.Health <= 0) { MainVehicle.IsInvincible = false; //_mainVehicle.Explode(); } else { MainVehicle.IsInvincible = true; if (MainVehicle.IsDead) { MainVehicle.Repair(); } } MainVehicle.PrimaryColor = (VehicleColor)VehiclePrimaryColor; MainVehicle.SecondaryColor = (VehicleColor)VehicleSecondaryColor; MainVehicle.EngineRunning = IsEngineRunning; if (Plate != null) { MainVehicle.NumberPlate = Plate; } var radioStations = Util.GetRadioStations(); if (radioStations?.ElementAtOrDefault(RadioStation) != null) { Function.Call(Hash.SET_VEH_RADIO_STATION, radioStations[RadioStation]); } if (VehicleMods != null && _modSwitch % 50 == 0 && Game.Player.Character.IsInRangeOf(VehiclePosition, 30f)) { var id = _modSwitch / 50; if (VehicleMods.ContainsKey(id) && VehicleMods[id] != MainVehicle.GetMod((VehicleMod)id)) { Function.Call(Hash.SET_VEHICLE_MOD_KIT, MainVehicle.Handle, 0); MainVehicle.SetMod((VehicleMod)id, VehicleMods[id], false); Function.Call(Hash.RELEASE_PRELOAD_MODS, id); } } _modSwitch++; if (_modSwitch >= 2500) { _modSwitch = 0; } if (IsHornPressed && !_lastHorn) { _lastHorn = true; MainVehicle.SoundHorn(99999); } if (!IsHornPressed && _lastHorn) { _lastHorn = false; MainVehicle.SoundHorn(1); } if (MainVehicle.SirenActive && !Siren) { MainVehicle.SirenActive = Siren; } else if (!MainVehicle.SirenActive && Siren) { MainVehicle.SirenActive = Siren; } MainVehicle.SteeringAngle = (Steering > 5f || Steering < -5f) ? Steering : 0f; if (Character.IsOnBike && MainVehicle.ClassType == VehicleClass.Cycles) { var isPedaling = IsPedaling(false); var isFastPedaling = IsPedaling(true); if (Speed < 2f) { if (isPedaling) { StopPedalingAnim(false); } else if (isFastPedaling) { StopPedalingAnim(true); } } else if (Speed < 11f && !isPedaling) { StartPedalingAnim(false); } else if (Speed >= 11f && !isFastPedaling) { StartPedalingAnim(true); } } if (Speed > 0.2f) { int currentTime = Environment.TickCount; float alpha = Util.Unlerp(currentInterop.StartTime, currentTime, currentInterop.FinishTime); alpha = Util.Clamp(0f, alpha, 1.5f); float cAlpha = alpha - currentInterop.LastAlpha; currentInterop.LastAlpha = alpha; Vector3 comp = Util.Lerp(new Vector3(), cAlpha, currentInterop.vecError); if (alpha == 1.5f) { currentInterop.FinishTime = 0; } Vector3 newPos = VehiclePosition + comp; MainVehicle.Velocity = VehicleVelocity + (newPos - MainVehicle.Position); _stopTime = DateTime.Now; _carPosOnUpdate = MainVehicle.Position; } else if (DateTime.Now.Subtract(_stopTime).TotalMilliseconds <= 1000) { var dir = VehiclePosition - _lastVehiclePos; var posTarget = Util.LinearVectorLerp(_carPosOnUpdate, VehiclePosition + dir, (int)DateTime.Now.Subtract(_stopTime).TotalMilliseconds, 1000); Function.Call(Hash.SET_ENTITY_COORDS_NO_OFFSET, MainVehicle, posTarget.X, posTarget.Y, posTarget.Z, 0, 0, 0, 0); } else { MainVehicle.PositionNoOffset = VehiclePosition; } if (_lastVehicleRotation != null) { MainVehicle.Quaternion = Quaternion.Slerp(_lastVehicleRotation.Value.ToQuaternion(), _vehicleRotation.ToQuaternion(), Math.Min(1.5f, TicksSinceLastUpdate / (float)AverageLatency)); } else { MainVehicle.Quaternion = _vehicleRotation.ToQuaternion(); } } } else { if (Character.Weapons.Current.Hash != (WeaponHash)CurrentWeapon) { var wep = Character.Weapons.Give((WeaponHash)CurrentWeapon, 9999, true, true); Character.Weapons.Select(wep); } if (!_lastJumping && IsJumping) { Character.Task.Jump(); } if (IsParachuteOpen) { if (_parachuteProp == null) { _parachuteProp = World.CreateProp(new Model(1740193300), Character.Position, Character.Rotation, false, false); _parachuteProp.FreezePosition = true; Function.Call(Hash.SET_ENTITY_COLLISION, _parachuteProp.Handle, false, 0); } Character.FreezePosition = true; Character.Position = Position - new Vector3(0, 0, 1); Character.Quaternion = Rotation.ToQuaternion(); _parachuteProp.Position = Character.Position + new Vector3(0, 0, 3.7f); _parachuteProp.Quaternion = Character.Quaternion; Character.Task.PlayAnimation("skydive@parachute@first_person", "chute_idle_right", 8f, 5000, false, 8f); } else { var dest = Position; Character.FreezePosition = false; if (_parachuteProp != null) { _parachuteProp.Delete(); _parachuteProp = null; } const int threshold = 50; if (IsAiming && !IsShooting && !Character.IsInRangeOf(Position, 0.5f) && _switch % threshold == 0) { Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, Character.Handle, dest.X, dest.Y, dest.Z, AimCoords.X, AimCoords.Y, AimCoords.Z, 2f, 0, 0x3F000000, 0x40800000, 1, 512, 0, (uint)FiringPattern.FullAuto); } else if (IsAiming && !IsShooting && Character.IsInRangeOf(Position, 0.5f)) { Character.Task.AimAt(AimCoords, 100); } if (!Character.IsInRangeOf(Position, 0.5f) && ((IsShooting && !_lastShooting) || (IsShooting && _lastShooting && _switch % (threshold * 2) == 0))) { Function.Call(Hash.TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD, Character.Handle, dest.X, dest.Y, dest.Z, AimCoords.X, AimCoords.Y, AimCoords.Z, 2f, 1, 0x3F000000, 0x40800000, 1, 0, 0, (uint)FiringPattern.FullAuto); } else if ((IsShooting && !_lastShooting) || (IsShooting && _lastShooting && _switch % (threshold / 2) == 0)) { Function.Call(Hash.TASK_SHOOT_AT_COORD, Character.Handle, AimCoords.X, AimCoords.Y, AimCoords.Z, 1500, (uint)FiringPattern.FullAuto); } if (!IsAiming && !IsShooting && !IsJumping) { float distance = Character.Position.DistanceTo(Position); if (distance <= 0.15f || distance > 7.0f) // Still or too far away { Character.Position = dest - new Vector3(0, 0, 1f); Character.Quaternion = Rotation.ToQuaternion(); } else if (distance <= 1.25f) // Walking { Function.Call(Hash.TASK_GO_STRAIGHT_TO_COORD, Character, Position.X, Position.Y, Position.Z, 1.0f, -1, Character.Heading, 0.0f); Function.Call(Hash.SET_PED_DESIRED_MOVE_BLEND_RATIO, Character, 1.0f); } else if (distance > 1.75f) // Sprinting { Function.Call(Hash.TASK_GO_STRAIGHT_TO_COORD, Character, Position.X, Position.Y, Position.Z, 3.0f, -1, Character.Heading, 2.0f); Function.Call(Hash.SET_RUN_SPRINT_MULTIPLIER_FOR_PLAYER, Character, 1.49f); Function.Call(Hash.SET_PED_DESIRED_MOVE_BLEND_RATIO, Character, 3.0f); } else // Running { Function.Call(Hash.TASK_GO_STRAIGHT_TO_COORD, Character, Position.X, Position.Y, Position.Z, 4.0f, -1, Character.Heading, 1.0f); Function.Call(Hash.SET_PED_DESIRED_MOVE_BLEND_RATIO, Character, 2.0f); } } } _lastJumping = IsJumping; _lastShooting = IsShooting; _lastAiming = IsAiming; } _lastVehicle = IsInVehicle; if (PedProps != null && _clothSwitch % 50 == 0 && Game.Player.Character.IsInRangeOf(gPos, 30f)) { var id = _clothSwitch / 50; if (PedProps.ContainsKey(id) && PedProps[id] != Function.Call <int>(Hash.GET_PED_DRAWABLE_VARIATION, Character.Handle, id)) { Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Character.Handle, id, PedProps[id], 0, 0); } } _clothSwitch++; if (_clothSwitch >= 750) { _clothSwitch = 0; } } catch (Exception ex) { UI.Notify("Sync error: " + ex.Message); } }