Advertisement
Guest User

Untitled

a guest
Dec 18th, 2013
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.33 KB | None | 0 0
  1. public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
  2. {
  3.     new iInitialButtons = buttons;
  4.    
  5.     if(!IsPlayerAlive(client))
  6.         return Plugin_Continue;
  7.    
  8.     new mode = Timer_GetMode(client);
  9.     new Float:fGameTime = GetGameTime();
  10.     new bool:abuse = false;
  11.     new bool:oldgroundstatus = g_bStayOnGround[client];
  12.     new bool:onground = bool:(GetEntityFlags(client) & FL_ONGROUND);
  13.    
  14.     new Float:vecVelocity[3];
  15.     GetEntDataVector(client, g_iOffs_Velocity, vecVelocity);
  16.    
  17.     new bool:GainHeight = false;
  18.    
  19.     if(g_fCord_Old[client][2] < g_fCord_New[client][2])
  20.     {
  21.         GainHeight = true;
  22.     }
  23.    
  24.     decl Float:fVelocity[3];
  25.     GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVelocity); //velocity
  26.     new Float:currentspeed = SquareRoot(Pow(fVelocity[0],2.0)+Pow(fVelocity[1],2.0)); //player speed (units per secound)
  27.    
  28.     g_fSpeedTotal[client] += currentspeed;
  29.     g_iCommandCount[client] ++;
  30.     g_fSpeedCurrent[client] = currentspeed;
  31.    
  32.     if(currentspeed > g_fSpeedMax[client])
  33.     {
  34.         g_fSpeedMax[client] = currentspeed;
  35.     }
  36.  
  37.     g_fCord_Old[client][0] = g_fCord_New[client][0];
  38.     g_fCord_Old[client][1] = g_fCord_New[client][1];
  39.     g_fCord_Old[client][2] = g_fCord_New[client][2];
  40.    
  41.     GetClientAbsOrigin(client, g_fCord_New[client]);
  42.    
  43.     if(g_fCord_Old[client][2] > g_fCord_New[client][2] && GainHeight)
  44.     {
  45.         //PrintToChat(client, "Jumped height max reached: %f units", g_fCord_Old[client][2]-g_fJumpLastCord[client][2]);
  46.        
  47.         //new ForwardMaxJumpHeight;
  48.     }
  49.    
  50.     if(!onground && !Client_IsOnLadder(client))
  51.     {
  52.         if(g_Physics[mode][ModePreventLeft])
  53.         {
  54.             if(vel[1] < 0 || buttons & IN_MOVELEFT)
  55.             {
  56.                 TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
  57.                
  58.                 abuse = true;
  59.             }
  60.         }
  61.        
  62.         if(g_Physics[mode][ModePreventRight])
  63.         {
  64.             if(vel[1] > 0 || buttons & IN_MOVERIGHT)
  65.             {
  66.                 TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
  67.                
  68.                 abuse = true;
  69.             }
  70.         }
  71.        
  72.         if(g_Physics[mode][ModePreventMoveforward])
  73.         {
  74.             if(vel[0] > 0 || buttons & IN_FORWARD)
  75.             {
  76.                 TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
  77.                
  78.                 abuse = true;
  79.             }
  80.         }
  81.        
  82.         if(g_Physics[mode][ModePreventMoveback])
  83.         {
  84.             if(vel[0] < 0 || buttons & IN_BACK)
  85.             {
  86.                 TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
  87.                
  88.                 abuse = true;
  89.             }
  90.         }
  91.        
  92.         if(vecVelocity[2] <= 0)
  93.         {
  94.             if(g_Physics[mode][ModeBlockMovementDirection] != 0)
  95.             {
  96.                 if(currentspeed > 200.00)
  97.                 {
  98.                     //backwards
  99.                     if(g_Physics[mode][ModeBlockMovementDirection] == 1)
  100.                     {
  101.                         new Float:direction = GetClientMovingDirection(client);
  102.                         if (direction > 0.45)
  103.                         {
  104.                             TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
  105.                             abuse = true;
  106.                         }
  107.                     }
  108.                     //forward
  109.                     else if(g_Physics[mode][ModeBlockMovementDirection] == 2)
  110.                     {
  111.                         if (GetClientMovingDirection(client) < -0.45)
  112.                         {
  113.                             TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
  114.                             abuse = true;
  115.                         }
  116.                     }
  117.                 }
  118.             }
  119.         }
  120.     }
  121.    
  122.     if(buttons & IN_JUMP)
  123.     {
  124.         if(!Timer_IsPlayerTouchingZoneType(client, ZtNoBoost))
  125.         {
  126.             if(g_fBoost[client] > 0.0)
  127.             {
  128.                 if(onground && !g_bPushWait[client])
  129.                 {
  130.                     //PrintToChat(client, "Create Timer");
  131.                     g_bPushWait[client] = true;
  132.                     //CreateTimer(0.0, Timer_Push, client, TIMER_FLAG_NO_MAPCHANGE);
  133.                     Push_Client(client);
  134.                 }
  135.             }
  136.         }
  137.        
  138.         if(!onground)
  139.         {
  140.             //Settings/Zone check
  141.             if((g_bAuto[client] || Timer_IsPlayerTouchingZoneType(client, ZtAuto)) && !g_bAutoDisable[client] && !Timer_IsPlayerTouchingZoneType(client, ZtNoAuto))
  142.             {
  143.                 //Ladder check
  144.                 if (!Client_IsOnLadder(client))
  145.                 {
  146.                     //Wather check
  147.                     if (GetEntProp(client, Prop_Data, "m_nWaterLevel") <= 1)
  148.                     {
  149.                         buttons &= ~IN_JUMP;
  150.                     }
  151.                 }
  152.             }
  153.         }
  154.     }
  155.  
  156.     // Player didn't jump immediately after the last jump.
  157.     if (!(buttons & IN_JUMP) && onground && fCheckTime[client] > 0.0)
  158.     {
  159.         fCheckTime[client] = 0.0;
  160.     }
  161.  
  162.     new oldjumps = g_iFullJumpCount[client];
  163.     new bool:perfect = false;
  164.        
  165.     // Ignore this jump if the player is in a tight space or stuck in the ground.
  166.     if ((buttons & IN_JUMP) && !abuse)
  167.     {
  168.         if(!(iPrevButtons[client] & IN_JUMP))
  169.         {
  170.             // Player is on the ground and about to trigger a jump.
  171.             if (onground)
  172.             {
  173.                 // Player jumped on the exact frame that allowed it.
  174.                 if (fCheckTime[client] > 0.0 && fGameTime >= fCheckTime[client])
  175.                 {
  176.                     perfect = true;
  177.                     g_iFullJumpCount[client]++;
  178.                     g_fJumpAccuracy[client] = 100-((100/g_Settings[MultiBhopDelay])*g_fFullJumpTimeAmount[client])/g_iFullJumpCount[client];
  179.                 }
  180.                 else
  181.                 {
  182.                     fCheckTime[client] = fGameTime + g_Settings[MultiBhopJumpTime];
  183.                 }  
  184.             }
  185.             else if(fCheckTime[client] != 0.0)
  186.             {
  187.                 fCheckTime[client] = 0.0;
  188.             }
  189.         }
  190.     }
  191.    
  192.     if(!abuse && !perfect)
  193.     {
  194.         //Save new on ground status
  195.         if(onground)
  196.         {
  197.             if(!g_bStayOnGround[client] && g_fBoost[client] > 0.0)
  198.             {
  199.                 //PrintToChat(client, "Ready to boost");
  200.                 g_bPushWait[client] = false;
  201.             }
  202.            
  203.             g_bStayOnGround[client] = true;
  204.         }
  205.         else
  206.         {
  207.             g_bStayOnGround[client] = false;
  208.         }
  209.        
  210.         //Player landed
  211.         if(g_bStayOnGround[client] && g_bStayOnGround[client] != oldgroundstatus)
  212.         {
  213.             g_fLandedTime[client] = fGameTime;
  214.         }
  215.        
  216.         //Player jumped
  217.         if(!g_bStayOnGround[client] && g_bStayOnGround[client] != oldgroundstatus)
  218.         {
  219.             if(fGameTime-g_fLandedTime[client] < g_Settings[MultiBhopJumpTime])
  220.             {
  221.                 g_iFullJumpCount[client]++;
  222.             }
  223.             else
  224.             {
  225.                 g_bFirstJump[client] = true;
  226.                 //PrintToChat(client, "First Jump");
  227.             }
  228.         }
  229.        
  230.         //Player has jumped? How good was his jump?
  231.         if(oldjumps < g_iFullJumpCount[client]) //don't count first jump
  232.         {
  233.             if(fGameTime-g_fLandedTime[client] > g_Settings[MultiBhopDelay])
  234.             {
  235.                 g_fFullJumpTimeAmount[client] += g_Settings[MultiBhopDelay];
  236.             }
  237.             else if(fGameTime-g_fLandedTime[client] > 0.0)
  238.             {
  239.                 g_fFullJumpTimeAmount[client] += fGameTime-g_fLandedTime[client];
  240.             }
  241.            
  242.             //update jump accuracy
  243.             g_fJumpAccuracy[client] = 100-((100/g_Settings[MultiBhopDelay])*g_fFullJumpTimeAmount[client])/g_iFullJumpCount[client];
  244.         }
  245.     }
  246.    
  247.     iPrevButtons[client] = buttons;
  248.    
  249.     if(iInitialButtons != buttons)
  250.         return Plugin_Changed;
  251.    
  252.     return Plugin_Continue;
  253. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement