Skip to content

Commit

Permalink
Fix logs:enableDeathLog disables dummy respawn
Browse files Browse the repository at this point in the history
  • Loading branch information
DiFFoZ committed Nov 13, 2022
1 parent 0eff101 commit e7cf947
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions Dummy/Events/DummyDeadEvent.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
extern alias JetBrainsAnnotations;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using Dummy.API;
using JetBrainsAnnotations::JetBrains.Annotations;
using Microsoft.Extensions.Configuration;
using OpenMod.API.Eventing;
using OpenMod.Core.Eventing;
using OpenMod.UnityEngine.Extensions;
using OpenMod.Unturned.Players;
using OpenMod.Unturned.Players.Life.Events;
using OpenMod.Unturned.Users;
using SDG.Unturned;
using System.Threading.Tasks;
using JetBrainsAnnotations::JetBrains.Annotations;
using SDG.NetTransport;
using SDG.Unturned;
using UnityEngine;
using Microsoft.Extensions.Configuration;

namespace Dummy.Events
{
Expand All @@ -36,27 +35,26 @@ public DummyDeadEvent(IDummyProvider dummyProvider, IUnturnedUserDirectory untur
[EventListener(Priority = EventListenerPriority.Monitor)]
public async Task HandleEventAsync(object? sender, UnturnedPlayerDeathEvent @event)
{
if (!m_Configuration.GetValue<bool>("logs:enableDeathLog"))
{
return;
}

var dummy = await m_DummyProvider.FindDummyUserAsync(@event.Player.SteamId.m_SteamID);
if (dummy == null)
{
return;
}

foreach (var owner in dummy.Owners)
if (m_Configuration.GetValue<bool>("logs:enableDeathLog"))
{
var player = m_UnturnedUserDirectory.FindUser(owner);
if (player == null)
foreach (var owner in dummy.Owners)
{
continue;
}
var player = m_UnturnedUserDirectory.FindUser(owner);
if (player == null)
{
continue;
}

await player.PrintMessageAsync(
$"Dummy {@event.Player.SteamId} has died. Death reason: {@event.DeathCause.ToString().ToLower()}, killer = {@event.Instigator}. Respawning...");
await player.PrintMessageAsync(
$"Dummy {@event.Player.SteamId} has died. Death reason: {@event.DeathCause.ToString().ToLower()}, killer = {@event.Instigator}. Respawning...");
}
return;
}

Revive(dummy.Player).Forget();
Expand Down

0 comments on commit e7cf947

Please sign in to comment.