This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Hooking entity output "OnPlayerUse" problem?


Post New Thread Reply   
 
Thread Tools Display Modes
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
blade81
Senior Member
Join Date: Apr 2005
Old 07-21-2008 , 08:17   Re: Hooking entity output "OnPlayerUse" problem?
Reply With Quote #2

Hi, i've the same problem here. The !caller output is the same as !activator. Even if i do DispatchKeyValue(ent, "OnPlayerUse", "!activator,Kill,,1") for testing, the entity kills itself and not the activator. I would like to spawn medikits in my zombiemod, therefor i need this. Am i doing something wrong or is this a bug?

The code below doesn't work as well.
PHP Code:
    new ent CreateEntityByName("prop_physics");

    
PrecacheModel("models/Items/HealthKit.mdl");
    
SetEntityModel(ent,"models/Items/HealthKit.mdl");

    
// create an entity above of player
    
new Float:origin[3];
    
GetClientAbsOrigin(idorigin);
    
origin[1] += 100;
    
DispatchKeyValueVector(ent"origin"origin);
    
DispatchKeyValue(ent"spawnflags""256");
    
DispatchKeyValue(ent"OnPlayerUse""point_servercommand,command,sm_healthkit,0,-1");

    
PrintToChatAll("ent: %i"ent);
    
DispatchSpawn(ent); 
__________________
blade81 is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 07-21-2008 , 18:19   Re: Hooking entity output "OnPlayerUse" problem?
Reply With Quote #3

Same problem, I never got it to work. I just registered a console command to "+use" and save the ent in a public variable and catch it in the use function.
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
Reply



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 19:23.


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