From 9fb9855a2c12da5d49a91baa0c87043361a0a345 Mon Sep 17 00:00:00 2001 From: navewindre Date: Wed, 15 Nov 2023 03:16:22 +0100 Subject: better speed display --- sourcemod/scripting/sm_speedometer.sp | 80 ++++++++++++++++++----------------- 1 file 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) -- cgit v1.2.3