Raised This Month: $ Target: $400
 0% 

Help in getting the player's name who destroys an entity (prop).


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JZServices
Member
Join Date: Jul 2013
Old 04-04-2014 , 02:40   Help in getting the player's name who destroys an entity (prop).
Reply With Quote #1

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

Last edited by JZServices; 04-04-2014 at 02:40.
JZServices is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-04-2014 , 03:56   Re: Help in getting the player's name who destroys an entity (prop).
Reply With Quote #2

PHP Code:
public OnPluginStart()
{
    
HookEntityOutput("prop_physics_multiplayer""OnBreak"OnBreak);
}

public 
OnBreak(const String:output[], calleractivatorFloat:delay)
{
    
PrintToServer("output %s c %i a %i"outputcalleractivator); // activator is destroier, check it is valid client index

or use HookSingleEntityOutput to specific entity.
Remember, this hook stops after round restart.

Last edited by Bacardi; 04-04-2014 at 03:57.
Bacardi is offline
JZServices
Member
Join Date: Jul 2013
Old 04-04-2014 , 20:05   Re: Help in getting the player's name who destroys an entity (prop).
Reply With Quote #3

Awesome... I haven't seen anything on this before. I will give it a go

Thank you!
JZServices 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 05:05.


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