hi,
I want to prevent players from shooting through walls .
I tried to use first the bullet penetration filter, from Sheepdude (which is also bugged to me)
Actually it works as it should : it blocks bullets to walls BUT often when i try to shoot a player into his head by using a scout (zoomed)
without any entity between us, hitgroup return 0, instead of 1...
When i try to cut a player, it returns... nothing!
Obviously in both cases, the player takes zero damage.
I search for a long time, i tried a lot of different things, it's always the same result...
So what's wrong?
Here is the code
PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3])
{
if(!IsValidClient(attacker) || !IsValidClient(victim))
return Plugin_Continue;
if(attacker == victim)
return Plugin_Continue;
if(victim_hitgroups[victim] == 0)
{
damage = 0.0;
return Plugin_Changed;
}
return Plugin_Continue;
}
public Action:OnTraceAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{
if(!IsValidClient(attacker) || !IsValidClient(victim))
return Plugin_Continue;
if(attacker == victim)
return Plugin_Continue;
new Float:vAngles[3], Float:vOrigin[3];
GetClientEyePosition(attacker,vOrigin);
GetClientEyeAngles(attacker, vAngles);
new Handle:trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer, attacker);
new index = TR_GetEntityIndex( trace );
victim_hitgroups[index] = 0;
if(IsValidClient(index))
{
victim_hitgroups[index] = hitgroup;
PrintToChat(attacker, "Target: %N | Hitgroup: %d", index, victim_hitgroups[index]);
}
return Plugin_Continue;
}
public bool:TraceEntityFilterPlayer(entity, contentsMask, any:data)
{
if(0 < entity <= MaxClients && entity != data)
return true;
return false;
}
stock bool:IsValidClient(client)
{
if (0 < client <= MaxClients && IsClientInGame(client))
return true;
return false;
}