Hi,
How to find sessions KillerName ?
Code:private void OnPlayerDeath(PlayerSession session, EntityEffectSourceData dataSource) { var prefix = $"<color={Config["ServerColor"]}>{Config["ServerName"]}</color>"; var textcolor = $"<color={Config["TextColor"]}>"; string name = session.Name; string KillerName = GetNameOfObject(dataSource.EntitySource); if (KillerName == "") { hurt.BroadcastChat(prefix, textcolor + (lang.GetMessage(dataSource.SourceDescriptionKey, this) ?? lang.GetMessage("Unknown", this)).Replace("{Name}", name) + "</color>"); } else { hurt.BroadcastChat(prefix, textcolor + (lang.GetMessage(dataSource.SourceDescriptionKey, this) ?? lang.GetMessage("player", this)).Replace("{Name}", name).Replace("{Killer}", KillerName) + "</color>"); } }
Solved Find session from dataSource.EntitySource
Discussion in 'Hurtworld Development' started by MonkeY12, Aug 2, 2017.
-
Ok i solved problem
Code:private PlayerSession FindSession(string nameOrIdOrIp) { var sessions = GameManager.Instance.GetSessions(); PlayerSession session = null; foreach (var i in sessions) { if (nameOrIdOrIp.Equals(i.Value.Name, StringComparison.OrdinalIgnoreCase) || nameOrIdOrIp.Equals(i.Value.SteamId.ToString()) || nameOrIdOrIp.Equals(i.Key.ipAddress)) { session = i.Value; break; } } return session; }