Hey guys! I'm currently working on a plugin, and having some issues. I'm making gamemode for Rust pvp server, to recreate Roams. There is 3 teams, and each team has their own lobbies, and have UI for points. They get points for kills. I'm trying to make if player doesn't have weapon in his inventory, or belt container, team doesn't get point for it. But the issue is, if player holds a weapon and dies, the weapon drops and it's not in the inventory anymore and kill doesn't count. I tried using this code, but it doesn't work, no errors either.
private void OnEntityDeath(BasePlayer victim, HitInfo hitInfo)
{
if (victim == null || hitInfo == null)
return;
HeldEntity heldEntity = victim.GetHeldEntity() as HeldEntity;
if (UseTB)
{
if (hitInfo.InitiatorPlayer != null)
{
BasePlayer attacker = hitInfo.InitiatorPlayer;
if (victim != attacker)
{
if (victim.GetComponent<TBPlayer>() && attacker.GetComponent<TBPlayer>())
{
if (victim.GetComponent<TBPlayer>().team != attacker.GetComponent<TBPlayer>().team)
{
if (heldEntity != null) {
attacker.GetComponent<TBPlayer>().kills++;
AddPoints(attacker, victim);
}
}
}
}
}
}
}