AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Detect stuck player (https://forums.alliedmods.net/showthread.php?t=182953)

rodrigo286 04-15-2012 14:39

Detect stuck player
 
Hello, I need to detect when someone is stuck/buggy into something like a grenade or wall, as I do that?

Thanks.

Mitchell 04-15-2012 17:02

Re: Detect stuck player
 
Code:

stock IsPlayerStuck(client){
    decl Float:vecMin[3], Float:vecMax[3], Float:vecOrigin[3];
   
    GetClientMins(client, vecMin);
    GetClientMaxs(client, vecMax);
   
    GetClientAbsOrigin(client, vecOrigin);
   
    TR_TraceHullFilter(vecOrigin, vecOrigin, vecMin, vecMax, MASK_PLAYERSOLID, TraceRayDontHitPlayerAndWorld);
    return TR_GetEntityIndex();
}
stock bool:IsStuckInEnt(client, ent){
    decl Float:vecMin[3], Float:vecMax[3], Float:vecOrigin[3];
   
    GetClientMins(client, vecMin);
    GetClientMaxs(client, vecMax);
   
    GetClientAbsOrigin(client, vecOrigin);
   
    TR_TraceHullFilter(vecOrigin, vecOrigin, vecMin, vecMax, MASK_ALL, TraceRayHitOnlyEnt, ent);
    return TR_DidHit();
}

public bool:TraceRayDontHitPlayerAndWorld(entityhit, mask) {
    return entityhit>MaxClients
}
public bool:TraceRayHitOnlyEnt(entityhit, mask, any:data) {
    return entityhit==data;
}

IDK where i got this but i have it commented out because i never used it. even though i could.

zeroibis 04-24-2012 22:13

Re: Detect stuck player
 
I would be interested in testing this out. What I do is move the player slightly and then check their location. If their location is the same they are stuck.

Also does the IsStuckInEnt() stock return stuck is a player is stuck in the map or only objects on the map?

Ah I see you would just use 0 to compare the ent.

Lord Canistra 04-25-2012 00:54

Re: Detect stuck player
 
Quote:

What I do is move the player slightly and then check their location. If their location is the same they are stuck.
That here be one dangerous play. What if player is just standing near the wall or in some corner or w/e, and you push him in direction of that obstacle?

zeroibis 04-25-2012 03:16

Re: Detect stuck player
 
They are pushed up as well and the check for the change is fast enough where it works. I have always been surprised that it works so well but it has for over a year.

Previously I had some code that would do like this and try to figure out it a player would get stuck before moving them but it always would not move them when they could be or got them stuck anyways. Another issue I see with these stocks is what if you wanted to not include player collisions b/c your using no block.

I will still give these a test down the road to see how they work out. It would be ideal to be able to check locations before going to them.


All times are GMT -4. The time now is 21:54.

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