-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsm_dev_cmds.sp
More file actions
5407 lines (4583 loc) · 163 KB
/
sm_dev_cmds.sp
File metadata and controls
5407 lines (4583 loc) · 163 KB
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
/*
* Dev Cmds
* Copyright (C) 2026 Silvers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#define PLUGIN_VERSION "1.54"
/*=======================================================================================
Plugin Info:
* Name : [ANY] Dev Cmds
* Author : SilverShot
* Descrp : Provides a heap of commands for admins/developers to use.
* Link : https://forums.alliedmods.net/showthread.php?t=187566
* Plugins : https://sourcemod.net/plugins.php?exact=exact&sortby=title&search=1&author=Silvers
========================================================================================
Change Log:
1.54 (14-Mar-2026)
- Added command "sm_setdmg" to apply specific damage to an entity.
1.53 (17-Feb-2026)
- L4D/2: Added command "sm_temp" to set temporary health on a player.
- Fixed throwing errors for games which have no "m_iHammerID". Thanks to "caxanga334" for reporting.
1.52 (22-Sep-2024)
- Changed commands "sm_setang", "sm_setpos", "sm_tele" and "sm_tel" to allow placing "?" in any given XYZ vector to ignore and use the current targets value. Requested by "Tonblader".
1.51 (17-Jun-2024)
- Fixed command "sm_weapons" showing your own held weapon, instead of the targets.
1.50 (05-Mar-2024)
- Added a few more "m_h*" variables to read the entity index instead of reference number. Probably only for L4D/2 series.
1.49 (22-Nov-2023)
- Added command "sm_delents" to delete entities of a certain classnames. Allows using * wildcard to match various entities for example "weapon_*" can be used.
- Changed command "sm_near" to also show the targetname.
1.48 (19-Feb-2023)
- Added command "sm_hexcols" to print a list of hex colors to chat. Requested by "Marttt".
1.47 (10-Jan-2023)
- Added command "sm_gamerules" to read/write to the gamerules proxy.
- Added support for reading/writing to GameRules. Thanks to "Marttt" for the initial code. Requested by "caxanga334".
- Plugin now requires SourceMod 1.11 or newer. Using some natives that only appear in SM 1.11.
1.46 (28-Oct-2022)
- Added command "sm_vertex" to display the vecMins and vecMaxs of an entity.
- Fixed command "sm_listens" to displaying full details.
- L4D1/2: Fixed "sm_zspawnv" not pre-caching Special Infected models, also validates model paths and attempts to cache unknown ones. Thanks to "Tonblader" for reporting.
1.45 (10-Aug-2022)
- Changed command "sm_del" to no longer delete clients.
1.44 (17-Jul-2022)
- Fixed compile warnings on SM 1.11 when using SMLib.
1.43 (16-Jul-2022)
- Changed "sm_prop*" commands to allow editing members elements for example "m_iAmmo.005" to modify element array 005. Requested by "Sreaper".
- Added list of known entity property keys to better get or set their values.
1.42 (01-Aug-2022)
- Fixed command "sm_clients" throwing an error if a client was not in game.
1.41 (24-Jun-2022)
- Fixed command "sm_playtime" not showing playtime when the server is empty.
1.40 (24-Jun-2022)
- Fixed command "sm_playtime" sometimes breaking and not showing any playtime.
1.39 (20-Jun-2022)
- Added command "sm_playtime" to show how long players have been playing.
- Changed command "sm_clients" formatting to be clearer.
1.38 (09-Jun-2022)
- Added command "sm_changes" to show how many map changes have occurred.
1.37 (03-Jun-2022)
- Fixed command "sm_uptime" not displaying the correct time.
1.36 (03-Jun-2022)
- Changed the method for the command "sm_uptime" to show since the plugin was loaded since GetGameTime() resets to 0.0 on map change.
1.35 (01-Jun-2022)
- Added command "sm_aimpos" to get the vector position where the crosshair is aiming.
- Added command "sm_uptime" to display how long the server has been up. Thanks to "Impact123" for the code: https://forums.alliedmods.net/showthread.php?t=182012
1.34 (10-May-2022)
- Reverted command "sm_prop*" to before last update, removing the "m_h" check in the keynames, due to breaking non-entity fields.
1.33 (25-Apr-2022)
- Changed commands "sm_prop*" to get or set entity indexes which contain "m_h" in the keyname. Requested by "Sreaper".
- Changed command "sm_users" to count the last UserID better.
1.32 (10-Apr-2022)
- Changed command "sm_ent" to allow aiming at clients. Requested by "Sreaper".
- Changed command "sm_weapons" to include the currently held object/item/weapon.
1.31 (14-Dec-2021)
- Added command "sm_users" to report total bots and clients that connected and the last UserID index.
- Changed command "sm_listens" to output more information about sounds. Thanks to "Marttt" for writing.
1.30 (23-Nov-2021)
- Blocked various in-game commands from being used on the server.
- Changed various commands to use "ReplyToCommand". Requested by "Dragokas".
1.29 (10-Nov-2021)
- Added command "sm_viewmodel" to return a clients viewmodel entity index.
- Changed command "sm_attachments" to display attachments on entities. Requested by "Marttt".
- Fixed command "sm_dele" crashing the server when no entity was provided. Thanks to "Marttt" for reporting.
1.28 (06-Nov-2021)
- Fixed possible invalid entity when using "sm_propent". Thanks to "Shku" for reporting.
1.27 (04-Nov-2021)
- Added command "sm_rngc" to randomly execute specified commands if the chance is met, client command. Requested by "Tonblader".
- Added command "sm_rngf" to randomly execute specified commands if the chance is met, fake client command. Requested by "Tonblader".
- Added command "sm_rngs" to randomly execute specified commands if the chance is met, server command. Requested by "Tonblader".
- Added command "sm_wearables" for TF2 to list a players cosmetic items. Requested by "Shku".
- Changed "sm_propent" to accept target filters. Thanks to "Maliwolf" for coding.
1.26 (27-Oct-2021)
- Added command "sm_tele" to teleport clients to aim position or specific vector. Requested by "Dragokas".
- Added command "sm_collision" to toggle collision on a specified entity. Requested by "canadianjeff". Thanks to "Dragokas" for the stock.
- Added commands "sm_solid" and "sm_solidf" to return the solid type and solid flags from a value.
- L4D1 & L4D2: Changed command "sm_nospawn" to block common spawning. Thanks to "Dragokas" for reporting.
1.25 (13-Sep-2021)
- Added command "sm_getspeed" to return a players current speed value.
- Added command "sm_listens" to toggle printing all sounds being played.
- Added command "sm_delweps" to delete weapons from yourself or the targeted clients.
- Added command "sm_bringents" to teleport specified entities by classname to around the player.
- L4D2: Added command "sm_sc" to change the gamemode to Scavenge.
1.24 (06-Sep-2021)
- Added command "sm_attachments" to display all attachments on a specific client.
- Added command "sm_emit" to play a sound from your client.
1.23 (11-Aug-2021)
- Added commands "sm_bit" and "sm_val" to get and return values from: "1<<20" to "1048576" and "1048577" to "(1<<0); (1<<20)" for example.
- Added command "sm_dmg" to return SDKHooks damage flags from a value. For example "sm_dmg 9" returns "DMG_CRUSH (1<<0); DMG_BURN (1<<3)".
- Added command "sm_adm" to toggle between ROOT and BAN admin flags (or specified target flags). Requires ROOT to work. e.g: "sm_adm BAN KICK".
- Changed command "sm_anim" to watch sequence numbers on every frame and display only when they change, until toggled off.
1.22 (29-Jul-2021)
- L4D1 & L4D2: Changed command "sm_zspawnv" to accept a skin parameter for the models.
1.21 (25-Jul-2021)
- L4D1 & L4D2: Changed command "sm_zspawnv" to accept the modelname. This does not precache the model and a server crash possible for non-cached models. Requested by "Tonblader".
- Usage: "sm_zspawnv boomer posX posY posZ modelname" or "sm_zspawnv boomer posX posY posZ andX angY andZ modelname". Modelname is optional.
1.20 (22-Jul-2021)
- L4D1 & L4D2: Fixed command "sm_zspawnv" not spawning in the correct direction. Thanks to "Tonblader" for reporting.
1.19 (05-Jul-2021)
- L4D1 & L4D2: Added command "sm_bots" to spawn a Survivor bot.
1.18 (04-Jul-2021)
- Removed requirement of being alive for some commands: "sm_ccmd", "sm_fcmd", "sm_nv", "sm_ledge". Thanks to "noto3" for reporting.
1.17 (01-Jul-2021)
- L4D1 and L4D2: Added command "sm_zspawnv" to spawn infected and special infected specifying pos and ang. Requested by "Tonblader" and "nataa123".
1.16 (16-Jun-2021)
- Changed commands "sm_setang", "sm_setpos", "sm_tel" and "sm_viewr" and set speed to 0 on teleport. Requested by "Tonblader".
1.15 (15-Feb-2021)
- Changed "sm_count" to accept a classname to search for. Requested by "canadianjeff".
1.14 (30-Sep-2020)
- Fixed compile errors on SM 1.11.
1.13 (20-Sep-2020)
- Added command "sm_setpos" to set target(s) origin position. Requested by "Tonblader".
- Fixed command "sm_cheats" not working in all games.
- Increased model string length for "sm_ent" and "sm_ente" commands.
1.12 (07-Jun-2020)
- Added command "sm_setang" to set target(s) view angles. Requested by "Tonblader".
1.11 (10-May-2020)
- Various changes to tidy up code.
1.10 (25-Mar-2020)
- Changed "sm_range" to add an optional arg for specifying an entity.
- Fixed command "sm_cheats" not toggling "sv_cheats".
- Some text changes from previously added commands.
1.9 (19-Mar-2020)
Update with changes provided by "Dragokas":
- Added command "sm_ice" to freeze any client/entity from moving.
- Changed command "sm_anim" to allow getting the sequence for a specified entity.
- Fixed command "sm_stopang" from not repeating.
- Fixed commands "sm_halt", "sm_hold" and "sv_cheats" from not accurately detecting the cvar setting being changed.
1.8 (02-Mar-2020)
Update by "Dragokas":
- Appended "sm_find" <classname> <maxdist> (2nd argument filters entities located in specified radius).
- Added command "sm_damage" <client> - to track damage info dealt to this client or by this client. Use -1 or empty to track everybody.
- (L4D & L4D2) Added command "sm_nospawn" to prevent all types of infected from spawning.
- (L4D & L4D2) Added command "sm_slayall" to slay all common and special infected and witches.
Update by "Silvers":
- Added command "sm_scmd" to execute a server command.
- Changed command "sm_count" to work better and sort the classnames list.
1.7 (02-Nov-2019)
- Fixed copy paste error preventing the plugin from compiling. Thanks to "eyal282" for reporting.
1.6 (01-Nov-2019)
- Changed "sm_input", "sm_inputent" and "sm_inputme" to accept activator and caller params.
- Fixed commands "sm_ledge", "sm_spit" and "sm_nv" failing with ProcessTargetString. Thanks to "Marttt".
1.5 (30-Oct-2019)
- Added command "sm_clients" to list client indexes/userids and some other data.
- Added command "sm_weapons" to list your own weapons or that of the target you're aiming at or specified index by command arg.
- Added command "sm_range" to find how far away an object is.
- Added command "sm_near" to list nearby object classnames.
- Added various vector commands provided by "Dragokas": "sm_dist", "sm_distdir", "sm_distfloor", "sm_distroof", "sm_size", "sm_sizee".
- Changed "sm_ent" and "sm_ente" to add more info. Provided by "Marttt".
- Changed "sm_box" laser outlines to use smlib draw box with correct angles matrix rotation. Provided by "disawar1".
- The "sm_box" changes work when the smlib include is present, or defaults to old version, no edits required.
- Various fixes and changes.
1.4.1 (28-Jun-2019)
- Changed PrecacheParticle method.
1.4 (01-Jun-2019)
- Added "sm_anim" to show your players animation sequence number (for 6 * 0.5 seconds).
- Changed "sm_tel" to also accept angles when teleporting.
- Changed "sm_ente" to work from the server console.
1.3 (05-May-2018)
- Converted plugin source to the latest syntax utilizing methodmaps. Requires SourceMod 1.8 or newer.
1.2 (09-Aug-2013)
- Reverted the change to "sm_alloff".
- Changed "sm_fcmd" to allow command arguments, Usage: sm_fcmd <#userid|name> <command> [args].
1.1 (22-Jun-2012)
- Added "sm_findname" to list entities by matching a partial targetname.
- Changed "sm_modlist" to save the file as "models_mapname.txt".
- Changed "sm_input", "sm_inputent" and "sm_inputme" to accept parameters.
- Changed "sm_alloff" to not toggle the director or sb_hold_position.
- Fixed "sm_find" throwing errors for non-networked entities.
1.0 (15-Jun-2012)
- Initial release.
========================================================================================
This plugin was made using source code from the following plugins.
If I have used your code and not credited you, please let me know.
* Thanks to "Don't Fear The Reaper" - For the sm_slaycommon and sm_slaywitches code.
======================================================================================*/
#tryinclude <smlib> // SMLIB - for sm_box. Before newdecls incase using old syntax style.
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#define MAX_OUTPUTS 32
#define RED {255, 0, 0, 255}
#define GREEN {0, 255, 0, 255}
#define BLUE {0, 0, 255, 255}
#if !defined _smlib_included
// Taken from smlib
enum
{
FSOLID_CUSTOMRAYTEST = 0x0001, // Ignore solid type + always call into the entity for ray tests
FSOLID_CUSTOMBOXTEST = 0x0002, // Ignore solid type + always call into the entity for swept box tests
FSOLID_NOT_SOLID = 0x0004, // Are we currently not solid?
FSOLID_TRIGGER = 0x0008, // This is something may be collideable but fires touch functions
// even when it's not collideable (when the FSOLID_NOT_SOLID flag is set)
FSOLID_NOT_STANDABLE = 0x0010, // You can't stand on this
FSOLID_VOLUME_CONTENTS = 0x0020, // Contains volumetric contents (like water)
FSOLID_FORCE_WORLD_ALIGNED = 0x0040, // Forces the collision rep to be world-aligned even if it's SOLID_BSP or SOLID_VPHYSICS
FSOLID_USE_TRIGGER_BOUNDS = 0x0080, // Uses a special trigger bounds separate from the normal OBB
FSOLID_ROOT_PARENT_ALIGNED = 0x0100, // Collisions are defined in root parent's local coordinate space
FSOLID_TRIGGER_TOUCH_DEBRIS = 0x0200, // This trigger will touch debris objects
FSOLID_MAX_BITS = 10
};
enum
{
SOLID_NONE = 0, // no solid model
SOLID_BSP = 1, // a BSP tree
SOLID_BBOX = 2, // an AABB
SOLID_OBB = 3, // an OBB (not implemented yet)
SOLID_OBB_YAW = 4, // an OBB, constrained so that it can only yaw
SOLID_CUSTOM = 5, // Always call into the entity for tests
SOLID_VPHYSICS = 6, // solid vphysics object, get vcollide from the model and collide with that
SOLID_LAST,
};
#endif
float g_vSavedPos[3];
bool g_bFirst = true;
int g_sprite;
bool g_bLateLoad, g_bDirector = true, g_bAll, g_bNB, g_bNospawn, g_bDamage;
int g_iGAMETYPE, g_iEntsSpit[MAXPLAYERS], g_iLedge[MAXPLAYERS], g_iDamageRequestor, g_iTotalBots, g_iTotalPlays, g_iLastUserID, g_iGameTime, g_iPlayers, g_iPlayTime, g_iPlayedTime, g_iMapChanges;
float g_vAng[MAXPLAYERS+1][3], g_vPos[MAXPLAYERS+1][3];
ConVar sb_hold_position, sb_stop, sv_cheats, mp_gamemode, z_background_limit, z_boomer_limit, z_charger_limit, z_common_limit, z_hunter_limit, z_jockey_limit, z_minion_limit, z_smoker_limit, z_spitter_limit, director_no_bosses, director_no_mobs, director_no_specials;
int g_iHaloIndex, g_iLaserIndex, g_iOutputs[MAX_OUTPUTS][2];
char g_sOutputs[MAX_OUTPUTS][64];
StringMap g_hEntityKeys;
EngineVersion g_iEngine;
char g_sGameRulesNet[32], g_sGameRulesClass[32];
// Precache models for spawning (L4D1/2)
static const char g_sModels1[][] =
{
"models/infected/witch.mdl",
"models/infected/hulk.mdl",
"models/infected/smoker.mdl",
"models/infected/boomer.mdl",
"models/infected/hunter.mdl"
};
static const char g_sModels2[][] =
{
"models/infected/witch_bride.mdl",
"models/infected/spitter.mdl",
"models/infected/jockey.mdl",
"models/infected/charger.mdl"
};
enum
{
GAME_ANY = 1,
GAME_L4D,
GAME_L4D2,
GAME_CSS,
GAME_TF2
}
// ====================================================================================================
// PLUGIN INFO / START / END
// ====================================================================================================
public Plugin myinfo =
{
name = "[ANY] Dev Cmds",
author = "SilverShot",
description = "Provides a heap of commands for admins/developers to use.",
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/showthread.php?t=187566"
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
EngineVersion test = GetEngineVersion();
switch( test )
{
case Engine_CSS: g_iGAMETYPE = GAME_CSS;
case Engine_CSGO: g_iGAMETYPE = GAME_CSS;
case Engine_Left4Dead: g_iGAMETYPE = GAME_L4D;
case Engine_Left4Dead2: g_iGAMETYPE = GAME_L4D2;
case Engine_TF2: g_iGAMETYPE = GAME_TF2;
default: g_iGAMETYPE = GAME_ANY;
}
g_bLateLoad = late;
g_iEngine = test;
return APLRes_Success;
}
public void OnPluginStart()
{
CreateConVar("sm_dev_cmds", PLUGIN_VERSION, "Dev Cmds plugin version.", FCVAR_NOTIFY|FCVAR_DONTRECORD);
// Commands
RegAdminCmd("sm_refresh", CmdRefresh, ADMFLAG_ROOT, "Refresh plugins (same as 'sm plugins refresh').");
RegAdminCmd("sm_renew", CmdRenew, ADMFLAG_ROOT, "Unload and Refresh plugins (same as 'sm plugins unload_all; sm plugins refresh').");
RegAdminCmd("sm_unload", CmdUnload, ADMFLAG_ROOT, "Unload all plugins (same as 'sm plugins unload_all').");
RegAdminCmd("sm_round", CmdRound, ADMFLAG_ROOT, "Executes 'mp_restartgame 1' to restart round.");
RegAdminCmd("sm_cheats", CmdCheats, ADMFLAG_ROOT, "Toggles sv_cheats.");
RegAdminCmd("sm_logit", CmdLogIt, ADMFLAG_ROOT, "<text>. Logs specified text to 'sourcemod/logs/sm_logit.txt'.");
RegAdminCmd("sm_gametime", CmdGameTime, ADMFLAG_ROOT, "Displays the GetGameTime() float.");
RegAdminCmd("sm_uptime", CmdUpTime, ADMFLAG_ROOT, "Displays how long the server has been up. Maybe inaccurate if server hibernation is active.");
RegAdminCmd("sm_playtime", CmdPlayTime, ADMFLAG_ROOT, "Displays how long players have been playing on the server.");
RegAdminCmd("sm_changes", CmdChanges, ADMFLAG_ROOT, "Displays how many map changes have occurred.");
RegAdminCmd("sm_createent", CmdCreateEnt, ADMFLAG_ROOT, "<classname>. Creates and removes the entity classname, reports success.");
RegAdminCmd("sm_cv", CmdCV, ADMFLAG_ROOT, "<cvar> [value]. Get/Set cvar value without the notify flag.");
RegAdminCmd("cv", CmdCV, ADMFLAG_ROOT, "<cvar> [value]. Get/Set cvar value without the notify flag.");
RegAdminCmd("sm_e", CmdECheat, ADMFLAG_ROOT, "<command> [args]. Executes a cheat command.");
RegAdminCmd("e", CmdECheat, ADMFLAG_ROOT, "<command> [args]. Executes a cheat command.");
RegAdminCmd("sm_ccmd", CmdCCmd, ADMFLAG_ROOT, "<#userid|name> <command> [args]. Executes a client command on the target you specify.");
RegAdminCmd("sm_fcmd", CmdFCmd, ADMFLAG_ROOT, "<#userid|name> <command> [args]. Executes a fake client command on the target you specify.");
RegAdminCmd("sm_scmd", CmdSCmd, ADMFLAG_ROOT, "Executes a server command.");
RegAdminCmd("sm_rngc", CmdRngC, ADMFLAG_ROOT, "<0-100> <command string> chance out of 100 to execute the command string, client command.");
RegAdminCmd("sm_rngf", CmdRngF, ADMFLAG_ROOT, "<0-100> <command string> chance out of 100 to execute the command string, fake client command.");
RegAdminCmd("sm_rngs", CmdRngS, ADMFLAG_ROOT, "<0-100> <command string> chance out of 100 to execute the command string, server command.");
RegAdminCmd("sm_views", CmdViewS, ADMFLAG_ROOT, "Saves your current position and eye angles.");
RegAdminCmd("sm_viewr", CmdViewR, ADMFLAG_ROOT, "Teleports you to the saved position and eye angles.");
RegAdminCmd("sm_pos", CmdPosition, ADMFLAG_ROOT, "Displays your position vector.");
RegAdminCmd("sm_aimpos", CmdAimPos, ADMFLAG_ROOT, "Displays the position vector where your crosshair is aiming.");
RegAdminCmd("sm_setang", CmdSetAng, ADMFLAG_ROOT, "<#userid|name> <vector ang>. Teleport someone to the x y z angles vector specified. Place ? to ignore an XYZ vector and use the targets current value.");
RegAdminCmd("sm_setpos", CmdSetPos, ADMFLAG_ROOT, "<#userid|name> <vector pos>. Teleport someone to the x y z origin vector specified. Place ? to ignore an XYZ vector and use the targets current value.");
RegAdminCmd("sm_bringents", CmdBring, ADMFLAG_ROOT, "<classname> [distance: (default 50)]. Teleport specified entities by classname to around the player. e.g. sm_bringents weapon_rifle.");
RegAdminCmd("sm_tele", CmdTele, ADMFLAG_ROOT, "<#userid|name> [x y z vector pos]. Teleport specified targets to aim location or to the x y z origin vector specified. Place ? to ignore an XYZ vector and use the targets current value.");
RegAdminCmd("sm_tel", CmdTeleport, ADMFLAG_ROOT, "<vector pos> [vector ang]. Teleport yourself to the x y z vector specified. Place ? to ignore an XYZ vector and use the targets current value.");
RegAdminCmd("sm_range", CmdRange, ADMFLAG_ROOT, "[entity] Shows how far away an object is that you're aiming at, or optional arg to specify an entity index.");
RegAdminCmd("sm_near", CmdNear, ADMFLAG_ROOT, "Lists all nearby entities within the specified range. Usage sm_near: [range].");
RegAdminCmd("sm_dist", CmdDist, ADMFLAG_ROOT, "Enter twice to measure distance between the origins you stand on.");
RegAdminCmd("sm_distdir", CmdDistDir, ADMFLAG_ROOT, "Get distance between you and end point of direction you are looking at (considering collision).");
RegAdminCmd("sm_distfloor", CmdDistFloor, ADMFLAG_ROOT, "Get distance between you and floor below you (considering collision).");
RegAdminCmd("sm_distroof", CmdDistRoof, ADMFLAG_ROOT, "Get distance between you and roof above your head (considering collision).");
RegAdminCmd("sm_size", CmdSizeMe, ADMFLAG_ROOT, "Get sizes (Width, Length, Height) of your player.");
RegAdminCmd("sm_sizee", CmdSizeTarget, ADMFLAG_ROOT, "Get sizes (Width, Length, Height) of the entity you are looking at.");
RegAdminCmd("sm_del", CmdDel, ADMFLAG_ROOT, "Deletes the entity your crosshair is over.");
RegAdminCmd("sm_dele", CmdDelE, ADMFLAG_ROOT, "<entity>. Deletes the entity you specify.");
RegAdminCmd("sm_delents", CmdDelEnts, ADMFLAG_ROOT, "<classname> Delete all the entities of a specific classname.");
RegAdminCmd("sm_ent", CmdEnt, ADMFLAG_ROOT, "Displays info about the entity your crosshair is over.");
RegAdminCmd("sm_ente", CmdEntE, ADMFLAG_ROOT, "<entity>. Displays info about the entity you specify.");
RegAdminCmd("sm_vertex", CmdVertex, ADMFLAG_ROOT, "[entity]. Displays vMaxs and vMins bounding box about the specified entity or aimed at entity.");
RegAdminCmd("sm_box", CmdBox, ADMFLAG_ROOT, "[entity]. Displays a beam box around the specified entity or aimed at entity for 10 seconds.");
RegAdminCmd("sm_find", CmdFind, ADMFLAG_ROOT, "<classname> List entity indexes from the given classname.");
RegAdminCmd("sm_findname", CmdFindName, ADMFLAG_ROOT, "<targetname> List entity indexes from a partial targetname.");
RegAdminCmd("sm_count", CmdCount, ADMFLAG_ROOT, "Displays a list of all spawned entity classnames and count. Optional sm_count <classname>");
RegAdminCmd("sm_modlist", CmdModList, ADMFLAG_ROOT, "Saves a list of all the models used on the current map to 'sourcemod/logs/models_<MAPNAME>.txt'.");
RegAdminCmd("sm_collision", CmdColli, ADMFLAG_ROOT, "[entity] Toggles collision on the aimed entity or specified entity index.");
RegAdminCmd("sm_movetype", CmdMoveType, ADMFLAG_ROOT, "[entity] Set the MoveType of an entity.");
RegAdminCmd("sm_anim", CmdAnim, ADMFLAG_ROOT, "[sequence]. Show aimed entities animation sequence number until toggled again or your own if not aimed at entity. Optionally, it can set sequence. Checks every frame and reports changes.");
RegAdminCmd("sm_weapons", CmdWeapons, ADMFLAG_ROOT, "[client index]. Lists players weapons and indexes. Either yourself, or aim target or optional index via cmd args.");
if( g_iGAMETYPE == GAME_TF2 )
RegAdminCmd("sm_wearables", CmdWearables, ADMFLAG_ROOT, "[client index]. Lists players cosmetics indexes and definitions. Either yourself with no args, or aim target or optional index via cmd args.");
RegAdminCmd("sm_attachments", CmdAttachments, ADMFLAG_ROOT, "[#userid|name] or [entity index] Displays a list of attachments on the specified clients. No args = self.");
RegAdminCmd("sm_viewmodel", CmdViewmodel, ADMFLAG_ROOT, "[#userid|name] returns a clients viewmodel entity index, or no args = self.");
RegAdminCmd("sm_delweps", CmdDelWeps, ADMFLAG_ROOT, "[#userid|name] delete weapons from targeted clients, or no args = self.");
RegAdminCmd("sm_getspeed", CmdSpeed, ADMFLAG_ROOT, "<#userid|name> Get the speed of the specified clients.");
RegAdminCmd("sm_clients", CmdClients, ADMFLAG_ROOT, "Lists client indexes/userids and some other data.");
RegAdminCmd("sm_users", CmdUsers, ADMFLAG_ROOT, "Prints the total amount of bots and clients who had connected and the last UserID to have connected.");
RegAdminCmd("sm_ice", CmdFreeze, ADMFLAG_ROOT, "[entity]. Freeze / unfreeze aim target or specified entity.");
RegAdminCmd("sm_damage", CmdDamage, ADMFLAG_ROOT, "<client index>. Track damage info deal to this client or by this client. -1 or empty to track everybody.");
RegAdminCmd("sm_solid", CmdSolid, ADMFLAG_ROOT, "<flags>. Returns the SolidType_t flags from a flag value.");
RegAdminCmd("sm_solidf", CmdSolidF, ADMFLAG_ROOT, "<flags>. Returns the SolidFlags_t flags from a flag value.");
RegAdminCmd("sm_dmg", CmdDmg, ADMFLAG_ROOT, "<flags>. Returns the SDKHooks DamageType from a flag value.");
RegAdminCmd("sm_setdmg", CmdSetDmg, ADMFLAG_ROOT, "<target index> <damage amount> [damage type enum] [inflictor index]. Deal damage to an entity");
RegAdminCmd("sm_val", CmdVal, ADMFLAG_ROOT, "<bit value>. e.g: sm_val 1<<20. Returns: 1048576");
RegAdminCmd("sm_bit", CmdBit, ADMFLAG_ROOT, "<bit value>. e.g: sm_bit 1048577. Returns: (1<<0); (1<<20)");
RegAdminCmd("sm_adm", CmdAdm, 0, "Toggles between ROOT and BAN admin flags, for testing stuff without ROOT access. Or specified flags e.g. Usage: sm_adm BAN KICK");
RegAdminCmd("sm_hexcols", CmdHexCol, ADMFLAG_ROOT, "Print a list of hex colors to chat.");
RegAdminCmd("sm_gamerules", CmdGameRules, ADMFLAG_ROOT, "<prop> [value] Affects the gamerules proxy. Can read or write to table members, prop.member: e.g. m_iChapterDamage.001");
RegAdminCmd("sm_prop", CmdProp, ADMFLAG_ROOT, "<prop> [value] Affects the entity you aim at. Can read or write to table members, prop.member: e.g. m_iChapterDamage.001");
RegAdminCmd("sm_propent", CmdPropEnt, ADMFLAG_ROOT, "<entity> or <#userid|name> <prop> [val] Affects the specified entity. Can read or write to table members, prop.member: e.g. m_iChapterDamage.001");
RegAdminCmd("sm_propself", CmdPropMe, ADMFLAG_ROOT, "<prop> [value] Affects yourself. Can read or write to table members, prop.member: e.g. m_iChapterDamage.001");
RegAdminCmd("sm_propi", CmdPropMe, ADMFLAG_ROOT, "<prop> [value] Affects yourself. Can read or write to table members, prop.member: e.g. m_iChapterDamage.001");
RegAdminCmd("sm_input", CmdInput, ADMFLAG_ROOT, "<input> [param] [activator] [caller] Makes the entity you're aiming at accept an Input. Optionally give a param, e.g. sm_input color '255 0 0'.");
RegAdminCmd("sm_inputent", CmdInputEnt, ADMFLAG_ROOT, "<entity|targetname> <input> [param] [activator] [caller] Makes the specified entity accept an Input. Optionally give a param, e.g. sm_inputent 5 color '255 0 0'.");
RegAdminCmd("sm_inputme", CmdInputMe, ADMFLAG_ROOT, "<input> [param] [activator] [caller] Makes you accept an entity Input. Optionally give a param, e.g. sm_inputme color '255 0 0'.");
RegAdminCmd("sm_output", CmdOutput, ADMFLAG_ROOT, "<output> Watches the specified output on the entity aimed at.");
RegAdminCmd("sm_outputent", CmdOutputEnt, ADMFLAG_ROOT, "<entity> <output> Watches the specified entity and specified output.");
RegAdminCmd("sm_outputme", CmdOutputMe, ADMFLAG_ROOT, "<output> Watches the specified output on yourself.");
RegAdminCmd("sm_outputstop", CmdOutputStop, ADMFLAG_ROOT, "Stops watching all entity outputs.");
RegAdminCmd("sm_emit", CmdEmit, ADMFLAG_ROOT, "<sound path and filename> Plays a sound from your client. For testing sounds.");
RegAdminCmd("sm_listens", CmdListen, ADMFLAG_ROOT, "Toggle to start/stop listening to sounds being played. Displays messages in chat to everyone.");
RegAdminCmd("sm_watchents", CmdWatchEnts, ADMFLAG_ROOT, "Toggle to watch which entities are being spawned.");
RegAdminCmd("sm_newbot", CmdBot, ADMFLAG_ROOT, "Create new bot client.");
RegAdminCmd("sm_part", CmdPart, ADMFLAG_ROOT, "<name> Displays a particle you specify. Automatically removed after 5 seconds.");
RegAdminCmd("sm_parti", CmdPart2, ADMFLAG_ROOT, "<name> Displays a particle where you are pointing. Automatically removed after 5 seconds.");
if( g_iGAMETYPE == GAME_L4D || g_iGAMETYPE == GAME_L4D2 )
{
RegAdminCmd("sm_lobby", CmdLobby, 0, "Starts a vote return to lobby.");
RegAdminCmd("sm_ledge", CmdLedge, ADMFLAG_ROOT, "Enables/Disables ledge hanging.");
RegAdminCmd("sm_spit", CmdSpit, ADMFLAG_ROOT, "[#userid|name] Toggles spitter goo dribble on self (with no args) or specified targets.");
RegAdminCmd("sm_temp", CmdTemp, ADMFLAG_ROOT, "<#userid|name> <amount> Set temporary health on a client.");
RegAdminCmd("sm_alloff", CmdAll, ADMFLAG_ROOT, "Toggles - AI director on/off, z_common_limit, sb_hold.");
RegAdminCmd("sm_director", CmdDirector, ADMFLAG_ROOT, "Toggles - AI director on/off.");
RegAdminCmd("sm_hold", CmdHold, ADMFLAG_ROOT, "Toggles sb_hold - Stop the survivor bots moving but allows them to shoot.");
RegAdminCmd("sm_halt", CmdHalt, ADMFLAG_ROOT, "Toggles sb_stop - Stops the survivor bots from moving and shooting.");
RegAdminCmd("sm_nb", CmdNB, ADMFLAG_ROOT, "Toggles nb_stop - Stops all survivors/specifial infected from moving.");
RegAdminCmd("sm_nospawn", CmdNoSpawn, ADMFLAG_ROOT, "Prevents all types of infected from spawning");
RegAdminCmd("sm_zspawnv", CmdZSpawnV, ADMFLAG_ROOT, "Spawn infected and special infected specifying pos and ang. Usage sm_zspawnv <boomer|hunter|smoker|spitter|jockey|charger|tank|witch|infected> <pos X> <pos Y> <pos Z> ( [modelname] [skin] || [ang X] [ang Y] [ang Z] [modelname] [skin] ).");
RegAdminCmd("sm_bots", CmdBotsL4D, ADMFLAG_ROOT, "Creates a new Survivor bot.");
RegAdminCmd("sm_slayall", CmdSlayAll, ADMFLAG_ROOT, "Slays all common and special infected and witches");
RegAdminCmd("sm_slaycommon", CmdSlayCommon, ADMFLAG_ROOT, "Slays all common infected.");
RegAdminCmd("sm_slaywitches", CmdSlayWitches, ADMFLAG_ROOT, "Slays all witches.");
RegAdminCmd("sm_stopang", CmdStopAngle, ADMFLAG_ROOT, "Freeze current angle of all survivor bot players.");
RegAdminCmd("sm_c", CmdCoop, ADMFLAG_ROOT, "Sets the game mode to Coop.");
RegAdminCmd("sm_r", CmdRealism, ADMFLAG_ROOT, "Sets the game mode to Realism.");
RegAdminCmd("sm_s", CmdSurvival, ADMFLAG_ROOT, "Sets the game mode to Survival.");
RegAdminCmd("sm_v", CmdVersus, ADMFLAG_ROOT, "Sets the game mode to Versus.");
if( g_iGAMETYPE == GAME_L4D2 )
RegAdminCmd("sm_sc", CmdScavenge, ADMFLAG_ROOT, "Sets the game mode to Scavenge.");
sb_hold_position = FindConVar("sb_hold_position");
sb_stop = FindConVar("sb_stop");
mp_gamemode = FindConVar("mp_gamemode");
z_background_limit = FindConVar("z_background_limit");
z_common_limit = FindConVar("z_common_limit");
z_minion_limit = FindConVar("z_minion_limit");
director_no_bosses = FindConVar("director_no_bosses");
director_no_specials = FindConVar("director_no_specials");
director_no_mobs = FindConVar("director_no_mobs");
}
sv_cheats = FindConVar("sv_cheats");
if( g_iGAMETYPE == GAME_L4D2 )
{
z_boomer_limit = FindConVar("z_boomer_limit");
z_charger_limit = FindConVar("z_charger_limit");
z_hunter_limit = FindConVar("z_hunter_limit");
z_jockey_limit = FindConVar("z_jockey_limit");
z_smoker_limit = FindConVar("z_smoker_limit");
z_spitter_limit = FindConVar("z_spitter_limit");
}
if( g_iGAMETYPE == GAME_CSS || g_iGAMETYPE == GAME_L4D || g_iGAMETYPE == GAME_L4D2 )
{
RegAdminCmd("sm_nv", CmdNV, ADMFLAG_ROOT, "Toggles nightvision.");
}
if( g_iGAMETYPE == GAME_CSS )
{
RegAdminCmd("sm_bots", CmdBots, ADMFLAG_ROOT, "Opens a menu to spawn bots.");
RegAdminCmd("sm_money", CmdMoney, ADMFLAG_ROOT, "Opens a menu of players, sets 16000 money.");
}
// Translations
LoadTranslations("common.phrases");
// Events
HookEventEx("round_end", Event_RoundEnd, EventHookMode_PostNoCopy); // Only hooks if exists
// Other
g_iGameTime = GetTime();
if( g_bLateLoad )
{
for( int i = 1; i <= MaxClients; i++ )
{
if( IsClientInGame(i) && !IsFakeClient(i) )
{
g_iPlayTime = GetTime();
g_iPlayers++;
}
}
}
// Property Field stuff
g_hEntityKeys = new StringMap();
g_hEntityKeys.SetValue("moveparent", true);
g_hEntityKeys.SetValue("m_hActiveWeapon", true);
g_hEntityKeys.SetValue("m_hAttachedToEntity", true);
g_hEntityKeys.SetValue("m_hAttachEntity", true);
g_hEntityKeys.SetValue("m_hBuildableButtonUseEnt", true);
g_hEntityKeys.SetValue("m_hColorCorrectionCtrl", true);
g_hEntityKeys.SetValue("m_hConstraintEntity", true);
g_hEntityKeys.SetValue("m_hControlPointEnts", true);
g_hEntityKeys.SetValue("m_hEffectEntity", true);
g_hEntityKeys.SetValue("m_hElevator", true);
g_hEntityKeys.SetValue("m_hEntAttached", true);
g_hEntityKeys.SetValue("m_hGasNozzle", true);
g_hEntityKeys.SetValue("m_hGroundEntity", true);
g_hEntityKeys.SetValue("m_hLastWeapon", true);
g_hEntityKeys.SetValue("m_hMoveParent", true);
g_hEntityKeys.SetValue("m_hMyWeapons", true);
g_hEntityKeys.SetValue("m_hObserverTarget", true);
g_hEntityKeys.SetValue("m_holdingObject", true);
g_hEntityKeys.SetValue("m_hOwner", true);
g_hEntityKeys.SetValue("m_hOwnerEntity", true);
g_hEntityKeys.SetValue("m_hPlayer", true);
g_hEntityKeys.SetValue("m_hPlayerOwner", true);
g_hEntityKeys.SetValue("m_hPostProcessCtrl", true);
g_hEntityKeys.SetValue("m_hProps", true);
g_hEntityKeys.SetValue("m_hRagdoll", true);
g_hEntityKeys.SetValue("m_hScriptUseTarget", true);
g_hEntityKeys.SetValue("m_hStartPoint", true);
g_hEntityKeys.SetValue("m_hTargetEntity", true);
g_hEntityKeys.SetValue("m_hThrower", true);
g_hEntityKeys.SetValue("m_hTonemapController", true);
g_hEntityKeys.SetValue("m_hUseEntity", true);
g_hEntityKeys.SetValue("m_hVehicle", true);
g_hEntityKeys.SetValue("m_hViewEntity", true);
g_hEntityKeys.SetValue("m_hViewModel", true);
g_hEntityKeys.SetValue("m_hViewPosition", true);
g_hEntityKeys.SetValue("m_hWeapon", true);
g_hEntityKeys.SetValue("m_hZoomOwner", true);
g_hEntityKeys.SetValue("m_useActionTarget", true);
g_hEntityKeys.SetValue("m_useActionOwner", true);
g_hEntityKeys.SetValue("m_reviveTarget", true);
g_hEntityKeys.SetValue("m_reviveOwner", true);
g_hEntityKeys.SetValue("m_healTarget", true);
g_hEntityKeys.SetValue("m_survivor", true);
// GameRules net class name
switch( g_iEngine )
{
case Engine_AlienSwarm: g_sGameRulesNet = "CAlienSwarmProxy";
case Engine_BlackMesa: g_sGameRulesNet = "CBM_MP_GameRulesProxy";
case Engine_BloodyGoodTime: g_sGameRulesNet = "CPMGameRulesProxy";
case Engine_Contagion: g_sGameRulesNet = "CTerrorGameRulesProxy";
case Engine_CSGO: g_sGameRulesNet = "CCSGameRulesProxy";
case Engine_CSS: g_sGameRulesNet = "CCSGameRulesProxy";
case Engine_DarkMessiah: g_sGameRulesNet = "CHL2MPGameRulesProxy";
case Engine_DODS: g_sGameRulesNet = "CDODGameRulesProxy";
case Engine_EYE: g_sGameRulesNet = "CHL2MPGameRulesProxy";
case Engine_HL2DM: g_sGameRulesNet = "CHL2MPGameRulesProxy";
case Engine_Insurgency: g_sGameRulesNet = "CINSRulesProxy";
case Engine_Left4Dead: g_sGameRulesNet = "CTerrorGameRulesProxy";
case Engine_Left4Dead2: g_sGameRulesNet = "CTerrorGameRulesProxy";
case Engine_NuclearDawn: g_sGameRulesNet = "CNuclearDawnRulesProxy";
case Engine_TF2: g_sGameRulesNet = "CTFGameRulesProxy";
}
switch( g_iEngine )
{
case Engine_AlienSwarm: g_sGameRulesClass = "asw_gamerules";
case Engine_BlackMesa: g_sGameRulesClass = "blackmesa_mp_gamerules";
case Engine_BloodyGoodTime: g_sGameRulesClass = "pm_gamerules";
case Engine_Contagion: g_sGameRulesClass = "contagion_gamerules";
case Engine_CSGO: g_sGameRulesClass = "cs_gamerules";
case Engine_CSS: g_sGameRulesClass = "cs_gamerules";
case Engine_DarkMessiah: g_sGameRulesClass = "hl2mp_gamerules";
case Engine_DODS: g_sGameRulesClass = "dod_gamerules";
case Engine_EYE: g_sGameRulesClass = "hl2mp_gamerules";
case Engine_HL2DM: g_sGameRulesClass = "hl2mp_gamerules";
case Engine_Insurgency: g_sGameRulesClass = "ins_gamerules";
case Engine_Left4Dead: g_sGameRulesClass = "terror_gamerules";
case Engine_Left4Dead2: g_sGameRulesClass = "terror_gamerules";
case Engine_NuclearDawn: g_sGameRulesClass = "nd_gamerules";
case Engine_TF2: g_sGameRulesClass = "tf_gamerules";
}
}
public void OnPluginEnd()
{
if( g_iGAMETYPE == GAME_L4D2 )
{
for( int i = 0; i <= MaxClients; i++ )
{
if( IsValidEntRef(g_iEntsSpit[i]) )
{
AcceptEntityInput(g_iEntsSpit[i], "ClearParent");
RemoveEntity(g_iEntsSpit[i]);
}
}
}
}
public void OnMapStart()
{
if( g_iGAMETYPE == GAME_L4D || g_iGAMETYPE == GAME_L4D2 )
{
g_bDirector = true;
g_bAll = false;
for( int i = 0; i < sizeof(g_sModels1); i++ )
PrecacheModel(g_sModels1[i]);
if( g_iGAMETYPE == GAME_L4D2 )
{
PrecacheParticle("spitter_slime_trail");
for( int i = 0; i < sizeof(g_sModels2); i++ )
PrecacheModel(g_sModels2[i]);
}
}
g_iLaserIndex = PrecacheModel("materials/sprites/laserbeam.vmt");
g_iHaloIndex = PrecacheModel("materials/sprites/halo01.vmt");
g_iMapChanges++;
}
Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
g_bFirst = true;
return Plugin_Continue;
}
bool g_bWatchEnts;
bool g_bWatchSpawn;
int g_iSpawned;
public void OnEntityCreated(int entity, const char[] classname)
{
if( g_bWatchEnts )
{
PrintToServer("%d %s", entity, classname);
PrintToChatAll("%d %s", entity, classname);
}
if( g_bNospawn )
{
if( strcmp(classname, "infected") == 0 )
{
SDKHook(entity, SDKHook_SpawnPost, OnSpawnCommon);
}
}
if( g_bWatchSpawn )
{
if(
strcmp(classname, "boomer") == 0 ||
strcmp(classname, "hunter") == 0 ||
strcmp(classname, "smoker") == 0 ||
strcmp(classname, "spitter") == 0 ||
strcmp(classname, "jockey") == 0 ||
strcmp(classname, "charger") == 0 ||
strcmp(classname, "tank") == 0 ||
strcmp(classname, "witch") == 0 ||
strcmp(classname, "infected") == 0
)
{
g_iSpawned = entity;
}
}
}
void OnSpawnCommon(int entity)
{
RemoveEntity(entity);
}
// ====================================================================================================
// COMMANDS - PLUGINS - sm_refresh, sm_reload, sm_unload
// ====================================================================================================
Action CmdRefresh(int client, int args)
{
ServerCommand("sm plugins refresh");
if( client ) PrintToChat(client, "\x04[Plugins Refreshed]");
else ReplyToCommand(client, "[Plugins Refreshed]");
return Plugin_Handled;
}
Action CmdRenew(int client, int args)
{
ServerCommand("sm plugins unload_all; sm plugins refresh");
if( client ) PrintToChat(client, "\x04[Plugins Reloaded]");
else ReplyToCommand(client, "[Plugins Reloaded]");
return Plugin_Handled;
}
Action CmdUnload(int client, int args)
{
ServerCommand("sm plugins unload_all");
if( client ) PrintToChat(client, "\x04[Plugins Unloaded]");
else ReplyToCommand(client, "[Plugins Unloaded]");
return Plugin_Handled;
}
// ====================================================================================================
// COMMANDS - ALL GAMES - sm_round, sm_cheats, sm_logit, sm_createent
// ====================================================================================================
Action CmdRound(int client, int args)
{
if( g_iGAMETYPE == GAME_CSS )
ServerCommand("mp_restartgame 1");
else
ServerCommand("sm_cvar mp_restartgame 1");
if( client ) PrintToChat(client, "\x04[Restarting game]");
else ReplyToCommand(client, "\x04[Restarting game]");
return Plugin_Handled;
}
Action CmdCheats(int client, int args)
{
if( sv_cheats != null )
{
if( sv_cheats.IntValue == 1 )
{
ServerCommand("sv_cheats 0");
if( client ) PrintToChat(client, "\x04[sv_cheats]\x01 disabled!");
else ReplyToCommand(client, "[sv_cheats] disabled!");
}
else
{
ServerCommand("sv_cheats 1");
if( client ) PrintToChat(client, "\x04[sv_cheats]\x01 enabled!");
else ReplyToCommand(client, "[sv_cheats] enabled!");
}
}
return Plugin_Handled;
}
Action CmdLogIt(int client, int args)
{
if( args == 0 )
{
ReplyToCommand(client, "Usage: sm_logit <text>");
return Plugin_Handled;
}
char sTemp[256];
GetCmdArgString(sTemp, sizeof(sTemp));
LogCustom("%N: %s", client, sTemp);
return Plugin_Handled;
}
Action CmdGameTime(int client, int args)
{
ReplyToCommand(client, "[GameTime] %f", GetGameTime());
return Plugin_Handled;
}
Action CmdUpTime(int client, int args)
{
// From nextmap plugin
int time = GetTime() - g_iGameTime;
int days = time / 86400;
int hours = (time / 3600) % 24;
int minutes = (time / 60) % 60;
int seconds = time % 60;
if( client > 0 && client <= MaxClients && IsClientInGame(client) )
{
PrintToChat(client, "\x03Uptime: %d days %d hours %d minutes %d seconds", days, hours, minutes, seconds);
}
else if( client == 0 )
{
PrintToServer("Uptime: %d days %d hours %d minutes %d seconds", days, hours, minutes, seconds);
}
return Plugin_Handled;
}
Action CmdPlayTime(int client, int args)
{
// From nextmap plugin
int time = g_iPlayers ? g_iPlayedTime + GetTime() - g_iPlayTime : g_iPlayedTime;
int days = time / 86400;
int hours = (time / 3600) % 24;
int minutes = (time / 60) % 60;
int seconds = time % 60;
if( client > 0 && client <= MaxClients && IsClientInGame(client) )
{
PrintToChat(client, "\x03Playtime: %d days %d hours %d minutes %d seconds", days, hours, minutes, seconds);
}
else if( client == 0 )
{
PrintToServer("Playtime: %d days %d hours %d minutes %d seconds", days, hours, minutes, seconds);
}
return Plugin_Handled;
}
Action CmdChanges(int client, int args)
{
if( client > 0 && client <= MaxClients && IsClientInGame(client) )
{
PrintToChat(client, "\x01Map Changes: \x03%d", g_iMapChanges);
}
else if( client == 0 )
{
PrintToServer("Map Changes: %d", g_iMapChanges);
}
return Plugin_Handled;
}
Action CmdCreateEnt(int client, int args)
{
if( args != 1 )
{
ReplyToCommand(client, "Usage: sm_createent <text>");
return Plugin_Handled;
}
char sBuff[32];
GetCmdArg(1, sBuff, sizeof(sBuff));
int entity = CreateEntityByName(sBuff);
if( entity != -1 )
{
ReplyToCommand(client, "Created entity: %s", sBuff);
RemoveEntity(entity);
}
else
{
ReplyToCommand(client, "Failed entity: %s", sBuff);
}
return Plugin_Handled;
}
// ====================================================================================================
// COMMANDS - ALL GAMES - sm_e, sm_cv, sm_fcmd
// ====================================================================================================
Action CmdCV(int client, int args)
{
if( args == 0 )
{
ReplyToCommand(client, "[SM] Usage: sm_cv <cvar> [value]");
return Plugin_Handled;
}
char sCvar[64], sTemp[256];
GetCmdArg(1, sCvar, sizeof(sCvar));
ConVar hCvar = FindConVar(sCvar);
if( hCvar == null )
{
ReplyToCommand(client, "[SM] %t", "Unable to find cvar", sCvar);
return Plugin_Handled;
}
if( args == 1 )
{
hCvar.GetString(sTemp, sizeof(sTemp));
ReplyToCommand(client, "[SM] %t", "Value of cvar", sCvar, sTemp);
return Plugin_Handled;
}
int flags = hCvar.Flags;
hCvar.Flags = flags & ~FCVAR_NOTIFY;
GetCmdArg(2, sTemp, sizeof(sTemp));
hCvar.SetString(sTemp);
hCvar.Flags = flags;
ReplyToCommand(client, "[SM] %t", "Cvar changed", sCvar, sTemp);
return Plugin_Handled;
}
Action CmdECheat(int client, int args)
{
if( !client )
{
ReplyToCommand(client, "Command can only be used %s", IsDedicatedServer() ? "in game on a dedicated server." : "in chat on a Listen server.");
return Plugin_Handled;
}
if( args == 0 )
{
ReplyToCommand(client, "Usage: sm_e <command> [args]");
return Plugin_Handled;
}
char sArg1[64], sArg2[64];
GetCmdArg(1, sArg1, sizeof(sArg1));
if( args != 1 )
{
GetCmdArgString(sArg2, sizeof(sArg2));
strcopy(sArg2, sizeof(sArg2), sArg2[FindCharInString(sArg2, ' ')]);
}
int bits = GetUserFlagBits(client);
int flags = GetCommandFlags(sArg1);
SetUserFlagBits(client, ADMFLAG_ROOT);
SetCommandFlags(sArg1, flags & ~FCVAR_CHEAT);
if( args != 1 )
FakeClientCommand(client, "%s %s", sArg1, sArg2);
else
FakeClientCommand(client, sArg1);