This is for my Weapon Immunity plugin, to make players immune to the HE grenade. The idea is to stop a grenade's FindEntityInSphere from returning any players that are immune. This is my code:
Code:
public plugin_init()
{
register_forward(FM_FindEntityInSphere,"fw_sphere",0);
}
public fw_sphere(start,Float:origin[3],Float:radius)
{
// not a grenade's radius
if(radius != 350.0) return FMRES_IGNORED;
// run the same check to see what its result will be
new hit = engfunc(EngFunc_FindEntityInSphere,start,origin,radius);
if(is_user_alive(hit) && immune[hit][CSW_HEGRENADE])
{
// run another check to see who should be hit instead of me
hit = engfunc(EngFunc_FindEntityInSphere,hit,origin,radius);
client_print(0,print_chat,"* You got hit by a grenade! Returning instead: %i",hit);
forward_return(FMV_CELL,hit);
return FMRES_OVERRIDE;
}
return FMRES_IGNORED;
}
immune[hit][CSW_HEGRENADE] is true.
Part of this works, in that I can't take any damage from HE grenades. The message comes up and gives me a valid entity index that isn't me. The problem is that this seemingly stops any more checks from being called afterwards:
If I get a bot and turn on friendlyfire, make myself immune and him not, when I throw a grenade at us both, it tells me that I was hit by a grenade, and that it is instead returning 2 (the bot). However, the bot takes no damage (and neither do I, since I'm immune). This is the same functionality as if I were to return FMRES_SUPERCEDE.
Why wouldn't this be working?
Thanks.
__________________