Raised This Month: $ Target: $400
 0% 

Hooking entity output "OnPlayerUse" problem?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
jopmako
Senior Member
Join Date: Jul 2006
Location: QQ:331537639
Old 04-11-2008 , 13:31   Hooking entity output "OnPlayerUse" problem?
Reply With Quote #1

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.
__________________
QQ31537639
jopmako is offline
Send a message via MSN to jopmako
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode