Thinking entity:
Code:
#include < amxmodx >
#include < hamsandwich >
#include < engine >
const Float:INTERVAL = 10.0;
new const g_szThinkingEntityClassname[ ] = "hitzone_think";
new g_iThinkingEntity;
public plugin_init( )
{
g_iThinkingEntity = create_entity( "info_target" );
entity_set_string( g_iThinkingEntity, EV_SZ_classname, g_szThinkingEntityClassname );
entity_set_float( g_iThinkingEntity, EV_FL_nextthink, INTERVAL );
RegisterHam( Ham_Think, g_szThinkingEntityClassname, "Forward_EntityThink" );
}
public Forward_EntityThink( iEntity )
{
static szPlayers[ 32 ], iPlayerCount, iNum, iPlayer;
if( iEntity == g_iThinkingEntity )
{
get_players( szPlayers, iPlayerCount, "a" );
for( iNum = 0; iNum < iPlayerCount; iNum++ )
{
iPlayer = szPlayers[ iNum ];
// iPlayer = index of a player
// do whatever to set their hitzone here
}
}
entity_set_float( g_iThinkingEntity, EV_FL_nextthink, INTERVAL );
}
Set task:
Code:
#include < amxmodx >
const Float:INTERVAL = 10.0;
public plugin_init( )
{
set_task( INTERVAL, "HitzoneTask", _, _, _, "b" );
}
public HitzoneTask( )
{
static szPlayers[ 32 ], iPlayerCount, iNum, iPlayer;
get_players( szPlayers, iPlayerCount, "a" );
for( iNum = 0; iNum < iPlayerCount; iNum++ )
{
iPlayer = szPlayers[ iNum ];
// iPlayer = index of a player
// do whatever to set their hitzone here
}
}
__________________