Raised This Month: $51 Target: $400
 12% 

SDKHook(entity, SDKHook_Spawn, Spawn);


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LeBabouin
Member
Join Date: Sep 2014
Old 11-12-2014 , 14:06   SDKHook(entity, SDKHook_Spawn, Spawn);
Reply With Quote #1

I found that sweet code here but can't get it to exec the Action:Spawn though the tf_ragdoll gets trapped in the "if". It's supposed to not spawn entities after them being created if gibs:

PHP Code:
public OnEntityCreated(entity, const String:classname[]) 
{
   if  (
StrEqual(classname"tf_ragdoll") || StrEqual(classname"prop_ragdoll"))
   {
         
PrintToServer"created = %s"classname ); 
          
SDKHook(entitySDKHook_SpawnSpawn); 
    }
}

public 
Action:Spawn(entityclassname)
{
   
PrintToServer"Action = %s"classname );
  new 
client =   GetEntPropEnt(entityProp_Send"m_hOwner");
  new 
TFClassType:class =  TF2_GetPlayerClass(client);
  if (class ==  
TFClassType:TFClass_DemoMan || class == TFClassType:TFClass_Pyro || class ==  TFClassType:TFClass_Heavy)
         return  
Plugin_Stop
  return 
Plugin_Continue;

for TF2

Last edited by LeBabouin; 11-12-2014 at 14:16.
LeBabouin is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-12-2014 , 14:25   Re: SDKHook(entity, SDKHook_Spawn, Spawn);
Reply With Quote #2

For whatever reason, returning Plugin_Stop doesn't actually seem to work for SDKHook_Spawn. No idea why. Send it a Kill input instead. AcceptEntityInput(entity, "Kill")
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 11-12-2014 , 15:31   Re: SDKHook(entity, SDKHook_Spawn, Spawn);
Reply With Quote #3

Pretty sure it doesn't work cause the ragdoll is client sided.
I hook tf_pumpkin_bomb and return Plugin_Handled; to stop them from spawning.
Mitchell is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 11-12-2014 , 15:40   Re: SDKHook(entity, SDKHook_Spawn, Spawn);
Reply With Quote #4

Lots of entities it will just hang your server, kill is usually safer
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
LeBabouin
Member
Join Date: Sep 2014
Old 11-12-2014 , 17:20   Re: SDKHook(entity, SDKHook_Spawn, Spawn);
Reply With Quote #5

Too bad, that sounded pretty. Thank you for convincing.
Quote:
Originally Posted by friagram View Post
kill is usually safer
i know what you mean ;)
I swear the tf_ragdoll entity gets created serverside though.
**edit** no luck anyway :
Quote:
L 11/12/2014 - 233:10: [SM] Native "GetEntPropEnt" reported: Property "m_hOwner" not found (entity 521/tf_ragdoll)

Last edited by LeBabouin; 11-12-2014 at 17:43.
LeBabouin is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 11-13-2014 , 00:10   Re: SDKHook(entity, SDKHook_Spawn, Spawn);
Reply With Quote #6

m_hOwnerEntity
bl4nk is offline
rswallen
SourceMod Donor
Join Date: Jun 2013
Location: 127.0.0.1
Old 11-13-2014 , 03:00   Re: SDKHook(entity, SDKHook_Spawn, Spawn);
Reply With Quote #7

Instead of blocking the spawn, try preventing the actual creation through an SDKHook_OnTakeDamage hook

PHP Code:
public Action:SDKHook_ClientOnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    new 
TFClassType:class =  TF2_GetPlayerClass(victim);
    switch (class)
    {
        case 
TFClass_DemoManTFClass_PyroTFClass_Heavy :
        {
            
damagetype |= DMG_REMOVENORAGDOLL;
            return 
Plugin_Changed;
        }
    }
    return 
Plugin_Continue;

(Though this might not work if the client/victim suicides :s)
__________________
rswallen is offline
LeBabouin
Member
Join Date: Sep 2014
Old 11-13-2014 , 17:49   Re: SDKHook(entity, SDKHook_Spawn, Spawn);
Reply With Quote #8

Quote:
Originally Posted by bl4nk View Post
m_hOwnerEntity
Thank you. Just have to find out why it throws the petty "L 11/13/2014 - 23:20:14: [SM] Native "GetEntPropEnt" reported: Property "m_hOwnerEntity" not found (entity 338/tf_ragdoll)"
When i get it working i'll try rswallen's way as it could feat my needs quite well, not talking about how clever this solution is.
Every post has been very useful and teaching, thank you so much for your help.
LeBabouin 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 06:33.


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