Skip to content

Commit 2a293e3

Browse files
committed
informer: initial release
1 parent 3ce3ea0 commit 2a293e3

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

map_manager_informer.sma

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#include <amxmodx>
2+
#include <map_manager>
3+
#include <map_manager_scheduler>
4+
5+
#if AMXX_VERSION_NUM < 183
6+
#include <colorchat>
7+
#endif
8+
9+
#define PLUGIN "Map Manager: Informer"
10+
#define VERSION "0.0.1"
11+
#define AUTHOR "Mistrick"
12+
13+
#pragma semicolon 1
14+
15+
#define get_num(%0) get_pcvar_num(g_pCvars[%0])
16+
17+
enum Cvars {
18+
TIMELIMIT,
19+
WINLIMIT,
20+
MAXROUNDS,
21+
NEXTMAP,
22+
EXTENDED_TYPE
23+
};
24+
25+
new g_pCvars[Cvars];
26+
27+
new g_iTeamScore[2];
28+
new g_szCurMap[MAPNAME_LENGTH];
29+
new PREFIX[32];
30+
31+
public plugin_init()
32+
{
33+
register_plugin(PLUGIN, VERSION, AUTHOR);
34+
35+
register_clcmd("say timeleft", "clcmd_timeleft");
36+
register_clcmd("say thetime", "clcmd_thetime");
37+
register_clcmd("say nextmap", "clcmd_nextmap");
38+
register_clcmd("say currentmap", "clcmd_currentmap");
39+
40+
get_mapname(g_szCurMap, charsmax(g_szCurMap));
41+
mapm_get_prefix(PREFIX, charsmax(PREFIX));
42+
}
43+
public plugin_cfg()
44+
{
45+
g_pCvars[TIMELIMIT] = get_cvar_pointer("mp_timelimit");
46+
g_pCvars[WINLIMIT] = get_cvar_pointer("mp_winlimit");
47+
g_pCvars[MAXROUNDS] = get_cvar_pointer("mp_maxrounds");
48+
g_pCvars[NEXTMAP] = get_cvar_pointer("amx_nextmap");
49+
g_pCvars[EXTENDED_TYPE] = get_cvar_pointer("mapm_extended_type");
50+
}
51+
public event_teamscore()
52+
{
53+
new team[2]; read_data(1, team, charsmax(team));
54+
g_iTeamScore[(team[0] == 'C') ? 0 : 1] = read_data(2);
55+
}
56+
public clcmd_timeleft(id)
57+
{
58+
new win_limit = get_num(WINLIMIT);
59+
new max_rounds = get_num(MAXROUNDS);
60+
61+
if((win_limit || max_rounds) && get_num(EXTENDED_TYPE) == EXTEND_ROUNDS) {
62+
new text[128], len;
63+
len = formatex(text, charsmax(text), "%L ", LANG_PLAYER, "MAPM_TIME_TO_END");
64+
if(win_limit) {
65+
new left_wins = win_limit - max(g_iTeamScore[0], g_iTeamScore[1]);
66+
// TODO: add to ML MAPM_WINS
67+
len += formatex(text[len], charsmax(text) - len, "%d %L", left_wins, LANG_PLAYER, "MAPM_WINS");
68+
}
69+
if(win_limit && max_rounds) {
70+
len += formatex(text[len], charsmax(text) - len, " %L ", LANG_PLAYER, "MAPM_TIMELEFT_OR");
71+
}
72+
if(max_rounds) {
73+
new left_rounds = max_rounds - g_iTeamScore[0] - g_iTeamScore[1];
74+
// TODO: add to ML MAPM_ROUNDS
75+
len += formatex(text[len], charsmax(text) - len, "%d %L", left_rounds, LANG_PLAYER, "MAPM_ROUNDS");
76+
}
77+
client_print_color(0, print_team_default, "%s^1 %s.", PREFIX, text);
78+
} else {
79+
if (get_num(TIMELIMIT)) {
80+
new a = get_timeleft();
81+
client_print_color(0, id, "%s^1 %L:^3 %d:%02d", PREFIX, LANG_PLAYER, "MAPM_TIME_TO_END", (a / 60), (a % 60));
82+
} else {
83+
if(is_vote_will_in_next_round()) {
84+
// TODO: add ML
85+
client_print_color(0, print_team_default, "%s^1 Wait vote in next round.", PREFIX);
86+
} else {
87+
client_print_color(0, print_team_default, "%s^1 %L", PREFIX, LANG_PLAYER, "MAPM_NO_TIMELIMIT");
88+
}
89+
}
90+
}
91+
}
92+
public clcmd_thetime(id)
93+
{
94+
new curtime[64]; get_time("%Y/%m/%d - %H:%M:%S", curtime, charsmax(curtime));
95+
client_print_color(0, print_team_default, "%s^3 %L", PREFIX, LANG_PLAYER, "MAPM_THETIME", curtime);
96+
}
97+
public clcmd_nextmap(id)
98+
{
99+
if(is_vote_finished()) {
100+
new map[MAPNAME_LENGTH]; get_pcvar_string(g_pCvars[NEXTMAP], map, charsmax(map));
101+
client_print_color(0, id, "%s^1 %L ^3%s^1.", PREFIX, LANG_PLAYER, "MAPM_NEXTMAP", map);
102+
} else {
103+
client_print_color(0, id, "%s^1 %L ^3%L^1.", PREFIX, LANG_PLAYER, "MAPM_NEXTMAP", LANG_PLAYER, "MAPM_NOT_SELECTED");
104+
}
105+
}
106+
public clcmd_currentmap(id)
107+
{
108+
client_print_color(0, id, "%s^1 %L", PREFIX, LANG_PLAYER, "MAPM_CURRENT_MAP", g_szCurMap);
109+
}

0 commit comments

Comments
 (0)