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 From 191d2772a056545b3aee70448385d703d57f07af Mon Sep 17 00:00:00 2001 From: navewindre Date: Wed, 15 Nov 2023 03:41:41 +0100 Subject: speedometer improvements --- sourcemod/scripting/sm_speedometer.sp | 56 +++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/sourcemod/scripting/sm_speedometer.sp b/sourcemod/scripting/sm_speedometer.sp index d0269f1..625395b 100644 --- a/sourcemod/scripting/sm_speedometer.sp +++ b/sourcemod/scripting/sm_speedometer.sp @@ -72,6 +72,8 @@ public OnPluginStart() HookEvent("player_death", Event_OnPlayerDeath); HookEvent("round_start", Event_OnRoundStart); HookEvent("round_end", Event_OnRoundEnd); + HookEvent("bomb_planted", Event_OnBombPlanted); + HookEvent("bomb_defused", Event_OnBombDefused); g_hCookie = RegClientCookie("Cookie_Speedometer", "The client's setting for speedometer.", CookieAccess_Protected); SetCookieMenuItem(Menu_Status, 0, "Speedometer"); @@ -199,23 +201,52 @@ public Action:Event_OnRoundStart(Handle:event, const String:name[], bool:dontBro return Plugin_Continue; } +public Action:Event_OnBombPlanted(Handle:event, const String:name[], bool:dontBroadcast) { + for(new i = 1; i <= MaxClients; i++) + { + if( g_bShowDisplay[i] && g_iDisplayMethod == 1 && IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i) ) { + PrintHintText( i, "Bomb has been planted" ); + } + } +} + +public Action:Event_OnBombDefused(Handle:event, const String:name[], bool:dontBroadcast) { + for(new i = 1; i <= MaxClients; i++) + { + if( g_bShowDisplay[i] && g_iDisplayMethod == 1 && IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i) ) { + PrintHintText( i, "Bomb has been defused" ); + } + } +} + public Action:Event_OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) { if(g_bEnabled) { g_bEnding = true; + new reason = GetEventInt(event, "reason"); + new winner = GetEventInt(event, "winner"); - if(g_bUseTimer) - { - for(new i = 1; i <= MaxClients; i++) - { - if(IsClientInGame(i)) - { - if(g_hTimer_Display[i] != INVALID_HANDLE && CloseHandle(g_hTimer_Display[i])) - g_hTimer_Display[i] = INVALID_HANDLE; - } - } - } + for(new i = 1; i <= MaxClients; i++) + { + if(IsClientInGame(i)) + { + if(g_bUseTimer) + { + if(g_hTimer_Display[i] != INVALID_HANDLE && CloseHandle(g_hTimer_Display[i])) + g_hTimer_Display[i] = INVALID_HANDLE; + } + + if( g_bShowDisplay[i] && g_iDisplayMethod == 1 && IsPlayerAlive(i) && !IsFakeClient(i) ) { + if( winner == 1 ) + PrintHintText( i, "Round Draw" ); + else if( winner == 2 ) + PrintHintText( i, "Terrorists Win" ); + else if( winner == 3 ) + PrintHintText( i, "Counter-Terrorists Win" ); + } + } + } if(g_bShowFastest) { @@ -228,7 +259,6 @@ public Action:Event_OnRoundEnd(Handle:event, const String:name[], bool:dontBroad PrintToChatAll("%t%t", "Prefix_Chat", "Phrase_Highest_Velocity", sName, g_fFastestVelocity); } } - return Plugin_Continue; } @@ -526,7 +556,7 @@ public Action_OnSettingsChange(Handle:cvar, const String:oldvalue[], const Strin if(g_hTimer_Display[i] != INVALID_HANDLE && CloseHandle(g_hTimer_Display[i])) g_hTimer_Display[i] = INVALID_HANDLE; - g_bAlive[i] = IsPlayerAlive(i) ? true : false; + g_bAlive[i] = (IsClientInGame(i) && IsPlayerAlive(i)) ? true : false; if(!g_bEnding && g_bUseTimer && IsClientInGame(i)) { if(g_fTimerRate && !IsFakeClient(i)) -- cgit v1.2.3