PHP Code:
float origin[3];
GetClientAbsOrigin(client, origin);
TR_TraceHullFilter(origin, origin, view_as<float>({-64.0, -64.0, 0.0}), view_as<float>({64.0, 64.0, 0.0}), MASK_SOLID, TraceFilter_Traps);
bool result = TR_DidHit();
PrintToChatAll("result %d", ent); // print: result 0
public bool TraceFilter_Traps(int entity, int mask)
{
if (entity > 0 && entity <= MaxClients || !IsValidEntity(entity))
{
return false;
}
char classname[128];
GetEntityClassname(entity, classname, sizeof(classname));
if (StrEqual(classname, "func_door", true))
{
PrintToChatAll("ent %s", classname); // this prints entity name if i am in its range
return true;
}
return false;
}
I'm trying to check if players are close to a func_door (or func_rotating, door_rotating, train etc, doesn't matter). If i'm close to a func_door, TraceFilter_Traps will print in chat the entity classname.
Example: ent func_door.
So, i'm returning true.
https://sm.alliedmods.net/new-api/sd...ceEntityFilter
"True to allow the current entity to be hit, otherwise false."
But when i check for TR_DidHit or TR_GetEntityIndex, the result will be: no collision. TR_DidHit returns 0 and TR_GetEntityIndex returns -1. What's wrong?
__________________