AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SC] Detect when monster_* is killed (https://forums.alliedmods.net/showthread.php?t=183376)

Rirre 04-21-2012 05:36

[SC] Detect when monster_* is killed
 
How can I use wildcard (*) in RegisterHam so it detect all killed monster_* entities by itself?
And prevent the message to spam/flood the players chat when a monster is killed and gibs.
This script flooding the chat if you kill a headcrab with the crowbar.

Also, execute server_cmd() when players receive every hundredths frags.
Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich>     public plugin_init () {     register_plugin( "Monster Frags", "1.0.0", "Rick" );     RegisterHam(Ham_Killed, "monster_zombie", "Monster_Killed", 1); } public Monster_Killed ( const Monster, const Killer ) {     if(is_user_alive( Killer ))     {         client_print( Killer, print_chat, "Monster Killed!");     } }

Devil259 04-21-2012 06:37

Re: [SC] Detect when monster_* is killed
 
What's the entity name (not classname) ?

If, for example, the name is "info_target", you've to do that :

Code:
RegisterHam( Ham_Killed, "info_target", "Monster_Killed", 1 ); public Monster_Killed( monster, killer ) {      new szClassname[ 32 ];      pev( monster, pev_classname, szClassname, 31 );      if( equal( szClassname, "monster_", 8 ) && is_user_alive( killer ) )      {           client_print( killer, print_chat, "monster killed!" );      } }

Rirre 04-21-2012 07:04

Re: [SC] Detect when monster_* is killed
 
Quote:

Originally Posted by Devil259 (Post 1693519)
What's the entity name (not classname) ?

If, for example, the name is "info_target", you've to do that :

Code:
RegisterHam( Ham_Killed, "info_target", "Monster_Killed", 1 ); public Monster_Killed( monster, killer ) {      new szClassname[ 32 ];      pev( monster, pev_classname, szClassname, 31 );      if( equal( szClassname, "monster_", 8 ) && is_user_alive( killer ) )      {           client_print( killer, print_chat, "monster killed!" );      } }

monster_* is the entity.

Devil259 04-21-2012 13:33

Re: [SC] Detect when monster_* is killed
 
Ok so I don't know if you can hook Ham_* on non-existing entity.

Better to use RegisterHamFromEntity in your case.

Emp` 04-21-2012 16:54

Re: [SC] Detect when monster_* is killed
 
You can use RegisterHam, MonsterMod creates the entities as "func_wall" though. You can use Devil259's code, just replace "info_target" with "func_wall".

Rirre 04-21-2012 18:27

Re: [SC] Detect when monster_* is killed
 
Quote:

Originally Posted by Emp` (Post 1693942)
You can use RegisterHam, MonsterMod creates the entities as "func_wall" though. You can use Devil259's code, just replace "info_target" with "func_wall".

SC in the thread name means Sven Co-op.
So this is not for botman's MonsterMod.

Devil259 04-21-2012 18:58

Re: [SC] Detect when monster_* is killed
 
Quote:

Originally Posted by Devil259 (Post 1693774)
Better to use RegisterHamFromEntity in your case.



All times are GMT -4. The time now is 07:46.

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