AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check if entity enters world (https://forums.alliedmods.net/showthread.php?t=55954)

hlstriker 06-03-2007 00:06

Check if entity enters world
 
I am trying to find out when a new entity enters the world.

I thought pfn_spawn would work but it turns out that isn't called in mid map :P

Example:
Code:
public pfn_spawn(entId) {     new className[64];     entity_get_string(entId, EV_SZ_classname, className, 63);         if(equali(className, "someClassName"))     {         // do something with entId entity     } }

I need something like that, but since pfn_spawn doesn't catch entities spawned in the middle of a map it doesn't work.

XxAvalanchexX 06-03-2007 00:16

Re: Check if entity enters world
 
You might be able to hook FM_CreateNamedEntity, but it won't work on entities created by Metamod, I believe.

hlstriker 06-03-2007 00:58

Re: Check if entity enters world
 
Thanks for the info, it should work.

How do I find arguments out though to use with it? I've always needed to know that.

XxAvalanchexX 06-03-2007 01:06

Re: Check if entity enters world
 
Arguments to use with it?

hlstriker 06-03-2007 01:29

Re: Check if entity enters world
 
I'm not really familiar with FM, don't I have to register a forward to it then use some arguments?

I really don't even know what I'm talking about lol...

Can you explain how I would use that please?

regalis 06-03-2007 07:49

Re: Check if entity enters world
 
I'm not sure if this works...
*edit* don't work...*edit*
I wonder if the EntID is passed too and not only the classname..0o

greetz regalis

P34nut 06-03-2007 08:00

Re: Check if entity enters world
 
Code:
#include <amxmodx> #include <fakemeta> public plugin_init() {     register_forward(FM_CreateNamedEntity, "fwCreateNamedEntity_post", 1) } public fwCreateNamedEntity_post(iClassname) {     static ent, szClassname[32]     ent = get_orig_retval()         engfunc(EngFunc_SzFromIndex, iClassname, szClassname, 31)         if (equal(szClassname, "MYCLASSNAME"))     {         // Do Something     } }

Zenith77 06-03-2007 11:00

Re: Check if entity enters world
 
Quote:

Originally Posted by XxAvalanchexX (Post 485100)
You might be able to hook FM_CreateNamedEntity, but it won't work on entities created by Metamod, I believe.

Just out of curiosity, how not?

VEN 06-03-2007 11:30

Re: Check if entity enters world
 
In my opinion Ham_Spawn hook should work for all entities that is created by the mod. And for ones that is spawned by mm/amxx/plugins. Shouldn't work for custom entities that isn't spawned.

XxAvalanchexX 06-03-2007 12:48

Re: Check if entity enters world
 
Quote:

Originally Posted by Zenith77 (Post 485206)
Just out of curiosity, how not?

I'm pretty sure that Metamod (and all of its plugins, so AMXX and AMXX's plugins), can't (or won't) hook functions called by itself.


All times are GMT -4. The time now is 10:35.

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