I'm create a "prop_physics" entity and hook it output.
Code:
#include <sourcemod>
#include <sdktools>
public OnPluginStart()
{
HookEntityOutput("prop_physics", "OnHealthChanged", EntityOutput:OnEntityOutPut)
HookEntityOutput("prop_physics", "OnPlayerUse", EntityOutput:OnEntityOutPut)
RegConsoleCmd("ent_test", ConCmd:cmd_ent_test)
}
public OnMapStart()
{
PrecacheModel("models/Gibs/HGIBS.mdl",true)
}
public Action:cmd_ent_test(id, args)
{
new ent = CreateEntityByName("prop_physics")
if (IsValidEntity(ent))
{
SetEntityModel(ent, "models/Gibs/HGIBS.mdl")
// create an entity above of player
new Float:origin[3]
GetClientAbsOrigin(id, origin)
origin[2] += 100
DispatchKeyValueVector(ent, "origin", origin)
DispatchKeyValue(ent, "targetname", "!activator")
DispatchKeyValue(ent, "spawnflags", "256")
DispatchSpawn(ent)
SetEntityMoveType(ent, MOVETYPE_FLY)
PrintToChat(id, "debug::CreateEntity(%d)", ent)
}
return Plugin_Handled
}
public OnEntityOutPut(const String:output[], caller, activator, Float:delay)
{
PrintToChatAll("output=%s, caller=%d, activator=%d",output, caller, activator)
}
According of
http://developer.valvesoftware.com/wiki/Prop_physics,
the output "activator" shoule be player index when we +USE or hit the entity.
In fact, when we hit the entity, output "OnHealthChanged" is working good.
But when +USE, the result alway "activator"=="caller" ?
Any problem with this code and how to get it work corrently?
Thanks.
__________________