forked from fdxx/l4d2_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
l4d2_dev_menu.sp
1688 lines (1542 loc) · 42.8 KB
/
l4d2_dev_menu.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
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <adminmenu>
#include <left4dhooks>
#define VERSION "0.9"
#define BOSS_TYPE_TANK 0
#define BOSS_TYPE_WITCH 1
static const char g_sWeapons[][][] =
{
{"weapon_shotgun_chrome", "铁喷", "models/w_models/weapons/w_pumpshotgun_A.mdl"},
{"weapon_pumpshotgun", "木喷", "models/w_models/weapons/w_shotgun.mdl"},
{"weapon_smg", "乌兹", "models/w_models/weapons/w_smg_uzi.mdl"},
{"weapon_smg_silenced", "消音冲锋", "models/w_models/weapons/w_smg_a.mdl"},
{"weapon_autoshotgun", "连喷", "models/w_models/weapons/w_autoshot_m4super.mdl"},
{"weapon_shotgun_spas", "钢喷", "models/w_models/weapons/w_shotgun_spas.mdl"},
{"weapon_rifle", "M16A2", "models/w_models/weapons/w_rifle_m16a2.mdl"},
{"weapon_rifle_desert", "三连发", "models/w_models/weapons/w_desert_rifle.mdl"},
{"weapon_rifle_ak47", "AK47", "models/w_models/weapons/w_rifle_ak47.mdl"},
{"weapon_sniper_military", "连狙", "models/w_models/weapons/w_sniper_military.mdl"},
{"weapon_hunting_rifle", "木狙", "models/w_models/weapons/w_sniper_mini14.mdl"},
{"weapon_sniper_awp", "AWP", "models/w_models/weapons/w_sniper_awp.mdl"},
{"weapon_sniper_scout", "鸟狙", "models/w_models/weapons/w_sniper_scout.mdl"},
{"weapon_smg_mp5", "MP5", "models/w_models/weapons/w_smg_mp5.mdl"},
{"weapon_rifle_sg552", "SG552", "models/w_models/weapons/w_rifle_sg552.mdl"},
{"weapon_grenade_launcher", "榴弹发射器", "models/w_models/weapons/w_grenade_launcher.mdl"},
{"weapon_rifle_m60", "M60", "models/w_models/weapons/w_m60.mdl"},
{"weapon_pistol_magnum", "马格南", "models/w_models/weapons/w_desert_eagle.mdl"},
{"weapon_chainsaw", "电锯", "models/weapons/melee/w_chainsaw.mdl"},
};
static const char g_sMelees[][][] =
{
// 需要使用近战解锁插件
{"fireaxe", "斧头", "models/weapons/melee/w_fireaxe.mdl"},
{"baseball_bat", "棒球棒", "models/weapons/melee/w_bat.mdl"},
{"cricket_bat", "球拍", "models/weapons/melee/w_cricket_bat.mdl"},
{"crowbar", "撬棍", "models/weapons/melee/w_crowbar.mdl"},
{"frying_pan", "平底锅", "models/weapons/melee/w_frying_pan.mdl"},
{"golfclub", "高尔夫球棍", "models/weapons/melee/w_golfclub.mdl"},
{"electric_guitar", "吉他", "models/weapons/melee/w_electric_guitar.mdl"},
{"katana", "武士刀", "models/weapons/melee/w_katana.mdl"},
{"machete", "砍刀", "models/weapons/melee/w_machete.mdl"},
{"tonfa", "警棍", "models/weapons/melee/w_tonfa.mdl"},
{"knife", "小刀", "models/w_models/weapons/w_knife_t.mdl"},
{"pitchfork", "草叉", "models/weapons/melee/w_pitchfork.mdl"},
{"shovel", "铁铲", "models/weapons/melee/w_shovel.mdl"},
{"weapon_pistol_magnum","马格南", "models/w_models/weapons/w_desert_eagle.mdl"},
{"weapon_chainsaw", "电锯", "models/weapons/melee/w_chainsaw.mdl"},
};
static const char g_sMedicalAndThrowItem[][][] =
{
{"weapon_first_aid_kit", "急救包", "models/w_models/weapons/w_eq_medkit.mdl"},
{"weapon_pain_pills", "止痛药", "models/w_models/weapons/w_eq_painpills.mdl"},
{"weapon_adrenaline", "肾上腺素", "models/w_models/weapons/w_eq_adrenaline.mdl"},
{"weapon_defibrillator", "电击除颤器", "models/w_models/weapons/w_eq_defibrillator.mdl"},
{"weapon_molotov", "燃烧瓶", "models/w_models/weapons/w_eq_molotov.mdl"},
{"weapon_pipe_bomb", "土制炸弹", "models/w_models/weapons/w_eq_pipebomb.mdl"},
{"weapon_vomitjar", "胆汁瓶", "models/w_models/weapons/w_eq_bile_flask.mdl"},
};
static const char g_sOtherItem[][][] =
{
// 如果客户端已经持有相同的物品,再次产生时会变得无法破坏/点燃/爆炸,需要重新捡起来一次才行
// https://forums.alliedmods.net/showthread.php?p=2739179
{"weapon_gascan", "汽油箱", "models/props_junk/gascan001a.mdl"},
{"weapon_propanetank", "丙烷罐", "models/props_junk/propanecanister001a.mdl"},
{"weapon_oxygentank", "氧气罐", "models/props_equipment/oxygentank01.mdl"},
{"weapon_fireworkcrate", "烟花盒", "models/props_junk/explosive_box001.mdl"},
{"weapon_upgradepack_incendiary", "燃烧弹升级包", "models/w_models/weapons/w_eq_incendiary_ammopack.mdl"},
{"weapon_upgradepack_explosive", "高爆弹升级包", "models/w_models/weapons/w_eq_explosive_ammopack.mdl"},
};
enum
{
ITEM_NAME,
ITEM_DISPLAY,
ITEM_MODEL
};
TopMenu g_TopMenu;
TopMenuObject
g_TopObj_Kill,
g_TopObj_SpawnSpecial,
g_TopObj_GodMode,
g_TopObj_NoClip,
g_TopObj_Teleport,
g_TopObj_GiveItem,
g_TopObj_GiveHp,
g_TopObj_Falldown,
g_TopObj_Respawn,
g_TopObj_Deprive,
g_TopObj_Freeze;
int
g_iGiveItemMenuPos[MAXPLAYERS+1][4],
g_iSpecialClassMenuPos[MAXPLAYERS+1],
g_iNoClipMenuPos[MAXPLAYERS+1],
g_iGodModeMenuPos[MAXPLAYERS+1],
g_iKillMenuPos[MAXPLAYERS+1],
g_iGiveItemType[MAXPLAYERS+1];
bool
g_bAutoSpawn[MAXPLAYERS+1],
g_bSpawnType[MAXPLAYERS+1],
g_bSpecialSpawnControl,
g_bBossSpawnControl;
StringMap
g_smNameToClass;
public Plugin myinfo =
{
name = "L4D2 Dev Menu",
author = "fdxx",
version = VERSION,
}
public void OnPluginStart()
{
CreateConVar("l4d2_dev_menu_version", VERSION, "version", FCVAR_NONE | FCVAR_DONTRECORD);
CreateStringMap();
RegAdminCmd("sm_kl", Cmd_Kill, ADMFLAG_ROOT);
RegAdminCmd("sm_god", Cmd_GodMode, ADMFLAG_ROOT);
RegAdminCmd("sm_fly", Cmd_Noclip, ADMFLAG_ROOT);
RegAdminCmd("sm_tele", Cmd_Teleport, ADMFLAG_ROOT);
RegAdminCmd("sm_givehp", Cmd_GiveHealth, ADMFLAG_ROOT);
RegAdminCmd("sm_rehp", Cmd_GiveHealth, ADMFLAG_ROOT);
}
void CreateStringMap()
{
g_smNameToClass = new StringMap();
g_smNameToClass.SetValue("smoker", 1, true);
g_smNameToClass.SetValue("boomer", 2, true);
g_smNameToClass.SetValue("hunter", 3, true);
g_smNameToClass.SetValue("spitter", 4, true);
g_smNameToClass.SetValue("jockey", 5, true);
g_smNameToClass.SetValue("charger", 6, true);
g_smNameToClass.SetValue("witch", 7, true);
g_smNameToClass.SetValue("tank", 8, true);
}
public void OnConfigsExecuted()
{
g_bSpecialSpawnControl = GetFeatureStatus(FeatureType_Native, "L4D2_CanSpawnSpecial") == FeatureStatus_Available;
g_bBossSpawnControl = GetFeatureStatus(FeatureType_Native, "L4D2_CanSpawnBoss") == FeatureStatus_Available;
static bool shit;
if (shit) return;
shit = true;
if (LibraryExists("adminmenu") && ((g_TopMenu = GetAdminTopMenu()) != null))
{
TopMenuObject TopObj_DevMenu = g_TopMenu.AddCategory("l4d2_dev_menu", Category_TopMenuHandler, "l4d2_dev_menu", ADMFLAG_ROOT);
// 可以在 configs/adminmenu_sorting.txt 中设置菜单显示的顺序
g_TopObj_Kill = g_TopMenu.AddItem("l4d2_dev_menu_kill", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_kill", ADMFLAG_ROOT, "处死玩家");
g_TopObj_SpawnSpecial = g_TopMenu.AddItem("l4d2_dev_menu_spawnspecial", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_spawnspecial", ADMFLAG_ROOT, "产生特感");
g_TopObj_GodMode = g_TopMenu.AddItem("l4d2_dev_menu_godmode", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_godmode", ADMFLAG_ROOT, "无敌模式");
g_TopObj_NoClip = g_TopMenu.AddItem("l4d2_dev_menu_noclip", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_noclip", ADMFLAG_ROOT, "穿墙模式");
g_TopObj_Teleport = g_TopMenu.AddItem("l4d2_dev_menu_teleport", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_teleport", ADMFLAG_ROOT, "传送");
g_TopObj_GiveItem = g_TopMenu.AddItem("l4d2_dev_menu_giveitem", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_giveitem", ADMFLAG_ROOT, "产生物品");
g_TopObj_GiveHp = g_TopMenu.AddItem("l4d2_dev_menu_givehp", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_givehp", ADMFLAG_ROOT, "回血");
g_TopObj_Falldown = g_TopMenu.AddItem("l4d2_dev_menu_falldown", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_falldown", ADMFLAG_ROOT, "强制倒地");
g_TopObj_Respawn = g_TopMenu.AddItem("l4d2_dev_menu_respawn", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_respawn", ADMFLAG_ROOT, "复活");
g_TopObj_Deprive = g_TopMenu.AddItem("l4d2_dev_menu_deprive", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_deprive", ADMFLAG_ROOT, "装备剥夺");
g_TopObj_Freeze = g_TopMenu.AddItem("l4d2_dev_menu_freeze", Item_TopMenuHandler, TopObj_DevMenu, "l4d2_dev_menu_freeze", ADMFLAG_ROOT, "冻结");
}
}
void Category_TopMenuHandler(TopMenu topmenu, TopMenuAction action, TopMenuObject topobj_id, int param, char[] buffer, int maxlength)
{
switch (action)
{
case TopMenuAction_DisplayOption: FormatEx(buffer, maxlength, "开发工具");
case TopMenuAction_DisplayTitle: FormatEx(buffer, maxlength, "开发工具:");
}
}
void Item_TopMenuHandler(TopMenu topmenu, TopMenuAction action, TopMenuObject topobj_id, int client, char[] buffer, int maxlength)
{
switch (action)
{
case TopMenuAction_DisplayOption:
{
topmenu.GetInfoString(topobj_id, buffer, maxlength);
}
case TopMenuAction_SelectOption:
{
ResetSubMenuPos(client); // 重置子菜单位置
if (topobj_id == g_TopObj_Kill)
Kill_TargetSelect(client);
else if (topobj_id == g_TopObj_SpawnSpecial)
SpawnSpecial_ClassSelect(client);
else if (topobj_id == g_TopObj_GodMode)
GodMode_TargetSelect(client);
else if (topobj_id == g_TopObj_NoClip)
NoClip_TargetSelect(client);
else if (topobj_id == g_TopObj_Teleport)
Teleport_TypeSelect(client);
else if (topobj_id == g_TopObj_GiveItem)
GiveItem_TypeSelect(client);
else if (topobj_id == g_TopObj_GiveHp)
GiveHp_TargetSelect(client);
else if (topobj_id == g_TopObj_Falldown)
FallDown_TargetSelect(client);
else if (topobj_id == g_TopObj_Respawn)
Respawn_TargetSelect(client);
else if (topobj_id == g_TopObj_Deprive)
Deprive_TargetSelect(client);
else if (topobj_id == g_TopObj_Freeze)
Freeze_TargetSelect(client);
}
}
}
void ResetSubMenuPos(int client)
{
for (int i = 0; i < sizeof(g_iGiveItemMenuPos[]); i++)
{
g_iGiveItemMenuPos[client][i] = 0;
}
g_iSpecialClassMenuPos[client] = 0;
g_iNoClipMenuPos[client] = 0;
g_iGodModeMenuPos[client] = 0;
g_iKillMenuPos[client] = 0;
}
void Kill_TargetSelect(int client)
{
Menu menu = new Menu(Kill_TargetSelect_MenuHandler);
menu.SetTitle("选择处死目标:");
menu.AddItem("", "所有特感");
menu.AddItem("", "所有普通感染者");
menu.AddItem("", "自己");
menu.AddItem("", "所有幸存者");
char sName[128], sUserid[16];
for (int i = 1; i <= MaxClients; i++)
{
if (i != client && IsClientInGame(i) && IsPlayerAlive(i))
{
switch (GetClientTeam(i))
{
case 2, 3:
{
FormatEx(sName, sizeof(sName), "%N", i);
FormatEx(sUserid, sizeof(sUserid), "%i", GetClientUserId(i));
menu.AddItem(sUserid, sName);
}
}
}
}
menu.ExitBackButton = true;
menu.DisplayAt(client, g_iKillMenuPos[client], MENU_TIME_FOREVER);
}
int Kill_TargetSelect_MenuHandler(Menu menu, MenuAction action, int client, int itemNum)
{
switch (action)
{
case MenuAction_Select:
{
switch (itemNum)
{
case 0, 1, 2, 3: DoKill(client, itemNum);
default:
{
char sUserid[16];
menu.GetItem(itemNum, sUserid, sizeof(sUserid));
int iTarget = GetClientOfUserId(StringToInt(sUserid));
if (iTarget > 0 && iTarget <= MaxClients && IsClientInGame(iTarget) && IsPlayerAlive(iTarget))
{
switch (GetClientTeam(iTarget))
{
case 2, 3:
{
ForcePlayerSuicide(iTarget);
Print(client, "[DevMenu] 处死: %N", iTarget);
}
}
}
}
}
g_iKillMenuPos[client] = menu.Selection;
Kill_TargetSelect(client);
}
case MenuAction_Cancel:
{
if (itemNum == MenuCancel_ExitBack)
g_TopMenu.Display(client, TopMenuPosition_LastCategory);
}
case MenuAction_End:
{
delete menu;
}
}
return 0;
}
Action Cmd_Kill(int client, int args)
{
if (args != 1)
{
ReplyToCommand(client, "sm_kl <si|ci|me|sur|all>");
return Plugin_Handled;
}
int iType = -1;
char sTarget[32];
GetCmdArg(1, sTarget, sizeof(sTarget));
if (strcmp(sTarget, "si", false) == 0)
iType = 0;
else if (strcmp(sTarget, "ci", false) == 0)
iType = 1;
else if (strcmp(sTarget, "me", false) == 0)
iType = 2;
else if (strcmp(sTarget, "sur", false) == 0)
iType = 3;
else if (strcmp(sTarget, "all", false) == 0)
iType = 4;
DoKill(client, iType);
return Plugin_Handled;
}
void DoKill(int client, int iType)
{
switch (iType)
{
case 0:
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
{
ForcePlayerSuicide(i);
Print(client, "[DevMenu] 处死: %N", i);
}
}
int witch = -1;
while ((witch = FindEntityByClassname(witch, "witch")) != INVALID_ENT_REFERENCE)
{
AcceptEntityInput(witch, "Kill");
Print(client, "[DevMenu] 处死: Witch");
}
}
case 1:
{
int inf = -1;
int count;
while ((inf = FindEntityByClassname(inf, "infected")) != INVALID_ENT_REFERENCE)
{
count++;
AcceptEntityInput(inf, "Kill");
}
Print(client, "[DevMenu] 处死普通感染者: %i 个", count);
}
case 2:
{
if (IsPlayerAlive(client))
{
ForcePlayerSuicide(client);
Print(client, "[DevMenu] 处死: %N", client);
}
}
case 3:
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
{
ForcePlayerSuicide(i);
Print(client, "[DevMenu] 处死: %N", i);
}
}
}
case 4:
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && (GetClientTeam(i) == 2 || GetClientTeam(i) == 3))
{
ForcePlayerSuicide(i);
Print(client, "[DevMenu] 处死: %N", i);
}
}
}
}
}
void SpawnSpecial_ClassSelect(int client)
{
static char sSpawnType[128], sAutoSpawn[128];
FormatEx(sSpawnType, sizeof(sSpawnType), "%s", g_bSpawnType[client] ? "设置产生方式 [当前: left4dhooks]" : "设置产生方式 [当前: z_spawn_old]");
FormatEx(sAutoSpawn, sizeof(sAutoSpawn), "%s", g_bAutoSpawn[client] ? "设置产生位置 [当前: 自动找位]" : "设置产生位置 [当前: 十字准星处]");
Menu menu = new Menu(SpawnSpecial_ClassSelect_MenuHandler);
menu.SetTitle("产生特感:");
menu.AddItem("", sSpawnType);
menu.AddItem("", sAutoSpawn);
menu.AddItem("tank", "Tank");
menu.AddItem("witch", "Witch");
menu.AddItem("smoker", "Smoker");
menu.AddItem("boomer", "Boomer");
menu.AddItem("hunter", "Hunter");
menu.AddItem("spitter", "Spitter");
menu.AddItem("jockey", "Jockey");
menu.AddItem("charger", "Charger");
menu.ExitBackButton = true;
menu.DisplayAt(client, g_iSpecialClassMenuPos[client], MENU_TIME_FOREVER);
}
int SpawnSpecial_ClassSelect_MenuHandler(Menu menu, MenuAction action, int client, int itemNum)
{
switch (action)
{
case MenuAction_Select:
{
switch (itemNum)
{
case 0: g_bSpawnType[client] = !g_bSpawnType[client];
case 1: g_bAutoSpawn[client] = !g_bAutoSpawn[client];
default:
{
AllowSpawn(true);
char sName[16], sDisplay[128];
menu.GetItem(itemNum, sName, sizeof(sName), _, sDisplay, sizeof(sDisplay));
if (!g_bSpawnType[client])
{
char sCmdArgs[128];
FormatEx(sCmdArgs, sizeof(sCmdArgs), "%s%s", sName, (g_bAutoSpawn[client] ? " auto" : ""));
CheatCommand(client, "z_spawn_old", sCmdArgs);
Print(client, "[DevMenu] 产生特感 (z_spawn_old): %s", sDisplay);
}
else
{
int iClass;
if (g_smNameToClass.GetValue(sName, iClass))
{
float fPos[3];
if (GetSpawnPos(client, iClass, fPos))
{
bool bSpawnSuccess;
switch (iClass)
{
case 1,2,3,4,5,6:
bSpawnSuccess = L4D2_SpawnSpecial(iClass, fPos, NULL_VECTOR) > 0;
case 7:
bSpawnSuccess = L4D2_SpawnWitch(fPos, NULL_VECTOR) > MaxClients;
case 8:
bSpawnSuccess = L4D2_SpawnTank(fPos, NULL_VECTOR) > 0;
}
if (bSpawnSuccess)
{
Print(client, "[DevMenu] 产生特感 (left4dhooks): %s", sDisplay);
}
}
}
}
AllowSpawn(false);
}
}
g_iSpecialClassMenuPos[client] = menu.Selection;
SpawnSpecial_ClassSelect(client);
}
case MenuAction_Cancel:
{
if (itemNum == MenuCancel_ExitBack)
g_TopMenu.Display(client, TopMenuPosition_LastCategory);
}
case MenuAction_End:
{
delete menu;
}
}
return 0;
}
bool GetSpawnPos(int client, int iClass, float fPos[3])
{
if (g_bAutoSpawn[client])
{
return L4D_GetRandomPZSpawnPosition(client, iClass, 30, fPos);
}
else
{
float fClientAng[3], fClientPos[3];
GetClientEyeAngles(client, fClientAng);
GetClientEyePosition(client, fClientPos);
Handle hTrace = TR_TraceRayFilterEx(fClientPos, fClientAng, MASK_SHOT, RayType_Infinite, TraceFilter);
if (TR_DidHit(hTrace))
{
TR_GetEndPosition(fPos, hTrace); //获得碰撞点
fPos[2] += 20.0; // 避免产生在地下
delete hTrace;
return true;
}
delete hTrace;
return false;
}
}
bool TraceFilter(int entity, int contentsMask)
{
return entity > MaxClients;
}
void GodMode_TargetSelect(int client)
{
Menu menu = new Menu(GodMode_TargetSelect_MenuHandler);
menu.SetTitle("选择无敌模式目标:");
menu.AddItem("", "自己");
menu.AddItem("", "所有幸存者");
menu.AddItem("", "所有特感");
char sName[128], sUserid[16];
for (int i = 1; i <= MaxClients; i++)
{
if (i != client && IsClientInGame(i) && IsPlayerAlive(i))
{
switch (GetClientTeam(i))
{
case 2:
{
FormatEx(sName, sizeof(sName), "%N", i);
FormatEx(sUserid, sizeof(sUserid), "%i", GetClientUserId(i));
menu.AddItem(sUserid, sName);
}
case 3:
{
if (!GetEntProp(i, Prop_Send, "m_isGhost"))
{
FormatEx(sName, sizeof(sName), "%N", i);
FormatEx(sUserid, sizeof(sUserid), "%i", GetClientUserId(i));
menu.AddItem(sUserid, sName);
}
}
}
}
}
menu.ExitBackButton = true;
menu.DisplayAt(client, g_iGodModeMenuPos[client], MENU_TIME_FOREVER);
}
int GodMode_TargetSelect_MenuHandler(Menu menu, MenuAction action, int client, int itemNum)
{
switch (action)
{
case MenuAction_Select:
{
switch (itemNum)
{
case 0, 1, 2: DoGodMode(client, itemNum);
default:
{
char sUserid[16];
menu.GetItem(itemNum, sUserid, sizeof(sUserid));
int iTarget = GetClientOfUserId(StringToInt(sUserid));
if (iTarget > 0 && iTarget <= MaxClients && IsClientInGame(iTarget) && IsPlayerAlive(iTarget))
{
switch (GetClientTeam(iTarget))
{
case 2: SetClientGodMode(client, iTarget);
case 3:
{
if (!GetEntProp(iTarget, Prop_Send, "m_isGhost"))
SetClientGodMode(client, iTarget);
}
}
}
}
}
g_iGodModeMenuPos[client] = menu.Selection;
GodMode_TargetSelect(client);
}
case MenuAction_Cancel:
{
if (itemNum == MenuCancel_ExitBack)
g_TopMenu.Display(client, TopMenuPosition_LastCategory);
}
case MenuAction_End:
{
delete menu;
}
}
return 0;
}
Action Cmd_GodMode(int client, int args)
{
if (args != 1)
{
ReplyToCommand(client, "sm_god <me|sur|si>");
return Plugin_Handled;
}
int iType = -1;
char sTarget[32];
GetCmdArg(1, sTarget, sizeof(sTarget));
if (strcmp(sTarget, "me", false) == 0)
iType = 0;
else if (strcmp(sTarget, "sur", false) == 0)
iType = 1;
else if (strcmp(sTarget, "si", false) == 0)
iType = 2;
DoGodMode(client, iType);
return Plugin_Handled;
}
void DoGodMode(int client, int iType)
{
switch (iType)
{
case 0:
{
if (IsPlayerAlive(client))
{
switch (GetClientTeam(client))
{
case 2: SetClientGodMode(client, client);
case 3:
{
if (!GetEntProp(client, Prop_Send, "m_isGhost"))
SetClientGodMode(client, client);
}
}
}
}
case 1:
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
{
SetClientGodMode(client, i);
}
}
}
case 2:
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3 && !GetEntProp(i, Prop_Send, "m_isGhost"))
{
SetClientGodMode(client, i);
}
}
}
}
}
void SetClientGodMode(int client, int iTarget)
{
int flags = GetEntityFlags(iTarget);
if (flags & FL_GODMODE)
{
SetEntityFlags(iTarget, flags & ~FL_GODMODE);
Print(client, "[DevMenu] 关闭无敌模式: %N", iTarget);
}
else
{
SetEntityFlags(iTarget, flags | FL_GODMODE);
Print(client, "[DevMenu] 开启无敌模式: %N", iTarget);
}
}
void NoClip_TargetSelect(int client)
{
Menu menu = new Menu(NoClip_TargetSelect_MenuHandler);
menu.SetTitle("选择穿墙模式目标:");
menu.AddItem("", "自己");
menu.AddItem("", "所有幸存者");
menu.AddItem("", "所有特感");
char sName[128], sUserid[16];
for (int i = 1; i <= MaxClients; i++)
{
if (i != client && IsClientInGame(i) && IsPlayerAlive(i))
{
if (GetClientTeam(i) == 2 || GetClientTeam(i) == 3)
{
FormatEx(sName, sizeof(sName), "%N", i);
FormatEx(sUserid, sizeof(sUserid), "%i", GetClientUserId(i));
menu.AddItem(sUserid, sName);
}
}
}
menu.ExitBackButton = true;
menu.DisplayAt(client, g_iNoClipMenuPos[client], MENU_TIME_FOREVER);
}
int NoClip_TargetSelect_MenuHandler(Menu menu, MenuAction action, int client, int itemNum)
{
switch (action)
{
case MenuAction_Select:
{
switch (itemNum)
{
case 0, 1, 2: DoNoclip(client, itemNum);
default:
{
char sUserid[16];
menu.GetItem(itemNum, sUserid, sizeof(sUserid));
int iTarget = GetClientOfUserId(StringToInt(sUserid));
if (iTarget > 0 && iTarget <= MaxClients && IsClientInGame(iTarget) && IsPlayerAlive(iTarget))
{
if (GetClientTeam(iTarget) == 2 || GetClientTeam(iTarget) == 3)
{
SetClientNoClip(client, iTarget);
}
}
}
}
g_iNoClipMenuPos[client] = menu.Selection;
NoClip_TargetSelect(client);
}
case MenuAction_Cancel:
{
if (itemNum == MenuCancel_ExitBack)
g_TopMenu.Display(client, TopMenuPosition_LastCategory);
}
case MenuAction_End:
{
delete menu;
}
}
return 0;
}
Action Cmd_Noclip(int client, int args)
{
if (args != 1)
{
ReplyToCommand(client, "sm_fly <me|sur|si>");
return Plugin_Handled;
}
int iType = -1;
char sTarget[32];
GetCmdArg(1, sTarget, sizeof(sTarget));
if (strcmp(sTarget, "me", false) == 0)
iType = 0;
else if (strcmp(sTarget, "sur", false) == 0)
iType = 1;
else if (strcmp(sTarget, "si", false) == 0)
iType = 2;
DoNoclip(client, iType);
return Plugin_Handled;
}
void DoNoclip(int client, int iType)
{
switch (iType)
{
case 0:
{
if (IsPlayerAlive(client))
{
SetClientNoClip(client, client);
}
}
case 1:
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
{
SetClientNoClip(client, i);
}
}
}
case 2:
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
{
SetClientNoClip(client, i);
}
}
}
}
}
void SetClientNoClip(int client, int iTarget)
{
MoveType movetype = GetEntityMoveType(iTarget);
if (movetype != MOVETYPE_NOCLIP)
{
SetEntityMoveType(iTarget, MOVETYPE_NOCLIP);
Print(client, "[DevMenu] 开启穿墙模式: %N", iTarget);
}
else
{
SetEntityMoveType(iTarget, MOVETYPE_WALK);
Print(client, "[DevMenu] 关闭穿墙模式: %N", iTarget);
}
}
void Teleport_TypeSelect(int client)
{
Menu menu = new Menu(Teleport_TypeSelect_MenuHandler);
menu.SetTitle("选择传送类型:");
menu.AddItem("", "传送幸存者到自己");
menu.AddItem("", "传送特感到自己");
menu.AddItem("", "所有幸存者到安全屋");
menu.ExitBackButton = true;
menu.Display(client, MENU_TIME_FOREVER);
}
int Teleport_TypeSelect_MenuHandler(Menu menu, MenuAction action, int client, int itemNum)
{
switch (action)
{
case MenuAction_Select:
{
switch (itemNum)
{
case 0, 1, 2: DoTeleport(client, itemNum);
}
Teleport_TypeSelect(client);
}
case MenuAction_Cancel:
{
if (itemNum == MenuCancel_ExitBack)
g_TopMenu.Display(client, TopMenuPosition_LastCategory);
}
case MenuAction_End:
{
delete menu;
}
}
return 0;
}
Action Cmd_Teleport(int client, int args)
{
if (args != 1 && args != 3)
{
ReplyToCommand(client, "sm_tele <sur|si|saferoom> | sm_tele <pos0 pos1 pos2>");
return Plugin_Handled;
}
if (args == 1)
{
int iType = -1;
char sTarget[32];
GetCmdArg(1, sTarget, sizeof(sTarget));
if (strcmp(sTarget, "sur", false) == 0)
iType = 0;
else if (strcmp(sTarget, "si", false) == 0)
iType = 1;
else if (strcmp(sTarget, "saferoom", false) == 0)
iType = 2;
DoTeleport(client, iType);
}
else if (args == 3)
{
float fPos[3];
fPos[0] = GetCmdArgFloat(1);
fPos[1] = GetCmdArgFloat(2);
fPos[2] = GetCmdArgFloat(3);
TeleportEntity(client, fPos, NULL_VECTOR, NULL_VECTOR);
Print(client, "[DevMenu] 传送自己到: %f %f %f", fPos[0], fPos[1], fPos[2]);
}
return Plugin_Handled;
}
void DoTeleport(int client, int iType)
{
float fPos[3];
GetClientAbsOrigin(client, fPos);
switch (iType)
{
case 0:
{
for (int i = 1; i <= MaxClients; i++)
{
if (i != client && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
{
TeleportEntity(i, fPos, NULL_VECTOR, NULL_VECTOR);
Print(client, "[DevMenu] 传送幸存者到自己");
}
}
}
case 1:
{
for (int i = 1; i <= MaxClients; i++)
{
if (i != client && IsClientInGame(i) && GetClientTeam(i) == 3 && IsPlayerAlive(i))
{
TeleportEntity(i, fPos, NULL_VECTOR, NULL_VECTOR);
Print(client, "[DevMenu] 传送特感到自己");
}
}
}
case 2:
{
CheatCommand(client, "warp_all_survivors_to_checkpoint");
Print(client, "[DevMenu] 传送所有幸存者到安全屋");
}
}
}
void GiveItem_TypeSelect(int client)
{
Menu menu = new Menu(GiveItem_TypeSelect_MenuHandler);
menu.SetTitle("选择物品类型:");
menu.AddItem("", "武器");
menu.AddItem("", "近战"); // 需要近战解锁插件
menu.AddItem("", "医疗和投掷");
menu.AddItem("", "其他");
menu.ExitBackButton = true;
menu.Display(client, MENU_TIME_FOREVER);
}
int GiveItem_TypeSelect_MenuHandler(Menu menu, MenuAction action, int client, int itemNum)
{
switch (action)
{
case MenuAction_Select:
{
g_iGiveItemType[client] = itemNum;
GiveItem_Select(client);
}
case MenuAction_Cancel:
{
if (itemNum == MenuCancel_ExitBack)
g_TopMenu.Display(client, TopMenuPosition_LastCategory);
}
case MenuAction_End:
{
delete menu;
}
}
return 0;
}
void GiveItem_Select(int client)
{
Menu menu = new Menu(GiveItem_Select_MenuHandler);
switch (g_iGiveItemType[client])
{
case 0:
{
menu.SetTitle("产生武器:");
for (int i = 0; i < sizeof(g_sWeapons); i++)
{
menu.AddItem(g_sWeapons[i][ITEM_NAME], g_sWeapons[i][ITEM_DISPLAY]);
}
}
case 1:
{
menu.SetTitle("产生近战:");
for (int i = 0; i < sizeof(g_sMelees); i++)
{
menu.AddItem(g_sMelees[i][ITEM_NAME], g_sMelees[i][ITEM_DISPLAY]);
}
}