summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/sm_speedometer.sp
diff options
context:
space:
mode:
authorCristei Gabriel <cristei.g772@gmail.com>2023-11-15 05:17:35 +0200
committerCristei Gabriel <cristei.g772@gmail.com>2023-11-15 05:17:35 +0200
commite8bde25d567cdd4ecd1988dc186b6725d820bb42 (patch)
tree7e2c09e4f7ef77d7d028697660b83fc5b3a84dfe /sourcemod/scripting/sm_speedometer.sp
parent159db05faf44daf8a8ed326e4fbfd1e98b839a2f (diff)
parent191d2772a056545b3aee70448385d703d57f07af (diff)
Merge branch 'main' of https://github.com/navewindre/networkheaven
Diffstat (limited to 'sourcemod/scripting/sm_speedometer.sp')
-rw-r--r--sourcemod/scripting/sm_speedometer.sp138
1 files changed, 85 insertions, 53 deletions
diff --git a/sourcemod/scripting/sm_speedometer.sp b/sourcemod/scripting/sm_speedometer.sp
index f0d8ebd..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;
-
- 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;
- }
- }
- }
+ new reason = GetEventInt(event, "reason");
+ new winner = GetEventInt(event, "winner");
+
+ 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;
}
@@ -274,6 +304,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 +390,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)
@@ -524,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))