using System;
using System.Collections.Generic;
using CodeHatch.Damaging;
using CodeHatch.Engine.Networking;
using CodeHatch.Networking.Events.Entities;
using Oxide.Core.Plugins;
namespace Oxide.Plugins
{
[Info("DeathMessagesPlugin", "Ruby", "1.0.8")]
[Description("Displays server-wide messages for player deaths with customizable formatting, including sleeping players.")]
public class DeathMessagesPlugin : ReignOfKingsPlugin
{
private string prefix = "[FFFFFF][DeathMessages][FF0000]";
#region Lang
private new void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["DamageType"] = "[FF0000]† {0}[FFFFFF] died due to {1} at location {2}.",
["DamageMessage"] = "[FF0000]† {0}[FFFFFF] killed {1} at location {2}.",
["DamageDetails"] = "[FF0000]† Details: {0} on {1} using {2}.",
["DamageServer"] = "[FF0000]† {0}[FFFFFF] died due to {1} at location {2}.",
["ShortDmgDetails"] = "[FF0000]† Details: {0} on {1}.",
["defaultMessage"] = "[FF0000]† {0}[FFFFFF] met their fate.",
["Sleeping"] = "[8A2BE2]💤 {0}[FFFFFF] was killed in their sleep.",
["SleeperKilled"] = "[FF0000]† {0}[FFFFFF] was killed in their sleep by {1} with {2}."
}, this);
}
#endregion
void OnEntityDeath(EntityDeathEvent Event)
{
Puts("OnEntityDeath triggered.");
if (!Event.Entity.IsPlayer) return;
#region Data
var DamageType = Event.KillingDamage.DamageTypes.ToString();
var DamageAmount = Event.KillingDamage.Amount.ToString();
var HitBox = Event.KillingDamage.HitBoxBone.ToString();
string Victim = Event.Entity.Owner.DisplayName;
string Type = Event.KillingDamage.DamageTypes.ToString();
string Amount = $"{DamageAmount} damage";
string Location = $"{HitBox}";
#endregion
#region DeathLocations
string posX = Event.Entity.Position.x.ToString("F0");
string posZ = Event.Entity.Position.z.ToString("F0");
string Pos = $"[{posX} , {posZ}]";
#endregion
foreach (var player in covalence.Players.Connected)
{
#region DamageTypes
if (DamageType.Contains("Impact") ||
DamageType.Contains("Fire") ||
DamageType.Contains("Drowning") ||
DamageType.Contains("Plague") ||
DamageType.Contains("Hunger") ||
DamageType.Contains("Thirst") ||
DamageType.Contains("Unknown") ||
DamageType.Contains("OutOfBounds"))
{
PrintToChat(lang.GetMessage("DamageType", this, player.Id), Victim, Type, Pos);
return;
}
#endregion
#region Main
bool Server = Event.KillingDamage.DamageSource.Owner.IsServer;
bool Player = Event.KillingDamage.DamageSource.IsPlayer;
if (Player)
{
string Killer = Event.KillingDamage.DamageSource.Owner.DisplayName;
string Weapon = GetWeaponName(Event.KillingDamage.Damager.name);
PrintToChat(lang.GetMessage("DamageMessage", this, player.Id), Killer, Victim, Pos);
PrintToChat(lang.GetMessage("DamageDetails", this, player.Id), Amount, Location, Weapon);
return;
}
if (Server)
{
string Damage = Event.KillingDamage.DamageSource.name;
string DamagerServer = Damage.Replace("[Entity]", "");
PrintToChat(lang.GetMessage("DamageServer", this, player.Id), Victim, DamagerServer, Pos);
PrintToChat(lang.GetMessage("ShortDmgDetails", this, player.Id), Amount, Location);
return;
}
#endregion
}
}
private string GetWeaponName(string damagerName)
{
// Assuming that damagerName is the name of the entity or object causing the damage
// In many cases, this could represent the weapon, tool, or method used.
return damagerName.Replace("[Entity]", "").Trim();
}
}
}
Made a Death messages plugin to display when a 'sleeper' dies in ROK. I can't quite figure out, how to fix the issue. The Plugin can run fine just that when you kill a sleeper it doesn't say in chat. User has killed User (sleeping). I have looked at the games dnspy code and can't quite figure it out. Help will be nice.