if you're having problems catching the grenade id in the damage event, one alternative you could use is the TE_EXPLOSION tempent. Grenades (and their explosion origins) are easily catchable with the SVC_TEMPENTITY event (event "23"), and if you have an origin of the explosion, you can get distance and a vector velocity to send the player(s) to.
here's some code to help you along..
Code:
public plugin_init() {
register_event( "23", "on_Explosion", "a","1=3","6=25" );
return PLUGIN_CONTINUE;
}
public on_Explosion() {
// GRENADE EXPLOSION
// read_data(1) = 3 (TE_EXPLOSION)
// read_data(6) = 25 (scale in 0.1's)
new Float:ExplosionOrigin[3];
read_data( 2, ExplosionOrigin[0] );
read_data( 3, ExplosionOrigin[1] );
read_data( 4, ExplosionOrigin[2] );
// .. continue from here ..
return PLUGIN_CONTINUE;
}
now you would need to check if the player(s) were damaged first, so it might be a good idea to store this origin in a global var and wait until the damage event before actually moving the players.
and speaking of which, here's a couple stocks i wrote that will help you in determining the velocity (kickback) to give the player(s) damaged.
Code:
// Gets velocity of an entity (ent) away from origin with speed (fSpeed)
stock get_velocity_from_origin( ent, Float:fOrigin[3], Float:fSpeed, Float:fVelocity[3] )
{
new Float:fEntOrigin[3];
entity_get_vector( ent, EV_VEC_origin, fEntOrigin );
// Velocity = Distance / Time
new Float:fDistance[3];
fDistance[0] = fEntOrigin[0] - fOrigin[0];
fDistance[1] = fEntOrigin[1] - fOrigin[1];
fDistance[2] = fEntOrigin[2] - fOrigin[2];
new Float:fTime = ( vector_distance( fEntOrigin,fOrigin ) / fSpeed );
fVelocity[0] = fDistance[0] / fTime;
fVelocity[1] = fDistance[1] / fTime;
fVelocity[2] = fDistance[2] / fTime;
return ( fVelocity[0] && fVelocity[1] && fVelocity[2] );
}
// Sets velocity of an entity (ent) away from origin with speed (speed)
stock set_velocity_from_origin( ent, Float:fOrigin[3], Float:fSpeed )
{
new Float:fVelocity[3];
get_velocity_from_origin( ent, fOrigin, fSpeed, fVelocity )
entity_set_vector( ent, EV_VEC_velocity, fVelocity );
return ( 1 );
}
you would really only need to use the set_velocity_from_origin() function, so let me outline the parameters a bit..
1) ent - this is the player entity that you are pushing (kicking back)
2) fOrigin - this is the origin of the grenade explosion
3) fSpeed - this is how fast you want to push the player backwards (linear). this is required to get the vector speed (velocity) that will be used to force the player back. one way to get this is to make some kind of calculation as to how far the player is from the grenade explosion, the closer (or higher damage taken), the more speed given, etc...
for example, if you wanted the player to move 5 velocity per point of damage, it's as simple as doing 5 * iDamage.
etc etc.
i can't wait to see this plugin in action
__________________