-
Notifications
You must be signed in to change notification settings - Fork 1
/
hns_night_mode.sma
55 lines (44 loc) · 1.29 KB
/
hns_night_mode.sma
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
#include <amxmodx>
#include <hns_mode_main>
new g_szPrefix[24];
enum HNS_CVAR {
c_iStartNight,
c_iEndNight
};
new g_pCvar[HNS_CVAR];
new bool:g_bNight;
public plugin_init()
{
register_plugin("HNS: Night deathmatch", "1.0", "OpenHNS");
bind_pcvar_num(register_cvar("hns_start_night", "23"), g_pCvar[c_iStartNight]);
bind_pcvar_num(register_cvar("hns_end_night", "9"), g_pCvar[c_iEndNight]);
}
public plugin_cfg() {
if (isNight()) {
set_cvar_num("hns_deathmatch", 1);
g_bNight = true;
} else {
set_cvar_num("hns_deathmatch", 0);
g_bNight = false;
}
hns_get_prefix(g_szPrefix, charsmax(g_szPrefix));
}
public hns_round_start() {
if (isNight() && !g_bNight) {
hns_set_mode(MODE_DEATHMATCH);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "NIGHT_START", g_szPrefix);
g_bNight = true;
} else if (!isNight() && g_bNight) {
hns_set_mode(MODE_PUBLIC);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "NIGHT_STOP", g_szPrefix);
g_bNight = false;
}
}
public bool:isNight() {
static iNumChas; time(iNumChas);
if (g_pCvar[c_iStartNight] > g_pCvar[c_iEndNight]) {
return (iNumChas >= g_pCvar[c_iStartNight] || iNumChas < g_pCvar[c_iEndNight]) ? true : false;
} else {
return (g_pCvar[c_iStartNight] <= iNumChas < g_pCvar[c_iEndNight]) ? true : false;
}
}