Show kill notification
This commit is contained in:
parent
d0eb0b7818
commit
92e1a970a8
@ -170,8 +170,7 @@ namespace RageCoop.Client
|
||||
P.Health = 1;
|
||||
Game.Player.WantedLevel = 0;
|
||||
Main.Logger.Debug("Player died.");
|
||||
Scripting.API.Events.InvokePlayerDied();
|
||||
KillMessage();
|
||||
Scripting.API.Events.InvokePlayerDied(KillMessage());
|
||||
}
|
||||
GTA.UI.Screen.StopEffects();
|
||||
}
|
||||
@ -182,8 +181,7 @@ namespace RageCoop.Client
|
||||
}
|
||||
else if (P.IsDead && !_lastDead)
|
||||
{
|
||||
Scripting.API.Events.InvokePlayerDied();
|
||||
KillMessage();
|
||||
Scripting.API.Events.InvokePlayerDied(KillMessage());
|
||||
}
|
||||
|
||||
_lastDead = P.IsDead;
|
||||
@ -395,14 +393,15 @@ namespace RageCoop.Client
|
||||
});
|
||||
}
|
||||
|
||||
public static void KillMessage()
|
||||
private string KillMessage()
|
||||
{
|
||||
if (P.Killer != null)
|
||||
{
|
||||
var killer = EntityPool.GetPedByHandle(P.Killer.Handle);
|
||||
if (killer != null && killer.ID == killer.Owner.ID)
|
||||
Scripting.API.SendChatMessage($"Killed by {killer.Owner.Username} ({P.CauseOfDeath})");
|
||||
return $"~h~{PlayerList.GetPlayer(LocalPlayerID).Username}~h~ was killed by ~h~{killer.Owner.Username}~h~ ({P.CauseOfDeath})";
|
||||
}
|
||||
return $"~h~{PlayerList.GetPlayer(LocalPlayerID).Username}~h~ died";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ namespace RageCoop.Client.Scripting
|
||||
/// <summary>
|
||||
/// The local player is dead
|
||||
/// </summary>
|
||||
public static event EmptyEvent OnPlayerDied;
|
||||
public static event EventHandler<string> OnPlayerDied;
|
||||
|
||||
/// <summary>
|
||||
/// A local vehicle is spawned
|
||||
@ -133,7 +133,7 @@ namespace RageCoop.Client.Scripting
|
||||
internal static void InvokeVehicleDeleted(SyncedVehicle v) { OnVehicleDeleted?.Invoke(null, v); }
|
||||
internal static void InvokePedSpawned(SyncedPed p) { OnPedSpawned?.Invoke(null, p); }
|
||||
internal static void InvokePedDeleted(SyncedPed p) { OnPedDeleted?.Invoke(null, p); }
|
||||
internal static void InvokePlayerDied() { OnPlayerDied?.Invoke(); }
|
||||
internal static void InvokePlayerDied(string m) { OnPlayerDied?.Invoke(null, m); }
|
||||
internal static void InvokeTick() { OnTick?.Invoke(); }
|
||||
|
||||
internal static void InvokeKeyDown(object s, KeyEventArgs e) { OnKeyDown?.Invoke(s, e); }
|
||||
|
@ -16,7 +16,7 @@ namespace RageCoop.Client.Scripting
|
||||
{
|
||||
API.Events.OnPedDeleted += (s, p) => { API.SendCustomEvent(CustomEvents.OnPedDeleted, p.ID); };
|
||||
API.Events.OnVehicleDeleted += (s, p) => { API.SendCustomEvent(CustomEvents.OnVehicleDeleted, p.ID); };
|
||||
API.Events.OnPlayerDied += () => { API.SendCustomEvent(CustomEvents.OnPlayerDied); };
|
||||
API.Events.OnPlayerDied += (s, m) => { API.SendCustomEvent(CustomEvents.OnPlayerDied, m); };
|
||||
|
||||
API.RegisterCustomEventHandler(CustomEvents.SetAutoRespawn, SetAutoRespawn);
|
||||
API.RegisterCustomEventHandler(CustomEvents.SetDisplayNameTag, SetDisplayNameTag);
|
||||
@ -31,7 +31,7 @@ namespace RageCoop.Client.Scripting
|
||||
API.RegisterCustomEventHandler(CustomEvents.UpdatePedBlip, UpdatePedBlip);
|
||||
API.RegisterCustomEventHandler(CustomEvents.IsHost, (e) => { _isHost = (bool)e.Args[0]; });
|
||||
API.RegisterCustomEventHandler(CustomEvents.WeatherTimeSync, WeatherTimeSync);
|
||||
API.RegisterCustomEventHandler(CustomEvents.OnPlayerDied, (e) => { GTA.UI.Notification.Show($"~h~{e.Args[0]}~h~ died."); });
|
||||
API.RegisterCustomEventHandler(CustomEvents.OnPlayerDied, (e) => { GTA.UI.Notification.Show((string)e.Args[0]); });
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
|
@ -38,7 +38,7 @@ namespace RageCoop.Server.Scripting
|
||||
});
|
||||
API.RegisterCustomEventHandler(CustomEvents.OnPlayerDied, (e) =>
|
||||
{
|
||||
API.SendCustomEventQueued(API.GetAllClients().Values.Where(x => x != e.Client).ToList(), CustomEvents.OnPlayerDied, e.Client.Username);
|
||||
API.SendCustomEventQueued(API.GetAllClients().Values.Where(x => x != e.Client).ToList(), CustomEvents.OnPlayerDied, e.Args);
|
||||
});
|
||||
API.Events.OnChatMessage += (s, e) =>
|
||||
Server.Logger?.Info((e.Client?.Username ?? e.ClaimedSender ?? "Unknown") + ": " + e.Message);
|
||||
|
Loading…
Reference in New Issue
Block a user