static public void ReceiveRevive(string serializedEventModel) { try { TriggerEventForPlayersModel eventModel = Helpers.MsgPack.Deserialize <TriggerEventForPlayersModel>(serializedEventModel); DeathHandler.RevivePlayer(); DamageBitFlags.ClearAllDamageFlags(Game.PlayerPed); Function.Call(Hash.DECOR_SET_BOOL, Game.PlayerPed.Handle, "Ped.IsIncapacitated", false); } catch (Exception ex) { Log.Error($"ReceiveRevive ERROR: {ex.Message}"); } }
static public async void Revive(Command command) { try { var reviveList = PlayerList.Where(p => p != Game.Player && p.Character.Position.DistanceToSquared(Game.PlayerPed.Position) < Math.Pow(HealRange, 2) && (Function.Call <bool>(Hash.IS_ENTITY_DEAD, p.Handle) || Function.Call <bool>(Hash.IS_PED_FATALLY_INJURED, p.Handle) || (Function.Call <bool>(Hash.DECOR_EXIST_ON, p.Character.Handle, "Ped.IsIncapacitated") && Function.Call <bool>(Hash.DECOR_GET_BOOL, p.Character.Handle, "Ped.IsIncapacitated")))); var reviveListAi = PedList.Select(p => new Ped(p)).Where(p => p.Position.DistanceToSquared(Game.PlayerPed.Position) < Math.Pow(HealRange, 2) && (Function.Call <bool>(Hash.IS_ENTITY_DEAD, p.Handle) || Function.Call <bool>(Hash.IS_PED_FATALLY_INJURED, p.Handle))); if (reviveList.Any()) { var reviveTarget = reviveList.First(); BaseScript.TriggerServerEvent("TriggerEventForPlayers", Helpers.MsgPack.Serialize(new TriggerEventForPlayersModel(reviveTarget.ServerId, "Player.Revive", "", true))); } else if (reviveListAi.Any()) { var reviveTarget = reviveListAi.First(); Function.Call <bool>(Hash.DECOR_SET_BOOL, reviveTarget.Handle, "Ped.BeingRevived", true); BaseScript.TriggerServerEvent("TriggerEventForAll", Helpers.MsgPack.Serialize(new TriggerEventForAllModel("NPC.Revive", Helpers.MsgPack.Serialize(reviveTarget.Position.ToArray()), false))); DamageBitFlags.ClearAllDamageFlags(reviveTarget); Function.Call(Hash.RESURRECT_PED, reviveTarget.Handle); Function.Call(Hash.REVIVE_INJURED_PED, reviveTarget.Handle); Function.Call(Hash.CLEAR_PED_TASKS_IMMEDIATELY, reviveTarget.Handle); Function.Call(Hash.SET_ENTITY_COLLISION, reviveTarget.Handle, true, true); reviveTarget.Position = reviveTarget.Position + new Vector3(0, 0, 1f); Function.Call(Hash._PLAY_AMBIENT_SPEECH1, reviveTarget.Handle, "GENERIC_THANKS", "SPEECH_PARAMS_FORCE"); await BaseScript.Delay(3000); Function.Call <bool>(Hash.DECOR_SET_BOOL, reviveTarget.Handle, "Ped.BeingRevived", false); } } catch (Exception ex) { Log.Error($"EMS/Cop Revive error: {ex.Message}"); } }