AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   TraceHull error? (https://forums.alliedmods.net/showthread.php?t=325895)

Ilusion9 07-10-2020 10:29

TraceHull error?
 
PHP Code:


float origin
[3];
GetClientAbsOrigin(clientorigin);
    
TR_TraceHullFilter(originoriginview_as<float>({-64.0, -64.00.0}), view_as<float>({64.064.00.0}), MASK_SOLIDTraceFilter_Traps);
bool result TR_DidHit();
PrintToChatAll("result %d"ent); // print: result 0

public bool TraceFilter_Traps(int entityint mask)
{
    if (
entity && entity <= MaxClients || !IsValidEntity(entity))
    {
        return 
false;
    }
    
    
char classname[128];
    
GetEntityClassname(entityclassnamesizeof(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?

Ilusion9 07-10-2020 17:30

Re: TraceHull error?
 
solved
PHP Code:


    float origin
[3];
    
GetClientAbsOrigin(clientorigin);
    
    
float vEndPos[3];
    
vEndPos[0] = origin[0];
    
vEndPos[1] = origin[1];
    
vEndPos[2] = origin[2] - 2.0;
    
    
TR_TraceHullFilter(originvEndPosview_as<float>({-64.0, -64.00.0}), view_as<float>({64.064.00.0}), MASK_SOLIDTraceFilter_Traps); 



All times are GMT -4. The time now is 22:42.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.