I am trying to add a player to a group once they get to a certain kill threshold. To add someone to a group you need to use Iplayer, but all of my players are baseplayer atm. How do i get an Iplayer into this function?
void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
{
BasePlayer killer = info?.Initiator as BasePlayer;
if (entity == null | info == null) return;
if (killer == null || killer == entity) return;
if (entity.ShortPrefabName == "heavyscientist")
{
if ((bool)Config["Count Heavy Scientists"] == true)
if (Cachedplayerstats.ContainsKey(killer.userID)) Cachedplayerstats[killer.userID].heavyKills++;
HeavyCount(killer);
}
if (entity.ShortPrefabName == "scientistnpc")
{
if ((bool)Config["Count Scientists"] == true)
if (Cachedplayerstats.ContainsKey(killer.userID)) Cachedplayerstats[killer.userID].scientistkills++;
}
if (entity.ShortPrefabName == "murderer")
{
if ((bool)Config["Count Murderers"] == true)
if (Cachedplayerstats.ContainsKey(killer.userID)) Cachedplayerstats[killer.userID].murdererkills++;
}
if (entity.ShortPrefabName == "scarecrow")
{
if ((bool)Config["Count Scarecrow"] == true)
if (Cachedplayerstats.ContainsKey(killer.userID)) Cachedplayerstats[killer.userID].scarecrowkills++;
}
foreach (var data in Cachedplayerstats) data.Value.Save(data.Key);
return;
}
public void HeavyCount(BasePlayer player)
{
if (!Cachedplayerstats.ContainsKey(player.userID)) PVEStatsData.TryLoad(player.userID);
if (Cachedplayerstats[player.userID].heavyKills == (int)Config["first heavy scientist threshhold"])
{
target.AddToGroup((string)Config["first heavy scientist threshold oxide group"]);
}
}