So, I have been trying to figure out how to do this for the last several hours. I can't really find any straight forward simple solution.
I currently have:
The ability to spawn props from the player in the server.
When the prop is spawned:
I create a bool with the entity index and mark it to true.
Add the client of the player who spawned the prop to an array.
I use OnEntityDestroyed(entity)
and do some stuff when it is destroyed and mark the bool to false for the entity.
Is there a way to get the attacker of the entity within OnEntityDestroyed?
The only way that I can think of doing this is:
adding on prop creation
SDKHook(<entity id>, SDKHook_OnTakeDamage, OnTakeDamage);
then
public Action:OnTakeDamage(entity, &attacker, &inflictor, &Float:damage, &damagetype)
{
if (0<entity<MAXENTITIES)
{
if (b_SpawnedProps[entity])
{
new hp=GetEntProp(entity, Prop_Data, "m_iHealth");
if (hp-damage<=0)
{
PrintToChat(g_PropOwner[entity],"Stuff to say to them when their prop is destroyed");
}
}
}
}
but that is the most direct way I can think of with the least amount of calculations by the server...
anyone know a better way to get the attacker of a prop that has been destroyed?
I know if you turn on the switch -allowdebug it prints the player name who destroys a prop in the console.... :/
Thanks guys