diff options
| author | navewindre <nw@moneybot.cc> | 2023-11-15 03:16:22 +0100 |
|---|---|---|
| committer | navewindre <nw@moneybot.cc> | 2023-11-15 03:16:22 +0100 |
| commit | 9fb9855a2c12da5d49a91baa0c87043361a0a345 (patch) | |
| tree | 3d530919346937b9a6ae43f51560228626f1aff1 | |
| parent | d4d5482b5f66209d17b9d786ffe0a13cf352fb15 (diff) | |
better speed display
| -rw-r--r-- | sourcemod/scripting/sm_speedometer.sp | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/sourcemod/scripting/sm_speedometer.sp b/sourcemod/scripting/sm_speedometer.sp index f0d8ebd..d0269f1 100644 --- a/sourcemod/scripting/sm_speedometer.sp +++ b/sourcemod/scripting/sm_speedometer.sp @@ -274,6 +274,47 @@ public Action:Command_Meter(client, args) return Plugin_Handled; } +public Action:OnPlayerRunCmd(iClient, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon) { + if(g_bUseOnFrame) + { + decl String:sBuffer[128]; + decl Float:_fTemp[3], Float:_fVelocity; + new i = iClient; + if(g_bAlive[i] && g_iTeam[i] >= 2 && g_bShowDisplay[i]) + { + GetEntPropVector(i, Prop_Data, "m_vecVelocity", _fTemp); + for(new j = 0; j <= 1; j++) + _fTemp[j] *= _fTemp[j]; + + _fVelocity = SquareRoot(_fTemp[0] + _fTemp[1]); + if(g_fVelocityFactor) + _fVelocity /= g_fVelocityFactor; + + switch(g_iDisplayMethod) + { + case 0: + PrintHintText(i, "%t", "Phrase_Velocity_Display", _fVelocity); + case 1: + PrintCenterText(i, "%t", "Phrase_Velocity_Display", _fVelocity); + case 2: + { + Format(sBuffer, sizeof(sBuffer), "%T", "Phrase_Velocity_Display", i, _fVelocity); + new Handle:hTemp = StartMessageOne("KeyHintText", i); + BfWriteByte(hTemp, 1); + BfWriteString(hTemp, sBuffer); + EndMessage(); + } + } + + if(g_bShowFastest && _fVelocity > g_fFastestVelocity) + { + g_fFastestVelocity = _fVelocity; + g_iFastestClient = i; + } + } + } +} + public Action:Timer_Display(Handle:timer, any:client) { if(!g_bAlive[client] || g_iTeam[client] <= 1 || !g_bShowDisplay[client]) @@ -319,46 +360,7 @@ public Action:Timer_Display(Handle:timer, any:client) public OnGameFrame() { - if(g_bUseOnFrame) - { - decl String:sBuffer[128]; - decl Float:_fTemp[3], Float:_fVelocity; - for(new i = 1; i <= MaxClients; i++) - { - if(g_bAlive[i] && g_iTeam[i] >= 2 && g_bShowDisplay[i]) - { - GetEntPropVector(i, Prop_Data, "m_vecVelocity", _fTemp); - for(new j = 0; j <= 1; j++) - _fTemp[j] *= _fTemp[j]; - - _fVelocity = SquareRoot(_fTemp[0] + _fTemp[1]); - if(g_fVelocityFactor) - _fVelocity /= g_fVelocityFactor; - switch(g_iDisplayMethod) - { - case 0: - PrintHintText(i, "%t", "Phrase_Velocity_Display", _fVelocity); - case 1: - PrintCenterText(i, "%t", "Phrase_Velocity_Display", _fVelocity); - case 2: - { - Format(sBuffer, sizeof(sBuffer), "%T", "Phrase_Velocity_Display", i, _fVelocity); - new Handle:hTemp = StartMessageOne("KeyHintText", i); - BfWriteByte(hTemp, 1); - BfWriteString(hTemp, sBuffer); - EndMessage(); - } - } - - if(g_bShowFastest && _fVelocity > g_fFastestVelocity) - { - g_fFastestVelocity = _fVelocity; - g_iFastestClient = i; - } - } - } - } } public OnClientCookiesCached(client) |
