void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
{
if (entity == null | info == null)
return;
if (entity.PrefabName == "assets/prefabs/npc/scientist/scientist.prefab")
Puts("Scientist killed");
} Checking if entity is certain type on death?Solved
This doesn't work and i don't know why, its supposed to put that message in console when a scientist is killed. Im not sure if I just got the prefab name wrong, but i tried killing scientists on oil rig and it didn't work. How do I fix it?
Kingfoo55
This doesn't work and i don't know why, its supposed to put that message in console when a scientist is killed. Im not sure if I just got the prefab name wrong, but i tried killing scientists on oil rig and it didn't work. How do I fix it?
You could do this instead of checking the PrefabName:
void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
{
if (entity == null)
return;
if (entity is ScientistNPC)
{
Puts("scientist was killed");
}
} Thanks, this worked.
How would i do this for heavyscientists, scarecrows, murderers?
How would i do this for heavyscientists, scarecrows, murderers?
Kingfoo55
Thanks, this worked.
How would i do this for heavyscientists, scarecrows, murderers?
Most of them have same class. Check by shortname
E: What orange said.
what do you mean by check by shortname?
Merged post
Merged post
if (entity.ShortPrefabName == "murderer.prefab")would this work? Kingfoo55
what do you mean by check by shortname?
Merged postwould this work?if (entity.ShortPrefabName == "murderer.prefab")
Nope, you are using wrong shortname (https://github.com/OrangeWulf/Rust-Docs/blob/master/Entities.md)
On left column is shortname
so it would be like this
It works, thanks for the help guys.
if (entity.ShortPrefabName == "heavyscientist")It works, thanks for the help guys.
Locked automatically