-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathberobot_hud.sp
103 lines (87 loc) · 2.06 KB
/
berobot_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
103
#include <tf2>
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <sm_logger>
#include <morecolors>
#include <team_round_timer>
#include <berobot_constants>
#include <berobot_core_restrictions>
#include <berobot>
char LOG_TAGS[][] = {"VERBOSE", "INFO", "ERROR"};
enum(<<= 1)
{
SML_VERBOSE = 1,
SML_INFO,
SML_ERROR,
}
#include <berobot_core>
#pragma newdecls required
#pragma semicolon 1
public Plugin myinfo =
{
name = "berobot_hud",
author = "icebear",
description = "",
version = "0.1",
url = "https://github.com/higps/robogithub"
};
Handle _hudSynchronizer;
Handle _timer;
public void OnPluginStart()
{
SMLoggerInit(LOG_TAGS, sizeof(LOG_TAGS), SML_ERROR, SML_FILE);
SMLogTag(SML_INFO, "berobot_hud started at %i", GetTime());
_hudSynchronizer = CreateHudSynchronizer();
if (IsEnabled())
Start();
}
public void MM_OnEnabledChanged(int enabled)
{
SMLogTag(SML_VERBOSE, "MM_OnEnabledChanged called at %i with value %i", GetTime(), enabled);
if (enabled == 0)
{
Stop();
return;
}
Start();
}
void Start()
{
if (_timer != null)
{
KillTimer(_timer);
}
_timer = CreateTimer(1.0, DrawHud, _, TIMER_REPEAT);
}
void Stop()
{
if (_timer != null)
{
KillTimer(_timer);
_timer = null;
}
}
Action DrawHud(Handle timer)
{
DrawTeamHud(TFTeam_Red, 255, 64, 64, 255);
DrawTeamHud(TFTeam_Blue, 153, 204, 255, 255);
return Plugin_Continue;
}
void DrawTeamHud(TFTeam team, int r, int g, int b, int a)
{
SetHudTextParams(-1.0, 0.05, 4.0, r, g, b, a, 0, 0.0, 0.0, 0.0);
for(int i = 1; i <= MaxClients; i++)
{
if (!IsValidClient(i))
continue;
if (!IsAnyRobot(i))
continue;
TFTeam actualTeam = view_as<TFTeam>(GetClientTeam(i));
if (actualTeam != team)
continue;
int robotCoins = GetRobotCoinsFor(i);
int bossTokens = GetTeamCoinsFor(i);
ShowSyncHudText(i, _hudSynchronizer, "Robot-₡oins: %i\nBoss-₡oins: %i/1", robotCoins, bossTokens);
}
}