public static void Process() { if (!IsSwitching) { return; } if (!Main.IsPlayerSwitchInProgress) { Function.Call(Hash.SET_ENTITY_HEALTH, Game.Player.Character, _health); if (_ragdoll) { Game.Player.Character.Ragdoll(1); } OnSwitchingComplete?.Invoke(); IsSwitching = false; To = null; } }
internal static void Tick() { if (!IsSwitching) { return; } if (!Function.Call <bool>(Hash.IS_PLAYER_SWITCH_IN_PROGRESS)) { Function.Call(Hash.SET_ENTITY_HEALTH, Game.Player.Character, _health); if (_ragdoll) { Game.Player.Character.Ragdoll(1); } OnSwitchingComplete?.Invoke(); IsSwitching = false; To = null; } }
public static void Switch(Ped to, bool forceShort, bool instant = false) { _health = Function.Call <int>(Hash.GET_ENTITY_HEALTH, to); _ragdoll = to.IsRagdoll; if (instant) { Function.Call(Hash.CHANGE_PLAYER_PED, Game.Player, to, false, false); Function.Call(Hash.SET_ENTITY_HEALTH, Game.Player.Character, _health); if (_ragdoll) { Game.Player.Character.Ragdoll(1); } OnSwitchingComplete?.Invoke(); return; } To = to; ForceShort = forceShort; IsSwitching = true; if (ForceShort) { SwitchType = SwitchTypes.SWITCH_TYPE_SHORT; } else { SwitchType = (SwitchTypes)Function.Call <int>(Hash.GET_IDEAL_PLAYER_SWITCH_TYPE, Game.Player.Character.Position.X, Game.Player.Character.Position.Y, Game.Player.Character.Position.Z, to.Position.X, to.Position.Y, to.Position.Z); } Function.Call(Hash.START_PLAYER_SWITCH, Game.Player.Character, To, 1024, SwitchType); Function.Call(Hash.CHANGE_PLAYER_PED, Game.Player, To, false, false); OnSwitchingStart?.Invoke(); }