PHP Code:
stock DamagePlayer(id, damage, damageType, origin[3])
{
new entity= engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "trigger_hurt"))
//Damage
set_kvd(0, KV_ClassName, "trigger_hurt")
set_kvd(0, KV_KeyName, "dmg")
set_kvd(0, KV_Value, damage)
set_kvd(0, KV_fHandled, 0)
dllfunc(DLLFunc_KeyValue, entity, 0)
//Damage Type
set_kvd(1, KV_ClassName, "trigger_hurt")
set_kvd(1, KV_KeyName, "damagetype")
set_kvd(1, KV_Value, damageType)
set_kvd(1, KV_fHandled, 0)
dllfunc(DLLFunc_KeyValue, entity, 1)
//Origin
set_kvd(2, KV_ClassName, "trigger_hurt")
set_kvd(2, KV_KeyName, "origin")
set_kvd(2, KV_Value, origin)
set_kvd(2, KV_fHandled, 0)
dllfunc(DLLFunc_KeyValue, entity, 2)
//Spawn the entity
dllfunc(DLLFunc_Spawn, entity)
//Touch entity and the player
dllfunc(DLLFunc_Touch, entity, id)
//Remove the entity
engfunc(EngFunc_RemoveEntity, entity)
}
When I use it like this to make a player kill another (with gibs):
PHP Code:
DamagePlayer(target, health, DMG_ALWAYSGIB|DMG_ENERGYBEAM, origin)
the game crashes, but I can't find which function makes it crash.
__________________