-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot_freeze.sma
139 lines (112 loc) · 2.12 KB
/
bot_freeze.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <amxmodx>
#include <engine>
#include <hamsandwich>
#define PLUGIN "Bot Freeze"
#define VERSION "1.2b"
#define AUTHOR "mlibre"
#if AMXX_VERSION_NUM > 182
#define client_disconnect client_disconnected
#else
#define MAX_PLAYERS 32
#endif
new const bot_cvar[][] =
{
0,
"bot_freeze",
"yb_freeze_bots"
}
enum _:x
{
type,
bool:spawn,
isBot[MAX_PLAYERS + 1],
count
}
new mp_bot_freezetime, bot_enum[x]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar(PLUGIN, VERSION, FCVAR_SERVER | FCVAR_SPONLY)
mp_bot_freezetime = register_cvar("mp_bot_freezetime", "10") //<-starts after mp_freezetime
register_logevent("logevent_round_start", 2, "1=Round_Start")
}
public plugin_cfg()
{
for(new i = 1; i < sizeof bot_cvar; i++)
{
if(cvar_exists(bot_cvar[i]))
{
bot_enum[type] = i
break
}
}
}
public client_putinserver(id)
{
if( !bot_enum[spawn] && is_user_bot(id) )
{
bot_enum[spawn] = true
set_task(0.1, "bot_RegisterHamFromEntity", id)
}
}
public bot_RegisterHamFromEntity(id)
{
RegisterHamFromEntity(Ham_Spawn, id, "bot_spawn", true)
}
public bot_spawn(id)
{
if( !bot_enum[isBot][id] && is_user_alive(id) )
{
bot_enum[isBot][id] = 1
bot_enum[count]++
}
}
public client_disconnect(id)
{
if(bot_enum[isBot][id])
{
bot_enum[isBot][id] = 0
bot_enum[count]--
}
}
public logevent_round_start()
{
if(bot_enum[count] < 1)
{
return
}
const idtask = 666
#if AMXX_VERSION_NUM > 182
remove_task(idtask)
#else
if(task_exists(idtask))
{
remove_task(idtask)
}
#endif
set_task(float(get_pcvar_num(mp_bot_freezetime)), "bot_task", idtask)
bot_action(1)
}
public bot_task()
{
bot_action(0)
}
stock bot_action(y)
{
switch(bot_enum[type])
{
case 1,2: set_cvar_num(bot_cvar[bot_enum[type]], y)
default:
{
new bots[MAX_PLAYERS], maxbots
get_players(bots, maxbots, "adh")
for(new i, id; i < maxbots; i++)
{
id = bots[i]
if(y)
entity_set_int(id, EV_INT_flags, entity_get_int(id, EV_INT_flags) | FL_FROZEN)
else
entity_set_int(id, EV_INT_flags, entity_get_int(id, EV_INT_flags) & ~FL_FROZEN)
}
}
}
}