Raised This Month: $12 Target: $400
 3% 

Detect stuck player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 04-15-2012 , 14:39   Detect stuck player
Reply With Quote #1

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

Thanks.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM
rodrigo286 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-15-2012 , 17:02   Re: Detect stuck player
Reply With Quote #2

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.
Mitchell is offline
zeroibis
Veteran Member
Join Date: Jun 2007
Old 04-24-2012 , 22:13   Re: Detect stuck player
Reply With Quote #3

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.
__________________

Last edited by zeroibis; 04-24-2012 at 22:17.
zeroibis is offline
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 04-25-2012 , 00:54   Re: Detect stuck player
Reply With Quote #4

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?
__________________
Lord Canistra is offline
zeroibis
Veteran Member
Join Date: Jun 2007
Old 04-25-2012 , 03:16   Re: Detect stuck player
Reply With Quote #5

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.
__________________
zeroibis is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:47.


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