Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
- {
- new iInitialButtons = buttons;
- if(!IsPlayerAlive(client))
- return Plugin_Continue;
- new mode = Timer_GetMode(client);
- new Float:fGameTime = GetGameTime();
- new bool:abuse = false;
- new bool:oldgroundstatus = g_bStayOnGround[client];
- new bool:onground = bool:(GetEntityFlags(client) & FL_ONGROUND);
- new Float:vecVelocity[3];
- GetEntDataVector(client, g_iOffs_Velocity, vecVelocity);
- new bool:GainHeight = false;
- if(g_fCord_Old[client][2] < g_fCord_New[client][2])
- {
- GainHeight = true;
- }
- decl Float:fVelocity[3];
- GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVelocity); //velocity
- new Float:currentspeed = SquareRoot(Pow(fVelocity[0],2.0)+Pow(fVelocity[1],2.0)); //player speed (units per secound)
- g_fSpeedTotal[client] += currentspeed;
- g_iCommandCount[client] ++;
- g_fSpeedCurrent[client] = currentspeed;
- if(currentspeed > g_fSpeedMax[client])
- {
- g_fSpeedMax[client] = currentspeed;
- }
- g_fCord_Old[client][0] = g_fCord_New[client][0];
- g_fCord_Old[client][1] = g_fCord_New[client][1];
- g_fCord_Old[client][2] = g_fCord_New[client][2];
- GetClientAbsOrigin(client, g_fCord_New[client]);
- if(g_fCord_Old[client][2] > g_fCord_New[client][2] && GainHeight)
- {
- //PrintToChat(client, "Jumped height max reached: %f units", g_fCord_Old[client][2]-g_fJumpLastCord[client][2]);
- //new ForwardMaxJumpHeight;
- }
- if(!onground && !Client_IsOnLadder(client))
- {
- if(g_Physics[mode][ModePreventLeft])
- {
- if(vel[1] < 0 || buttons & IN_MOVELEFT)
- {
- TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
- abuse = true;
- }
- }
- if(g_Physics[mode][ModePreventRight])
- {
- if(vel[1] > 0 || buttons & IN_MOVERIGHT)
- {
- TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
- abuse = true;
- }
- }
- if(g_Physics[mode][ModePreventMoveforward])
- {
- if(vel[0] > 0 || buttons & IN_FORWARD)
- {
- TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
- abuse = true;
- }
- }
- if(g_Physics[mode][ModePreventMoveback])
- {
- if(vel[0] < 0 || buttons & IN_BACK)
- {
- TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
- abuse = true;
- }
- }
- if(vecVelocity[2] <= 0)
- {
- if(g_Physics[mode][ModeBlockMovementDirection] != 0)
- {
- if(currentspeed > 200.00)
- {
- //backwards
- if(g_Physics[mode][ModeBlockMovementDirection] == 1)
- {
- new Float:direction = GetClientMovingDirection(client);
- if (direction > 0.45)
- {
- TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
- abuse = true;
- }
- }
- //forward
- else if(g_Physics[mode][ModeBlockMovementDirection] == 2)
- {
- if (GetClientMovingDirection(client) < -0.45)
- {
- TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0});
- abuse = true;
- }
- }
- }
- }
- }
- }
- if(buttons & IN_JUMP)
- {
- if(!Timer_IsPlayerTouchingZoneType(client, ZtNoBoost))
- {
- if(g_fBoost[client] > 0.0)
- {
- if(onground && !g_bPushWait[client])
- {
- //PrintToChat(client, "Create Timer");
- g_bPushWait[client] = true;
- //CreateTimer(0.0, Timer_Push, client, TIMER_FLAG_NO_MAPCHANGE);
- Push_Client(client);
- }
- }
- }
- if(!onground)
- {
- //Settings/Zone check
- if((g_bAuto[client] || Timer_IsPlayerTouchingZoneType(client, ZtAuto)) && !g_bAutoDisable[client] && !Timer_IsPlayerTouchingZoneType(client, ZtNoAuto))
- {
- //Ladder check
- if (!Client_IsOnLadder(client))
- {
- //Wather check
- if (GetEntProp(client, Prop_Data, "m_nWaterLevel") <= 1)
- {
- buttons &= ~IN_JUMP;
- }
- }
- }
- }
- }
- // Player didn't jump immediately after the last jump.
- if (!(buttons & IN_JUMP) && onground && fCheckTime[client] > 0.0)
- {
- fCheckTime[client] = 0.0;
- }
- new oldjumps = g_iFullJumpCount[client];
- new bool:perfect = false;
- // Ignore this jump if the player is in a tight space or stuck in the ground.
- if ((buttons & IN_JUMP) && !abuse)
- {
- if(!(iPrevButtons[client] & IN_JUMP))
- {
- // Player is on the ground and about to trigger a jump.
- if (onground)
- {
- // Player jumped on the exact frame that allowed it.
- if (fCheckTime[client] > 0.0 && fGameTime >= fCheckTime[client])
- {
- perfect = true;
- g_iFullJumpCount[client]++;
- g_fJumpAccuracy[client] = 100-((100/g_Settings[MultiBhopDelay])*g_fFullJumpTimeAmount[client])/g_iFullJumpCount[client];
- }
- else
- {
- fCheckTime[client] = fGameTime + g_Settings[MultiBhopJumpTime];
- }
- }
- else if(fCheckTime[client] != 0.0)
- {
- fCheckTime[client] = 0.0;
- }
- }
- }
- if(!abuse && !perfect)
- {
- //Save new on ground status
- if(onground)
- {
- if(!g_bStayOnGround[client] && g_fBoost[client] > 0.0)
- {
- //PrintToChat(client, "Ready to boost");
- g_bPushWait[client] = false;
- }
- g_bStayOnGround[client] = true;
- }
- else
- {
- g_bStayOnGround[client] = false;
- }
- //Player landed
- if(g_bStayOnGround[client] && g_bStayOnGround[client] != oldgroundstatus)
- {
- g_fLandedTime[client] = fGameTime;
- }
- //Player jumped
- if(!g_bStayOnGround[client] && g_bStayOnGround[client] != oldgroundstatus)
- {
- if(fGameTime-g_fLandedTime[client] < g_Settings[MultiBhopJumpTime])
- {
- g_iFullJumpCount[client]++;
- }
- else
- {
- g_bFirstJump[client] = true;
- //PrintToChat(client, "First Jump");
- }
- }
- //Player has jumped? How good was his jump?
- if(oldjumps < g_iFullJumpCount[client]) //don't count first jump
- {
- if(fGameTime-g_fLandedTime[client] > g_Settings[MultiBhopDelay])
- {
- g_fFullJumpTimeAmount[client] += g_Settings[MultiBhopDelay];
- }
- else if(fGameTime-g_fLandedTime[client] > 0.0)
- {
- g_fFullJumpTimeAmount[client] += fGameTime-g_fLandedTime[client];
- }
- //update jump accuracy
- g_fJumpAccuracy[client] = 100-((100/g_Settings[MultiBhopDelay])*g_fFullJumpTimeAmount[client])/g_iFullJumpCount[client];
- }
- }
- iPrevButtons[client] = buttons;
- if(iInitialButtons != buttons)
- return Plugin_Changed;
- return Plugin_Continue;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement