well i wrote a dynamic native for my plugins long time ago.
Code:
//... somewhere in your *.inc file
native radiusDamage( Entity, DeathMsg[], Float:MaxDamage, Float:MaxRadius, Float:MaxDamageRadius, IgnoreEntity = 0 );
//... public plugin_natives()
register_native( "radiusDamage" , "__RadiusDamage" );
//... somewhere in your code
public __RadiusDamage( Plugin )
{
static iEntity;
iEntity = get_param(1);
static Classname[64];
get_string( 2, Classname, 63 );
static Float:fMaxDamage;
fMaxDamage = get_param_f( 3 );
static Float:MaxRadius;
MaxRadius = get_param_f( 4 );
static Float:iRadius;
iRadius = get_param_f( 5 );
static IgnoreEntity;
IgnoreEntity = get_param(6);
static Float:vExplodeAt[3], Float:damage, Float:origin1[3];
pev(iEntity, pev_origin, vExplodeAt);
static Float:multiplier, Float:distanceBetween;
static maxClients;
maxClients = global_get( glb_maxClients );
static Float:hp;
new owner = pev(iEntity, pev_owner );
iEntity = owner ? owner : iEntity;
for(new id = 1; id <= maxClients ; id++)
{
if( pev_valid(id)
&& is_user_alive(id)
&& IgnoreEntity != id
&& ( get_pcvar_num( CVAR_FriendlyFire ) || getClientTEAM( iEntity ) != getClientTEAM( id ) )
)
{
pev(id, pev_origin, origin1);
distanceBetween = get_distance_f(vExplodeAt, origin1 );
if( distanceBetween <= MaxRadius )
{
multiplier = ( fMaxDamage * fMaxDamage ) / iRadius;
damage = ( iRadius - distanceBetween ) * multiplier;
damage = floatsqroot( damage );
pev( id, pev_health, hp );
hp -= damage;
if( hp <= 0 )
{
silentClientKILL( id );
message_begin ( MSG_ALL, MSG_DeathMsg, { 0, 0, 0 }, 0 );
write_byte ( iEntity );
write_byte ( id );
write_string ( Classname );
message_end ();
}
else
{
set_pev( id, pev_health, hp );
message_begin ( MSG_ONE, MSG_Health, {0,0,0} , id );
write_byte ( floatround(hp) );
message_end ();
}
}
}
}
}
iEntity = Entity who does damage. If it has an owner, the owner will be used for the DeathMsg
DeathMsg = The weapon that will be displayed
MaxDamage = the max damage that a client will get
MaxRadius = Inside of this radius the client will get damage. How much depends on the distance to the explosion core
MaxDamageRadius = If a player is inside of this radius the client will get the maxdamage
IgnoreEntity = this entity will not get any damage.
NOTE: This code contains functions that are not in included in amxx. So you have to port this function first b4 you can use it.
getClientTEAM = returns TeamID of the player
silentClientKILL = kills a player without score-/deathmessages