SOLUTION:
It's maybe not the best solution out there, but it does works.
So, instead of detecting the shield, I thought about detecting if entity is touching player from behind, sides, or front. Since player is fully covered in front when using shield, this way of detecting is helping me achive what I wanted. (If entity is touching player in front, it means it's touching the shield too).
And that's where I remembered about this plugin that prevents players from back stabbing.
https://forums.alliedmods.net/showpo...66&postcount=4 So after some small changes I made it work.
The code I am using in FM_Touch forward after checking if entity is touching player and all other checks:
PHP Code:
if(is_using_shield(id))
{
static Float:fOrigin[3];
pev(id, pev_origin, fOrigin);
static Float:fViewAngles[3]
static Float:fTViewAngles[3];
pev(bullet, pev_v_angle, fTViewAngles);
static Float:fMinAngle, Float:fMaxAngle;
fMinAngle = fViewAngles[1] - CHECK_ANGLE;
fMaxAngle = fViewAngles[1] + CHECK_ANGLE;
if(fMinAngle <= fTViewAngles[1] <= fMaxAngle)
{
// Entity is touching player's back
}
else
{
// Entity is touching player's front (shield)
}
}
Define and stock used
PHP Code:
#define CHECK_ANGLE 100.0
bool:is_using_shield(id)
{
if(entity_get_int(id , EV_INT_sequence) == 98)
return true;
return false;
}
If there is a better way of doing this, I am always up for suggestions.