-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTF2Jail_Redux_HUD.sp
102 lines (84 loc) · 2.59 KB
/
TF2Jail_Redux_HUD.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "Battlefield Duck"
#define PLUGIN_VERSION "1.2"
#include <sourcemod>
#include <sdktools>
#include <tf2jailredux>
#undef REQUIRE_PLUGIN
#include <tf2jailredux>
#pragma newdecls required
//define
#define TEAM_RED 2
#define TEAM_BLU 3
public Plugin myinfo =
{
name = "[TF2] Jailbreak - HUD",
author = PLUGIN_AUTHOR,
description = "A Hintbox show Player status, Game status.",
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/showthread.php?t=300720"
};
//Handle cvar
Handle hConVars;
public void OnPluginStart()
{
CreateConVar("sm_tf2jail_HUD_version", PLUGIN_VERSION, "Version of [TF2] Jail - HUD", FCVAR_SPONLY|FCVAR_DONTRECORD|FCVAR_NOTIFY);
hConVars = CreateConVar("sm_tf2jail_HUDenable", "1", "Enable [TF2] Jail - HUD", _, true, 0.0, true, 1.0);
}
public void OnMapStart()
{
CreateTimer(1.0, Timer_ShowHintBox, _, TIMER_REPEAT);
}
public Action Timer_ShowHintBox(Handle hTimer)
{
if(GetConVarBool(hConVars) && !IsVoteInProgress())
{
for (int iClient = 1; iClient <= MaxClients; iClient++)
{
if(IsValidClient(iClient))
{
int iWarden = -1;
int iFreeday = 0;
int AliveRed = GetAlivePlayersCount(TEAM_RED);
int AliveBlu = GetAlivePlayersCount(TEAM_BLU);
int Red = GetTeamClientCount(TEAM_RED);
int Blu = GetTeamClientCount(TEAM_BLU);
for(int i = 1; i <= MaxClients; i++)
{
if(IsValidClient(i))
{
if(JBPlayer(i).bIsWarden) iWarden = i;
if(JBPlayer(i).bIsFreeday) iFreeday++;
}
}
if(iWarden != -1) PrintHintText(iClient, "Warden: %N \n Guard: %i/%i Prisoner: %i/%i \n Freeday: %i", iWarden, AliveBlu, Blu, AliveRed, Red, iFreeday);
else PrintHintText(iClient, "Warden: - \n Guard: %i/%i Prisoner: %i/%i \n Freeday: %i",AliveBlu, Blu, AliveRed, Red, iFreeday);
StopSound(iClient, SNDCHAN_STATIC, "UI/hint.wav");
}
}
}
}
/*******************
Vaild Client?
*******************/
stock bool IsValidClient(int client)
{
if(client <= -1 ) return false;
if(client <= 0 ) return false;
if(client > MaxClients) return false;
if(!IsClientConnected(client)) return false;
return IsClientInGame(client);
}
/**********************
GetAlivePlayersCount
***********************/
stock int GetAlivePlayersCount(int iTeam)
{
int i;
int iCount = 0;
for( i = 1; i <= MaxClients; i++ )
if( IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == iTeam)
iCount++;
return iCount;
}