daily pastebin goal
42%
SHARE
TWEET

CheckStuckPlayer

Nero-San Dec 7th, 2017 100 in 24 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void CheckStuckPlayer( CBasePlayer@ pPlayer )
  2. {
  3.     Vector origin, mins;
  4.     HULL_NUMBER hull;
  5.     const array<Vector> size = {
  6.         Vector(0.0, 0.0, 1.0), Vector(0.0, 0.0, -1.0), Vector(0.0, 1.0, 0.0), Vector(0.0, -1.0, 0.0), Vector(1.0, 0.0, 0.0), Vector(-1.0, 0.0, 0.0), Vector(-1.0, 1.0, 1.0),Vector(1.0, 1.0, 1.0),Vector(1.0, -1.0, 1.0),Vector(1.0, 1.0, -1.0), Vector(-1.0, -1.0, 1.0), Vector(1.0, -1.0, -1.0), Vector(-1.0, 1.0, -1.0), Vector(-1.0, -1.0, -1.0),
  7.         Vector(0.0, 0.0, 2.0), Vector(0.0, 0.0, -2.0), Vector(0.0, 2.0, 0.0), Vector(0.0, -2.0, 0.0), Vector(2.0, 0.0, 0.0), Vector(-2.0, 0.0, 0.0), Vector(-2.0, 2.0, 2.0), Vector(2.0, 2.0, 2.0), Vector(2.0, -2.0, 2.0), Vector(2.0, 2.0, -2.0), Vector(-2.0, -2.0, 2.0), Vector(2.0, -2.0, -2.0), Vector(-2.0, 2.0, -2.0), Vector(-2.0, -2.0, -2.0),
  8.         Vector(0.0, 0.0, 3.0), Vector(0.0, 0.0, -3.0), Vector(0.0, 3.0, 0.0), Vector(0.0, -3.0, 0.0), Vector(3.0, 0.0, 0.0), Vector(-3.0, 0.0, 0.0), Vector(-3.0, 3.0, 3.0), Vector(3.0, 3.0, 3.0), Vector(3.0, -3.0, 3.0), Vector(3.0, 3.0, -3.0), Vector(-3.0, -3.0, 3.0), Vector(3.0, -3.0, -3.0), Vector(-3.0, 3.0, -3.0), Vector(-3.0, -3.0, -3.0),
  9.         Vector(0.0, 0.0, 4.0), Vector(0.0, 0.0, -4.0), Vector(0.0, 4.0, 0.0), Vector(0.0, -4.0, 0.0), Vector(4.0, 0.0, 0.0), Vector(-4.0, 0.0, 0.0), Vector(-4.0, 4.0, 4.0), Vector(4.0, 4.0, 4.0), Vector(4.0, -4.0, 4.0), Vector(4.0, 4.0, -4.0), Vector(-4.0, -4.0, 4.0), Vector(4.0, -4.0, -4.0), Vector(-4.0, 4.0, -4.0), Vector(-4.0, -4.0, -4.0),
  10.         Vector(0.0, 0.0, 5.0), Vector(0.0, 0.0, -5.0), Vector(0.0, 5.0, 0.0), Vector(0.0, -5.0, 0.0), Vector(5.0, 0.0, 0.0), Vector(-5.0, 0.0, 0.0), Vector(-5.0, 5.0, 5.0), Vector(5.0, 5.0, 5.0), Vector(5.0, -5.0, 5.0), Vector(5.0, 5.0, -5.0), Vector(-5.0, -5.0, 5.0), Vector(5.0, -5.0, -5.0), Vector(-5.0, 5.0, -5.0), Vector(-5.0, -5.0, -5.0)
  11.     };
  12.  
  13.     if( pPlayer.IsConnected() && pPlayer.IsAlive() )
  14.     {
  15.         origin = pPlayer.pev.origin;
  16.         hull = pPlayer.pev.FlagBitSet(FL_DUCKING) ? head_hull : human_hull;
  17.         if( !is_hull_vacant(origin, hull, pPlayer) && pPlayer.pev.movetype != MOVETYPE_NOCLIP && pPlayer.pev.solid != SOLID_NOT )
  18.         {
  19.             mins = pPlayer.pev.mins;
  20.             Vector vec;
  21.             vec.z = origin.z;
  22.             for( uint ofs = 0; ofs < size.length(); ++ofs )
  23.             {
  24.                 vec.x = origin.x - mins.x * size[ofs].x;
  25.                 vec.y = origin.y - mins.y * size[ofs].y;
  26.                 vec.z = origin.z - mins.z * size[ofs].z;
  27.                 if( is_hull_vacant(vec, hull, pPlayer) )
  28.                 {
  29.                     pPlayer.SetOrigin( vec );
  30.                     ofs = size.length();
  31.                 }
  32.             }
  33.         }
  34.     }
  35. }
  36.  
  37. bool is_hull_vacant( Vector origin, HULL_NUMBER hull, CBasePlayer@ pPlayer )
  38. {
  39.     TraceResult tr;
  40.     g_Utility.TraceHull( origin, origin, ignore_monsters, hull, pPlayer.edict(), tr );//dont_ignore_monsters makes you bob up and down on placed corpses
  41.  
  42.     if( tr.fStartSolid != 1 || tr.fAllSolid != 1 )
  43.         return true;
  44.    
  45.     return false;
  46. }
RAW Paste Data
Top