void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
{
BasePlayer killer = info?.Initiator as BasePlayer;
if (killer.userID.IsSteamId())
{
if (!Cachedplayerstats.ContainsKey(killer.userID)) PVEStatsData.TryLoad(killer.userID);
}
if (!killer.userID.IsSteamId()) return;
if (entity == null | info == null) return;
if (killer == null || killer == entity) return;
if (killer.userID.IsSteamId())
{
if (entity.ShortPrefabName == "heavyscientist")
{
if ((bool)Config["Count Heavy Scientists"] == true)
{
if (Cachedplayerstats.ContainsKey(killer.userID)) Cachedplayerstats[killer.userID].heavyKills++;
int newheavypoints = Cachedplayerstats[killer.userID].points + heavypoints;
Cachedplayerstats[killer.userID].points = newheavypoints;
}
}
}
if (killer.userID.IsSteamId())
{
if (entity.ShortPrefabName == "scientistnpc")
{
if ((bool)Config["Count Scientists"] == true)
{
if (Cachedplayerstats.ContainsKey(killer.userID)) Cachedplayerstats[killer.userID].scientistkills++;
int newscientistpoints = Cachedplayerstats[killer.userID].points + scientistpoints;
Cachedplayerstats[killer.userID].points = newscientistpoints;
}
}
}
if (killer.userID.IsSteamId())
{
if (entity.ShortPrefabName == "murderer")
{
if ((bool)Config["Count Murderers"] == true)
{
if (Cachedplayerstats.ContainsKey(killer.userID)) Cachedplayerstats[killer.userID].murdererkills++;
int newmurdererpoints = Cachedplayerstats[killer.userID].points + murdererpoints;
Cachedplayerstats[killer.userID].points = newmurdererpoints;
}
}
}
if (killer.userID.IsSteamId())
{
if (entity.ShortPrefabName == "scarecrow")
{
if ((bool)Config["Count Scarecrow"] == true)
{
if (Cachedplayerstats.ContainsKey(killer.userID)) Cachedplayerstats[killer.userID].scarecrowkills++;
int newscarecrowpoints = Cachedplayerstats[killer.userID].points + scarecrowpoints;
Cachedplayerstats[killer.userID].points = newscarecrowpoints;
}
}
}
if (entity is HTNPlayer)
{
if (entity.ShortPrefabName == "scarecrow")
{
}
else
{
if ((bool)Config["Count Scientists"] == true)
{
if (Cachedplayerstats.ContainsKey(killer.userID)) Cachedplayerstats[killer.userID].scientistkills++;
int newscientistallpoints = Cachedplayerstats[killer.userID].points + scientistpoints;
Cachedplayerstats[killer.userID].points = newscientistallpoints;
}
}
}
foreach (var data in Cachedplayerstats) data.Value.Save(data.Key);
checkrankalreadyhad(killer);
CheckRank(killer, info);
GUIUpdateSkill(killer);
CreateGUI(killer);
return;
}Hey, I am using on entity death to count certain ai kills. However i noticed that on my server, i keep getting these null referance exceptionns. how do i make it so it returns everything except what i want to count. Thanks.