This repository has been archived by the owner on May 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
bTimes-extras.sp
383 lines (307 loc) · 10.6 KB
/
bTimes-extras.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <bTimes-core>
#include <bTimes-timer>
#include <smlib/entities>
#include "bTimes/extras.sp" // Weapons
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo = {
name = "[bTimes] Extras",
description = "Essential extras produced by cam for use on 2001",
author = "cam",
version = VERSION,
url = URL
}
int g_iLastRadio[MAXPLAYERS+1];
int g_iSelectedTeam[MAXPLAYERS+1] = {-1, ...};
int m_hActive;
int m_iClip1;
int m_iClip2;
int m_iAmmo1;
int m_iAmmo2;
int m_iFlashAlpha;
char g_msg_pre[128] = {""};
char g_msg_var[128] = {""};
char g_msg_msg[128] = {""};
char RadioCommands[][] = {
"coverme", "takepoint", "hodlpos", "regroup", "followme",
"takingfire", "go", "fallback", "sticktog", "getinpos",
"stormfront", "report", "roger", "enemyspot", "needbackup",
"sectorclear", "inposition", "reportingin", "getout", "negative",
"enemydown"
};
public void OnPluginStart()
{
if(GetGameType() != GameType_CSGO && GetGameType() != GameType_CSS)
SetFailState("This timer does not support this game (%d)", GetGameType());
HookEvent("player_team", HookPlayerTeamChange, EventHookMode_Pre);
HookEvent("server_cvar", HookServerVariables, EventHookMode_Pre);
HookEvent("player_blind", HookPlayerFlash, EventHookMode_Pre);
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
RegConsoleCmd("say", HookUserChatMessage);
RegConsoleCmd("say_team", HookUserChatMessage);
RegConsoleCmd("sm_m4a1", GiveWeapon_M4 );
RegConsoleCmd("sm_m4", GiveWeapon_M4 );
RegConsoleCmd("sm_ak47", GiveWeapon_AK );
RegConsoleCmd("sm_ak", GiveWeapon_AK );
RegConsoleCmd("sm_scout", GiveWeapon_Scout);
RegConsoleCmd("sm_p90", GiveWeapon_P90 );
RegConsoleCmd("sm_usp", GiveWeapon_USP );
RegConsoleCmd("sm_glock", GiveWeapon_G18 );
RegConsoleCmd("sm_awp", GiveWeapon_AWP );
/* Game specific shit */
if(GetGameType() == GameType_CSS){
RegConsoleCmd("sm_knife", GiveWeapon_Knife);
RegConsoleCmd("sm_m3", GiveWeapon_M3 );
m_hActive = FindSendPropOffs("CAI_BaseNPC", "m_hActiveWeapon");
m_iClip1 = FindSendPropOffs("CBaseCombatWeapon", "m_iClip1");
m_iClip2 = FindSendPropOffs("CBaseCombatWeapon", "m_iClip2");
m_iAmmo1 = FindSendPropOffs("CBaseCombatWeapon", "m_iPrimaryAmmoCount");
m_iAmmo2 = FindSendPropOffs("CBaseCombatWeapon", "m_iSecondaryAmmoCount");
m_iFlashAlpha = FindSendPropOffs("CCSPlayer", "m_flFlashMaxAlpha");
} else if(GetGameType() == GameType_CSGO){
HookEvent("round_poststart", Event_RoundPostStart);
}
for(int command = 0; command < sizeof(RadioCommands); command++)
RegConsoleCmd(RadioCommands[command], Command_RadioOverride);
AddCommandListener(Command_JoinTeamOverride, "jointeam");
AddCommandListener(Command_JoinTeamOverride, "spectate");
HookEventEx("player_connect_full", Event_OnFullConnect);
}
public void OnMapStart()
{
if(GetGameType() == GameType_CSS){
CreateTimer(1.0, HookAmmunitionChange, _, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
}
else if(GetGameType() == GameType_CSGO)
{
HookEvent("jointeam_failed", Event_JoinTeamFailed, EventHookMode_Pre);
}
// Enforce settings
CreateTimer(5.0, Timer_CheckConvars, _, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
}
/** HOOK FULL CONNECT AND ASSIGN TO SPECTATOR TEAM **/
public Action Event_OnFullConnect(Handle event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if(!client || client == 0 || !IsClientInGame(client))
return Plugin_Continue;
if(g_iSelectedTeam[client] != -1)
{
ForcePlayerSuicide(client);
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
}
return Plugin_Continue;
}
public Action Event_RoundPostStart(Handle event, const char[] name, bool PreventBroadcast)
{
ServerCommand("mp_warmup_end");
return Plugin_Continue;
}
public void OnClientPutInServer(int client)
{
g_iSelectedTeam[client] = -1;
g_iLastRadio[client] = -1;
}
/** HOOK SERVER VARIABLE CHANGES & PREVENT DISPLAY **/
public Action HookServerVariables(Handle event, const char[] name, bool dontBroadcast){
SetEventBroadcast(event, true);
char cvar_string[64];
GetEventString(event, "cvarname", cvar_string, sizeof(cvar_string));
if(StrEqual(cvar_string, "sv_allow_votes", false))
SetEventInt(event, "cvarvalue", 0);
if(StrEqual(cvar_string, "sv_airaccelerate", false))
SetEventInt(event, "cvarvalue", 1000);
if(StrEqual(cvar_string, "sv_enablebunnyhopping", false))
SetEventInt(event, "cvarvalue", 1);
if(StrEqual(cvar_string, "sv_alltalk", false))
SetEventInt(event, "cvarvalue", 1);
if(StrEqual(cvar_string, "sv_accelerate", false))
SetEventInt(event, "cvarvalue", 5);
if(StrEqual(cvar_string, "sv_friction", false))
SetEventInt(event, "cvarvalue", 4);
if(StrEqual(cvar_string, "sv_maxvelocity", false))
SetEventInt(event, "cvarvalue", 9999999);
if(StrEqual(cvar_string, "sv_full_alltalk", false))
SetEventInt(event, "cvarvalue", 1);
if(StrEqual(cvar_string, "sv_deadtalk", false))
SetEventInt(event, "cvarvalue", 2);
if(StrEqual(cvar_string, "sv_staminamax", false))
SetEventInt(event, "cvarvalue", 0);
if(StrEqual(cvar_string, "sv_staminalandcost", false))
SetEventInt(event, "cvarvalue", 0);
if(StrEqual(cvar_string, "mp_match_end_restart", false))
SetEventInt(event, "cvarvalue", 0);
return Plugin_Continue;
}
public Action Timer_CheckConvars(Handle timer)
{
ForceConVar("sv_alltalk", "1");
ForceConVar("sv_enablebunnyhopping", "1");
ForceConVar("sv_airaccelerate", "1000");
ForceConVar("sv_accelerate", "5");
ForceConVar("sv_friction", "4");
ForceConVar("sv_maxvelocity", "9999999");
if(GetGameType() == GameType_CSGO)
{
ForceConVar("sv_full_alltalk", "1");
ForceConVar("sv_deadtalk", "2");
ForceConVar("sv_staminamax", "0");
ForceConVar("sv_staminalandcost", "0");
ForceConVar("sv_staminajumpcost", "0");
ForceConVar("sv_allow_votes", "0");
ForceConVar("mp_match_end_restart", "0");
}
}
public void OnTimerChatChanged(int MessageType, char[] Message)
{
if(MessageType == 0)
{
Format(g_msg_pre, sizeof(g_msg_pre), Message);
ReplaceMessage(g_msg_pre, sizeof(g_msg_pre));
}
else if(MessageType == 1)
{
Format(g_msg_var, sizeof(g_msg_var), Message);
ReplaceMessage(g_msg_var, sizeof(g_msg_var));
}
else if(MessageType == 2)
{
Format(g_msg_msg, sizeof(g_msg_msg), Message);
ReplaceMessage(g_msg_msg, sizeof(g_msg_msg));
}
}
/** PREVENT AMMO LOSS / RELOADING **/
public Action HookAmmunitionChange(Handle timer){
if(GetGameType() == GameType_CSS){
for (int client = 1; client <= MaxClients; client++){
if(IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client)){
int clientWeapon = -1;
if(m_hActive != -1){
clientWeapon = GetEntDataEnt2(client, m_hActive);
if(clientWeapon != -1){
if(m_iClip1 != -1)
SetEntData(clientWeapon, m_iClip1, 99, 4, true);
if(m_iClip2 != -1)
SetEntData(clientWeapon, m_iClip2, 99, 4, true);
if(m_iAmmo1 != -1)
SetEntData(clientWeapon, m_iAmmo1, 99, 4, true);
if(m_iAmmo2 != -1)
SetEntData(clientWeapon, m_iAmmo2, 99, 4, true);
}
}
}
}
}
}
/** PREVENT TEAM CHANGE DISPLAY **/
public Action HookPlayerTeamChange(Handle event, const char[] name, bool dontBroadcast){
SetEventBroadcast(event, true);
return Plugin_Continue;
}
/** PREVENT MAPS FROM USING SAY **/
public Action HookUserChatMessage(int client, int args){
if(client == 0) return Plugin_Handled;
return Plugin_Continue;
}
/** PREVENT RADIO FROM BEING SPAMMED **/
public Action Command_RadioOverride(int client, int args){
int CurrentTime = GetTime();
if(g_iLastRadio[client] == -1){
g_iLastRadio[client] = CurrentTime;
return Plugin_Continue;
}
int TimeElapsed = CurrentTime - g_iLastRadio[client];
if(TimeElapsed >= 5){
g_iLastRadio[client] = CurrentTime;
return Plugin_Continue;
} else
PrintColorText(client, "%s%s You must wait %s%i %sseconds to use a radio command again.",
g_msg_pre,
g_msg_msg,
g_msg_var,
(5 - TimeElapsed),
g_msg_msg);
return Plugin_Handled;
}
/** ANTI FLASH **/
public Action HookPlayerFlash(Handle event, const char[] name, bool dontBroadcast){
int client = GetClientOfUserId(GetEventInt(event,"userid"));
if((IsClientInGame(client)) && (IsPlayerAlive(client)))
SetEntDataFloat(client, m_iFlashAlpha, 0.0);
return Plugin_Handled;
}
/** FORCE TEAM CHANGES TO PROPER TEAM **/
public Action Command_JoinTeamOverride(int client, const char[] command, int argc){
if(StrEqual(command, "jointeam")){
// Handle team joining - This way the teams can't ever be 'full'
char sArg[192];
GetCmdArgString(sArg, sizeof(sArg));
int team = StringToInt(sArg);
if(GetGameType() == GameType_CSGO){
if(team == CS_TEAM_T || team == CS_TEAM_CT || team == CS_TEAM_NONE)
team = CS_TEAM_CT;
}else if(GetGameType() == GameType_CSS){
if(team == CS_TEAM_T || team == CS_TEAM_CT || team == CS_TEAM_NONE)
team = CS_TEAM_T;
}
g_iSelectedTeam[client] = team;
if(team == CS_TEAM_T || team == CS_TEAM_CT || team == CS_TEAM_NONE){
CS_SwitchTeam(client, team);
CS_RespawnPlayer(client);
}else if(team == CS_TEAM_SPECTATOR){
ForcePlayerSuicide(client);
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
}
}else{
// Command was 'spectate' - Send the player to spectate
ForcePlayerSuicide(client);
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
}
return Plugin_Handled;
}
public Action Event_JoinTeamFailed(Handle event, const char[] name, bool dontBroadcast){
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if(!client || !IsClientInGame(client))
return Plugin_Continue;
int team = g_iSelectedTeam[client];
if(team != -1)
{
if(team == CS_TEAM_T || team == CS_TEAM_CT || team == CS_TEAM_NONE)
CS_SwitchTeam(client, team);
else
ChangeClientTeam(client, team);
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action Event_PlayerSpawn(Handle event, const char[] name, bool PreventBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
CreateTimer(0.5, Timer_PlayerSpawn, client);
}
public Action Timer_PlayerSpawn(Handle timer, any client)
{
if(0 < client <= MaxClients){
if(IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client))
SetEntProp( client, Prop_Data, "m_nHitboxSet", 2 );
}
}
//public Action CS_OnGetWeaponPrice(int client, const char[] weapon, int &price)
//{
// price = 0;
// return Plugin_Handled;
//}
//public Action CS_OnBuyCommand(int client, const char[] weapon)
//{
// char WeaponClass[128];
// CS_GetTranslatedWeaponAlias(weapon, WeaponClass, sizeof(WeaponClass));
//
// if(!StrEqual(WeaponClass, weapon, false))
// GivePlayerItem(client, WeaponClass);
//
// return Plugin_Handled;
//}