-
Notifications
You must be signed in to change notification settings - Fork 0
/
MetalAllocator.sp
777 lines (707 loc) · 25.1 KB
/
MetalAllocator.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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
#include <sourcemod>
#include <cstrike>
#include <clientprefs>
#include "include/retakes.inc"
#include "retakes/generic.sp"
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1.0.0"
#define MENU_TIME_LENGTH 15
#define WEAPON_MODE_ALL 0 /**< All weapons allowed. */
#define WEAPON_MODE_PISTOLS 1 /**< Pistons only. */
#define WEAPON_MODE_RIFLES 2 /**< Rifles only. */ // TODO : Implement rifles only
#define WEAPON_MODE_RIFLES_NO_AWP 3 /**< Rifles, but no awps. */ // TODO : Implement rifles only with no awps
char g_CTRifleChoice[MAXPLAYERS+1][WEAPON_STRING_LENGTH];
char g_CTPistolChoice[MAXPLAYERS+1][WEAPON_STRING_LENGTH];
char g_CTPistolOnlyChoice[MAXPLAYERS+1][WEAPON_STRING_LENGTH];
char g_TRifleChoice[MAXPLAYERS+1][WEAPON_STRING_LENGTH];
char g_TPistolChoice[MAXPLAYERS+1][WEAPON_STRING_LENGTH];
char g_TPistolOnlyChoice[MAXPLAYERS+1][WEAPON_STRING_LENGTH];
bool g_CTAwpChoice[MAXPLAYERS+1];
bool g_TAwpChoice[MAXPLAYERS+1];
Handle g_hCTRifleChoiceCookie;
Handle g_hTRifleChoiceCookie;
Handle g_hCTPistolChoiceCookie;
Handle g_hTPistolChoiceCookie;
Handle g_hCTPistolOnlyChoiceCookie;
Handle g_hTPistolOnlyChoiceCookie;
Handle g_hCTAwpChoiceCookie;
Handle g_hTAwpChoiceCookie;
int RoundCount = 0;
int EnemyWeaponWeight = 10;
int WeaponMode = WEAPON_MODE_ALL;
ConVar g_cvMAEnemyWeaponWeight;
ConVar g_cvMAWeaponMode;
public Plugin myinfo = {
name = "CS:GO Retakes: metal weapon allocator",
author = "Metal Injection",
description = "Defines a weapon allocation policy and lets players set weapon preferences",
version = PLUGIN_VERSION,
url = "https://github.com/splewis/csgo-retakes"
};
public void OnPluginStart() {
g_hCTRifleChoiceCookie = RegClientCookie("retakes_ctriflechoice", "CT Rifle Choice", CookieAccess_Private);
g_hTRifleChoiceCookie = RegClientCookie("retakes_triflechoice", "T Rifle Choice", CookieAccess_Private);
g_hCTPistolChoiceCookie = RegClientCookie("retakes_ctpistolchoice", "CT Pistol Choice", CookieAccess_Private);
g_hTPistolChoiceCookie = RegClientCookie("retakes_tpistolchoice", "T Pistol Choice", CookieAccess_Private);
g_hCTPistolOnlyChoiceCookie = RegClientCookie("retakes_ctpistolonlychoice", "CT Pistol Only Choice", CookieAccess_Private);
g_hTPistolOnlyChoiceCookie = RegClientCookie("retakes_tpistolonlychoice", "T Pistol Only Choice", CookieAccess_Private);
g_hCTAwpChoiceCookie = RegClientCookie("retakes_ctawpchoice", "", CookieAccess_Private);
g_hTAwpChoiceCookie = RegClientCookie("retakes_tawpchoice", "", CookieAccess_Private);
g_cvMAEnemyWeaponWeight = CreateConVar("ma_enemyweaponweight", "10", "Sets the weight of the chance to receive an enemy team weapon", FCVAR_NOTIFY|FCVAR_SPONLY|FCVAR_ARCHIVE|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_SPONLY);
g_cvMAWeaponMode = CreateConVar("ma_weaponmode", "0", "Sets the mode of the server", FCVAR_NOTIFY|FCVAR_SPONLY|FCVAR_ARCHIVE|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_SPONLY);
g_cvMAEnemyWeaponWeight.AddChangeHook(EnemyWeaponWeightChange);
g_cvMAWeaponMode.AddChangeHook(WeaponModeChange);
EnemyWeaponWeight = GetConVarInt(g_cvMAEnemyWeaponWeight);
WeaponMode = GetConVarInt(g_cvMAWeaponMode);
}
public int EnemyWeaponWeightChange(Handle cvar, const char[] oldValue, const char[] newValue)
{
EnemyWeaponWeight = StringToInt(newValue);
}
public int WeaponModeChange(Handle cvar, const char[] oldValue, const char[] newValue)
{
WeaponMode = StringToInt(newValue);
}
public void OnMapStart()
{
RoundCount = 0;
}
public void Retakes_OnGunsCommand(int client) {
ShowWeaponsMenu(client);
}
public void Retakes_OnWeaponsAllocated(ArrayList tPlayers, ArrayList ctPlayers, Bombsite bombsite) {
WeaponAllocator(tPlayers, ctPlayers, bombsite);
RoundCount++;
}
/**
* Updates client weapon settings according to their cookies.
*/
public void OnClientCookiesCached(int client) {
if (IsFakeClient(client))
return;
char ctrifle[WEAPON_STRING_LENGTH];
char ctpistol[WEAPON_STRING_LENGTH];
char ctpistolonly[WEAPON_STRING_LENGTH];
char trifle[WEAPON_STRING_LENGTH];
char tpistol[WEAPON_STRING_LENGTH];
char tpistolonly[WEAPON_STRING_LENGTH];
GetClientCookie(client, g_hCTRifleChoiceCookie, ctrifle, sizeof(ctrifle));
GetClientCookie(client, g_hCTPistolChoiceCookie, ctpistol, sizeof(ctpistol));
GetClientCookie(client, g_hCTPistolOnlyChoiceCookie, ctpistolonly, sizeof(ctpistolonly));
GetClientCookie(client, g_hTRifleChoiceCookie, trifle, sizeof(trifle));
GetClientCookie(client, g_hTPistolChoiceCookie, tpistol, sizeof(tpistol));
GetClientCookie(client, g_hTPistolOnlyChoiceCookie, tpistolonly, sizeof(tpistolonly));
bool ctAwpchoice = GetCookieBool(client, g_hCTAwpChoiceCookie);
bool tAwpchoice = GetCookieBool(client, g_hTAwpChoiceCookie);
g_CTRifleChoice[client] = IsValidWeapon(ctrifle) ? ctrifle : "m4a1";
g_CTPistolChoice[client] = IsValidWeapon(ctpistol) ? ctpistol : "usp_silencer";
g_CTPistolOnlyChoice[client] = IsValidWeapon(ctpistolonly) ? ctpistolonly : g_CTPistolChoice[client];
g_TRifleChoice[client] = IsValidWeapon(trifle) ? trifle : "ak47";
g_TPistolChoice[client] = IsValidWeapon(tpistol) ? tpistol : "glock";
g_TPistolOnlyChoice[client] = IsValidWeapon(tpistolonly) ? tpistolonly : g_TPistolChoice[client];
g_CTAwpChoice[client] = ctAwpchoice;
g_TAwpChoice[client] = tAwpchoice;
}
static bool IsValidWeapon(char weapon[WEAPON_STRING_LENGTH])
{
char weaponDisplay[255];
AppendWeaponDisplay(weaponDisplay, sizeof(weaponDisplay), weapon);
return !StrEqual(weaponDisplay, "");
}
static bool SetNadesGetKit(char nades[NADE_STRING_LENGTH], int team, bool isPistolRound, bool ctHasKit) {
bool hasKit = false;
int rand = GetRandomInt(0, 7);
switch(rand) {
case 0: {
nades = "";
hasKit = true;
}
case 1: {
nades = "s";
hasKit = true;
}
case 2: {
nades = "f";
hasKit = true;
}
case 3: {
nades = "h";
hasKit = true;
}
case 4: {
nades = (team == CS_TEAM_T) ? "m" : "i";
}
// Combo nades
case 5: {
nades = "sf";
}
case 6: {
nades = "sh";
}
case 7: {
nades = (team == CS_TEAM_T) ? "mf" : "if";
}
}
hasKit = hasKit || !isPistolRound;
return !ctHasKit && hasKit;
}
static bool GiveEnemyTeamWeapon()
{
return GetRandomInt(0, 100) < EnemyWeaponWeight;
}
public void WeaponAllocator(ArrayList tPlayers, ArrayList ctPlayers, Bombsite bombsite) {
int tCount = tPlayers.Length;
int ctCount = ctPlayers.Length;
bool isPistolRound = RoundCount < 5;
char weaponConstText[7] = "weapon_";
char primary[WEAPON_STRING_LENGTH];
char secondary[WEAPON_STRING_LENGTH];
strcopy(primary, sizeof(primary), weaponConstText);
strcopy(secondary, sizeof(secondary), weaponConstText);
char nades[NADE_STRING_LENGTH];
int health = 100;
int kevlar = 100;
bool helmet = !isPistolRound;
bool giveTAwp = true;
bool giveCTAwp = true;
int teammatesWithNades = 0;
// T setup
for (int i = 0; i < tCount; i++) {
nades = "";
primary = weaponConstText;
secondary = weaponConstText;
if (WeaponMode == WEAPON_MODE_RIFLES_NO_AWP)
{
giveTAwp = false;
}
int client = tPlayers.Get(i);
if (StrEqual(g_CTRifleChoice[client], "") || StrEqual(g_TRifleChoice[client], ""))
{
PrintToChatAll("");
OnClientCookiesCached(client);
}
if (isPistolRound)
{
primary = "";
StrCat(secondary, sizeof(secondary), g_TPistolOnlyChoice[client]);
}
else if (giveTAwp && g_TAwpChoice[client]) {
StrCat(primary, sizeof(primary), "awp");
giveTAwp = false;
StrCat(secondary, sizeof(secondary), g_TPistolChoice[client]);
} else {
if (GiveEnemyTeamWeapon())
{
StrCat(primary, sizeof(primary), g_CTRifleChoice[client]);
char primaryDisplayString[255] = "";
AppendWeaponDisplay(primaryDisplayString, sizeof(primaryDisplayString), g_CTRifleChoice[client]);
PrintToChat(client, "You received a %s to simulate a weapon pickup on the previous round", primaryDisplayString);
}
else
{
StrCat(primary, sizeof(primary), g_TRifleChoice[client]);
}
StrCat(secondary, sizeof(secondary), g_TPistolChoice[client]);
}
if (StrEqual(secondary, weaponConstText))
{
StrCat(secondary, sizeof(secondary), g_CTPistolChoice[client]);
}
health = 100;
if (!isPistolRound || teammatesWithNades < 2)
{
SetNadesGetKit(nades, CS_TEAM_T, isPistolRound, false);
if (isPistolRound && !StrEqual(nades, ""))
{
teammatesWithNades++;
}
}
kevlar = !isPistolRound ? 100 : isPistolRound && StrEqual(secondary, "weapon_glock") ? 100 : 0;
if (isPistolRound && kevlar > 0)
{
kevlar = (!isPistolRound || (StrEqual(nades, ""))) ? 100 : 0;
}
if (WeaponMode == WEAPON_MODE_PISTOLS)
{
primary = "";
}
else if (WeaponMode == WEAPON_MODE_RIFLES || WeaponMode == WEAPON_MODE_RIFLES_NO_AWP)
{
secondary = "";
}
Retakes_SetPlayerInfo(client, primary, secondary, nades, health, kevlar, helmet, false);
}
teammatesWithNades = 0;
bool ctHasKit = false;
bool kit = false;
// CT setup
for (int i = 0; i < ctCount; i++) {
kit = false;
nades = "";
primary = weaponConstText;
secondary = weaponConstText;
if (WeaponMode == WEAPON_MODE_RIFLES_NO_AWP)
{
giveTAwp = false;
}
int client = ctPlayers.Get(i);
if (StrEqual(g_CTRifleChoice[client], "") || StrEqual(g_TRifleChoice[client], ""))
{
OnClientCookiesCached(client);
}
if (isPistolRound)
{
primary = "";
StrCat(secondary, sizeof(secondary), g_CTPistolOnlyChoice[client]);
}
else if (giveCTAwp && g_CTAwpChoice[client]) {
StrCat(primary, sizeof(primary), "awp");
giveCTAwp = false;
} else {
if (GiveEnemyTeamWeapon())
{
StrCat(primary, sizeof(primary), g_TRifleChoice[client]);
char primaryDisplayString[255] = "";
AppendWeaponDisplay(primaryDisplayString, sizeof(primaryDisplayString), g_TRifleChoice[client]);
PrintToChat(client, "You received the %s to simulate a weapon pickup on the previous round", primaryDisplayString);
}
else
{
StrCat(primary, sizeof(primary), g_CTRifleChoice[client]);
}
}
if (StrEqual(secondary, weaponConstText))
{
StrCat(secondary, sizeof(secondary), g_CTPistolChoice[client]);
}
health = 100;
if (!isPistolRound || teammatesWithNades < 2)
{
kit = SetNadesGetKit(nades, CS_TEAM_CT, isPistolRound, ctHasKit); // On pistol round, will only have a kit if they have no nades
if (isPistolRound && (kit || !StrEqual(nades, "")))
{
teammatesWithNades++;
}
}
if (isPistolRound && kit)
{
ctHasKit = true;
}
char clientName[255];
GetClientName(client, clientName, sizeof(clientName));
char hasKit[255];
Format(clientName, sizeof(clientName), "hasKit: %b", kit);
StrCat(clientName, sizeof(clientName), hasKit);
kevlar = !isPistolRound ? 100 : isPistolRound && (StrEqual(secondary, "weapon_hkp2000") || StrEqual(secondary, "weapon_usp_silencer")) ? 100 : 0;
if (isPistolRound && kevlar > 0)
{
kevlar = !isPistolRound || (isPistolRound && !kit && (StrEqual(nades, ""))) ? 100 : 0;
}
if (WeaponMode == WEAPON_MODE_PISTOLS)
{
primary = "";
}
else if (WeaponMode == WEAPON_MODE_RIFLES || WeaponMode == WEAPON_MODE_RIFLES_NO_AWP)
{
secondary = "";
}
Retakes_SetPlayerInfo(client, primary, secondary, nades, health, kevlar, helmet, kit);
}
}
void AppendWeaponDisplay(char[] buffer, int bufferSize, char[] weapon)
{
// General Weapons
if (StrEqual(weapon, "ssg08"))
{
StrCat(buffer, bufferSize, "SSG 08");
}
else if (StrEqual(weapon, "p250"))
{
StrCat(buffer, bufferSize, "P250");
}
else if (StrEqual(weapon, "deagle"))
{
StrCat(buffer, bufferSize, "Deagle");
}
else if (StrEqual(weapon, "revolver"))
{
StrCat(buffer, bufferSize, "Revolver");
}
else if (StrEqual(weapon, "cz75a"))
{
StrCat(buffer, bufferSize, "CZ75-Auto");
}
// CT Exclusive Weapons
else if (StrEqual(weapon, "m4a1"))
{
StrCat(buffer, bufferSize, "M4A4");
}
else if (StrEqual(weapon, "m4a1_silencer"))
{
StrCat(buffer, bufferSize, "M4A1-S");
}
else if (StrEqual(weapon, "aug"))
{
StrCat(buffer, bufferSize, "AUG");
}
else if (StrEqual(weapon, "famas"))
{
StrCat(buffer, bufferSize, "Famas");
}
else if (StrEqual(weapon, "usp_silencer"))
{
StrCat(buffer, bufferSize, "USP-S");
}
else if (StrEqual(weapon, "hkp2000"))
{
StrCat(buffer, bufferSize, "P2000");
}
else if (StrEqual(weapon, "fiveseven"))
{
StrCat(buffer, bufferSize, "Five-Seven");
}
// T Exclusive Weapons
else if (StrEqual(weapon, "ak47"))
{
StrCat(buffer, bufferSize, "AK-47");
}
else if (StrEqual(weapon, "sg556"))
{
StrCat(buffer, bufferSize, "SG-553");
}
else if (StrEqual(weapon, "galilar"))
{
StrCat(buffer, bufferSize, "Galil AR");
}
else if (StrEqual(weapon, "glock"))
{
StrCat(buffer, bufferSize, "Glock-18");
}
else if (StrEqual(weapon, "tec9"))
{
StrCat(buffer, bufferSize, "Tec-9");
}
}
public void ShowWeaponsMenu(int client) {
Menu menu = new Menu(MenuHandler_LoadoutSelection);
menu.SetTitle("Select a loadout to edit:");
menu.AddItem("ctmenu", "CT");
menu.AddItem("tmenu", "T");
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_LoadoutSelection(Menu menu, MenuAction action, int param1, int param2) {
if (action == MenuAction_Select) {
int client = param1;
char choice[255];
menu.GetItem(param2, choice, sizeof(choice));
if (StrEqual(choice, "ctmenu"))
{
if (WeaponMode == WEAPON_MODE_ALL)
{
CTLoadoutMenu(client);
}
else if (WeaponMode == WEAPON_MODE_PISTOLS)
{
CTPistolMenu(client);
}
else if (WeaponMode == WEAPON_MODE_RIFLES)
{
CTRifleMenu(client);
}
}
else
{
if (WeaponMode == WEAPON_MODE_ALL)
{
TLoadoutMenu(client);
}
else if (WeaponMode == WEAPON_MODE_PISTOLS)
{
TPistolMenu(client);
}
else if (WeaponMode == WEAPON_MODE_RIFLES)
{
TRifleMenu(client);
}
}
} else if (action == MenuAction_End) {
delete menu;
}
}
public void CTLoadoutMenu(int client) {
char ctRifleString[255] = "CT Rifle: ";
AppendWeaponDisplay(ctRifleString, sizeof(ctRifleString), g_CTRifleChoice[client]);
char ctPistolString[255] = "CT Pistol: ";
AppendWeaponDisplay(ctPistolString, sizeof(ctPistolString), g_CTPistolChoice[client]);
char ctPistolOnlyString[255] = "CT Pistol Rounds: ";
AppendWeaponDisplay(ctPistolOnlyString, sizeof(ctPistolOnlyString), g_CTPistolOnlyChoice[client]);
char ctAwpString[255] = "CT Awp: ";
StrCat(ctAwpString, sizeof(ctAwpString), g_CTAwpChoice[client] ? "Always" : "Never");
Menu menu = new Menu(MenuHandler_CTLoadout);
menu.ExitBackButton = true;
menu.SetTitle("CT Loadout:");
menu.AddItem("ctrifle", ctRifleString);
menu.AddItem("ctpistol", ctPistolString);
menu.AddItem("ctawp", ctAwpString);
menu.AddItem("ctpistolrounds", ctPistolOnlyString);
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_CTLoadout(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
char choice[WEAPON_STRING_LENGTH];
menu.GetItem(param2, choice, sizeof(choice));
if (StrEqual(choice, "ctrifle"))
{
CTRifleMenu(client);
}
else if (StrEqual(choice, "ctpistol"))
{
CTPistolMenu(client);
}
else if (StrEqual(choice, "ctpistolrounds"))
{
CTPistolOnlyMenu(client);
}
else if (StrEqual(choice, "ctawp"))
{
//CTAwpMenu(client);
GiveCTAwpMenu(client);
}
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
ShowWeaponsMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}
public void TLoadoutMenu(int client) {
char tRifleString[255] = "T Rifle: ";
AppendWeaponDisplay(tRifleString, sizeof(tRifleString), g_TRifleChoice[client]);
char tPistolString[255] = "T Pistol: ";
AppendWeaponDisplay(tPistolString, sizeof(tPistolString), g_TPistolChoice[client]);
char tPistolOnlyString[255] = "T Pistol Rounds: ";
AppendWeaponDisplay(tPistolOnlyString, sizeof(tPistolOnlyString), g_TPistolOnlyChoice[client]);
char tAwpString[255] = "T Awp: ";
StrCat(tAwpString, sizeof(tAwpString), g_TAwpChoice[client] ? "Always" : "Never");
Menu menu = new Menu(MenuHandler_TLoadout);
menu.ExitBackButton = true;
menu.SetTitle("T Loadout:");
menu.AddItem("trifle", tRifleString);
menu.AddItem("tpistol", tPistolString);
menu.AddItem("tawp", tAwpString);
menu.AddItem("tpistolrounds", tPistolOnlyString);
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_TLoadout(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
char choice[255];
menu.GetItem(param2, choice, sizeof(choice));
if (StrEqual(choice, "trifle"))
{
TRifleMenu(client);
}
else if (StrEqual(choice, "tpistol"))
{
TPistolMenu(client);
}
else if (StrEqual(choice, "tpistolrounds"))
{
TPistolOnlyMenu(client);
}
else if (StrEqual(choice, "tawp"))
{
//TAwpMenu(client);
GiveTAwpMenu(client);
}
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
ShowWeaponsMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}
public void CTRifleMenu(int client) {
Menu menu = new Menu(MenuHandler_CTRifle);
menu.ExitBackButton = true;
menu.SetTitle("Select a CT rifle:");
menu.AddItem("m4a1", "M4A4");
menu.AddItem("m4a1_silencer", "M4A1-S");
menu.AddItem("aug", "AUG");
menu.AddItem("famas", "Famas");
menu.AddItem("ssg08", "SSG 08");
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_CTRifle(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
char choice[WEAPON_STRING_LENGTH];
menu.GetItem(param2, choice, sizeof(choice));
g_CTRifleChoice[client] = choice;
SetClientCookie(client, g_hCTRifleChoiceCookie, choice);
CTLoadoutMenu(client);
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
CTLoadoutMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}
public void SetCTPistolMenuItems(Menu menu)
{
menu.AddItem("usp_silencer", "USP-S");
menu.AddItem("hkp2000", "P2000");
menu.AddItem("fiveseven", "Five-Seven");
menu.AddItem("cz75a", "CZ75-Auto");
menu.AddItem("p250", "P250");
menu.AddItem("deagle", "Deagle");
menu.AddItem("revolver", "Revolver");
}
public void CTPistolMenu(int client) {
Menu menu = new Menu(MenuHandler_CTPistol);
menu.ExitBackButton = true;
menu.SetTitle("Select a CT pistol:");
SetCTPistolMenuItems(menu);
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_CTPistol(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
char choice[WEAPON_STRING_LENGTH];
menu.GetItem(param2, choice, sizeof(choice));
g_CTPistolChoice[client] = choice;
SetClientCookie(client, g_hCTPistolChoiceCookie, choice);
CTLoadoutMenu(client);
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
CTLoadoutMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}
public void CTPistolOnlyMenu(int client) {
Menu menu = new Menu(MenuHandler_CTPistolOnly);
menu.ExitBackButton = true;
menu.SetTitle("Select a CT pistol round weapon:");
SetCTPistolMenuItems(menu);
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_CTPistolOnly(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
char choice[WEAPON_STRING_LENGTH];
menu.GetItem(param2, choice, sizeof(choice));
g_CTPistolOnlyChoice[client] = choice;
SetClientCookie(client, g_hCTPistolOnlyChoiceCookie, choice);
CTLoadoutMenu(client);
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
CTLoadoutMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}
public void GiveCTAwpMenu(int client) {
Menu menu = new Menu(MenuHandler_CTAWP);
menu.ExitBackButton = true;
menu.SetTitle("Receive AWPs on CT side?");
AddMenuBool(menu, true, "Yes");
AddMenuBool(menu, false, "No");
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_CTAWP(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
bool allowAwps = GetMenuBool(menu, param2);
g_CTAwpChoice[client] = allowAwps;
SetCookieBool(client, g_hCTAwpChoiceCookie, allowAwps);
CTLoadoutMenu(client);
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
CTLoadoutMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}
public void TRifleMenu(int client) {
Menu menu = new Menu(MenuHandler_TRifle);
menu.ExitBackButton = true;
menu.SetTitle("Select a T rifle:");
menu.AddItem("ak47", "AK-47");
menu.AddItem("sg556", "SG-553");
menu.AddItem("galilar", "Galil AR");
menu.AddItem("ssg08", "SSG 08");
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_TRifle(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
char choice[WEAPON_STRING_LENGTH];
menu.GetItem(param2, choice, sizeof(choice));
g_TRifleChoice[client] = choice;
SetClientCookie(client, g_hTRifleChoiceCookie, choice);
TLoadoutMenu(client);
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
TLoadoutMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}
public void SetTPistolMenuItems(Menu menu)
{
menu.AddItem("glock", "Glock-18");
menu.AddItem("tec9", "Tec-9");
menu.AddItem("cz75a", "CZ75-Auto");
menu.AddItem("p250", "P250");
menu.AddItem("deagle", "Deagle");
menu.AddItem("revolver", "Revolver");
}
public void TPistolMenu(int client) {
Menu menu = new Menu(MenuHandler_TPistol);
menu.ExitBackButton = true;
menu.SetTitle("Select a T pistol:");
SetTPistolMenuItems(menu);
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_TPistol(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
char choice[WEAPON_STRING_LENGTH];
menu.GetItem(param2, choice, sizeof(choice));
g_TPistolChoice[client] = choice;
SetClientCookie(client, g_hTPistolChoiceCookie, choice);
TLoadoutMenu(client);
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
TLoadoutMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}
public void TPistolOnlyMenu(int client) {
Menu menu = new Menu(MenuHandler_TPistolOnly);
menu.ExitBackButton = true;
menu.SetTitle("Select a T pistol round weapon:");
SetTPistolMenuItems(menu);
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_TPistolOnly(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
char choice[WEAPON_STRING_LENGTH];
menu.GetItem(param2, choice, sizeof(choice));
g_TPistolOnlyChoice[client] = choice;
SetClientCookie(client, g_hTPistolOnlyChoiceCookie, choice);
TLoadoutMenu(client);
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
TLoadoutMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}
public void GiveTAwpMenu(int client) {
Menu menu = new Menu(MenuHandler_TAWP);
menu.ExitBackButton = true;
menu.SetTitle("Receive AWPs on T side?");
AddMenuBool(menu, true, "Yes");
AddMenuBool(menu, false, "No");
menu.Display(client, MENU_TIME_LENGTH);
}
public int MenuHandler_TAWP(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
bool allowAwps = GetMenuBool(menu, param2);
g_TAwpChoice[client] = allowAwps;
SetCookieBool(client, g_hTAwpChoiceCookie, allowAwps);
TLoadoutMenu(client);
} else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack) {
TLoadoutMenu(client);
} else if (action == MenuAction_End) {
delete menu;
}
}