-
Notifications
You must be signed in to change notification settings - Fork 2
/
hitmancsgo.sp
2475 lines (2175 loc) · 74.9 KB
/
hitmancsgo.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
#define PLUGIN_AUTHOR "Rachnus"
#define PLUGIN_VERSION "1.14"
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>
#include <dhooks>
#include <emitsoundany>
#include <clientprefs>
#pragma newdecls required
EngineVersion g_Game;
#define HITMAN_PREFIX "[\x04HitmanGO\x01]"
#define HIDE_RADAR 1<<12
#define GRAB_DISTANCE 100.0
#define SLOWMO_AMOUNT 0.4
#define AGENT47_MODEL "models/player/custom_player/voikanaa/hitman/agent47.mdl"
#define AGENT47_HEARTBEAT "hitmancsgo/heartbeat.mp3"
#define AGENT47_LOCATED "hitmancsgo/located.mp3"
#define AGENT47_SPOTTED "hitmancsgo/spotted.mp3"
#define AGENT47_DISGUISE "hitmancsgo/disguise.mp3"
#define AGENT47_SELECTED "hitmancsgo/selected.mp3"
#define MINE_ACTIVE "hitmancsgo/mine_activate.mp3"
#define MINE_EXPLODE "weapons/sensorgrenade/sensor_explode.wav"
#define TIMER_SOUND "buttons/button17.wav"
#define MINE_DEPLOY_VOLUME 0.1
#define MINE_EXPLOSION_VOLUME 1.0
#define MODEL_BEAM "materials/sprites/purplelaser1.vmt"
#define FOCUS_ACTIVE "ambient/atmosphere/underground.wav"
#define IDENTITY_SCAN_SOUND "buttons/blip2.wav"
#define IDENTITY_SCAN_VOLUME 1.0
//HITMAN VARIABLES
int g_iLastHitman = INVALID_ENT_REFERENCE;
int g_iHitman = INVALID_ENT_REFERENCE;
int g_iHitmanGlow = INVALID_ENT_REFERENCE;
int g_iHitmanTarget = INVALID_ENT_REFERENCE;
int g_iHitmanTargetGlow = INVALID_ENT_REFERENCE;
int g_iHitmanKiller = INVALID_ENT_REFERENCE;
int g_iHitmanTimer = 0;
int g_iHitmanTripmines = 0;
int g_iHitmanMaxTripmines = 0;
int g_iHitmanDecoys = 0;
int g_iHitmanMaxDecoys = 0;
int g_iHitmanTargetKills = 0;
int g_iHitmanNonTargetKills = 0;
bool g_bHasHitmanBeenSpotted = false;
bool g_bIsHitmanSeen = false;
bool g_bHitmanWasSeen = false;
bool g_bHitmanWasInOpen = false;
bool g_bHitmanPressedAttack1 = false;
bool g_bHitmanPressedUse = false;
bool g_bHitmanPressedWalk = false;
bool g_bFocusMode = false;
float g_iHitmanFocusTicksStart = 0.0;
float g_iHitmanTickCounter = 0.0;
float g_iHitmanGlobalTickCounter = 0.0;
float g_iHitmanFocusTime = 5.0;
float g_flTimeScaleGoal = 0.0;
char g_iHitmanDisguise[MAX_NAME_LENGTH];
//OTHER VARIABLES
int g_iDecoys[MAXPLAYERS + 1] = { false, ... };
int g_iMaxDecoys;
int g_iGrabbed[MAXPLAYERS + 1] = { INVALID_ENT_REFERENCE, ... };
int g_iPlayersOnStart;
int g_iPathLaserModelIndex;
int g_iPathHaloModelIndex;
bool g_bNotifyHelp[MAXPLAYERS + 1] = { false, ... };
bool g_bNotifyHitmanInfo[MAXPLAYERS + 1] = { false, ... };
bool g_bNotifyTargetInfo[MAXPLAYERS + 1] = { false, ... };
bool g_bPressedAttack2[MAXPLAYERS + 1] = { false, ... };
bool g_bDidHitHitman[MAXPLAYERS + 1] = { false, ... };
bool g_bPickingHitman = false;
ArrayList g_iRagdolls;
ArrayList g_iMines;
UserMsg g_BombText;
Handle g_PickHitmanTimer;
Handle g_hInaccuracy = INVALID_HANDLE;
Handle g_hNotifyHelp = INVALID_HANDLE;
Handle g_hNotifyHitmanInfo = INVALID_HANDLE;
Handle g_hNotifyTargetInfo = INVALID_HANDLE;
KeyValues g_Weapons;
//CONVARS
ConVar g_TimeUntilHitmanChosen;
ConVar g_MaxFocusTime;
ConVar g_RoundEndTime;
ConVar g_FocusPerKill;
ConVar g_FocusActivateCost;
ConVar g_DamagePenalty;
ConVar g_PenaltyType;
ConVar g_RagdollLimit;
ConVar g_MineExplosionRadius;
ConVar g_MineExplosionDamage;
ConVar g_IdentityScanRadius;
ConVar g_AllowTargetsGrabRagdoll;
ConVar g_HelpNoticeTime;
ConVar g_InfiniteFocusWhenAlone;
ConVar g_HitmanArmor;
ConVar g_HitmanHasHelmet;
ConVar g_TargetsArmor;
ConVar g_TargetsHaveHelmet;
ConVar g_DisguiseOnStart;
ConVar g_PunishOnFriendlyFire;
ConVar g_PunishOnFriendlyFireDamage;
ConVar g_AllowRemovalOfSilencer;
ConVar g_RootNotPunishable;
//FIND CONVARS
ConVar g_cvarTimescale;
ConVar g_cvarCheats;
ConVar g_cvarSpread;
//FORWARDS
Handle g_hOnPickHitman;
Handle g_hOnPickHitmanTarget;
public Plugin myinfo =
{
name = "Hitman Mod CS:GO v1.10",
author = PLUGIN_AUTHOR,
description = "A hitman mode for CS:GO",
version = PLUGIN_VERSION,
url = "https://github.com/Rachnus"
};
public void OnPluginStart()
{
g_Game = GetEngineVersion();
if(g_Game != Engine_CSGO)
{
SetFailState("This plugin is for CSGO");
}
//CONVARS
g_TimeUntilHitmanChosen = CreateConVar("hitmancsgo_time_until_hitman_chosen", "20", "Time in seconds until a hitman is chosen on round start");
g_MaxFocusTime = CreateConVar("hitmancsgo_max_slowmode_time", "5", "Maximum time in seconds hitman can use slowmode");
g_RoundEndTime = CreateConVar("hitmancsgo_round_end_timer", "3", "Time in seconds until next round starts after round ends when hitman is killed or targets killed");
g_FocusPerKill = CreateConVar("hitmancsgo_focus_per_kill", "0.20", "Amount of focus to gain in % (percentage) (0.0 - 1.0)");
g_FocusActivateCost = CreateConVar("hitmancsgo_focus_activate_cost", "0.10", "Amount of focus to use when walk buttin is first pressed (To prevent from focus spamming)");
g_DamagePenalty = CreateConVar("hitmancsgo_damage_penalty", "25", "Amount of damage to hurt hitman if wrong target was killed");
g_PenaltyType = CreateConVar("hitmancsgo_penalty_type", "1", "0 = No punishment, 1 = Punish hitman on wrong target kill using hitmancsgo_damage_penalty, 2 = Reflect the damage onto hitman if wrong target was shot",0,true,0.0,true,2.0);
g_RagdollLimit = CreateConVar("hitmancsgo_ragdoll_limit", "10", "Amount of server side ragdolls there can be (Lower this if server starts lagging)");
g_MineExplosionRadius = CreateConVar("hitmancsgo_explosion_radius", "600", "Tripmine explosion radius");
g_MineExplosionDamage = CreateConVar("hitmancsgo_explosion_damage", "500", "Tripmine explosion damage (magnitude)");
g_IdentityScanRadius = CreateConVar("hitmancsgo_identity_scan_radius", "400", "Identity scan grenade radius");
g_AllowTargetsGrabRagdoll = CreateConVar("hitmancsgo_allow_targets_grab_ragdolls", "0", "Allow non hitmen to grab ragdolls (Might cause lag if many players grab ragdolls)");
g_HelpNoticeTime = CreateConVar("hitmancsgo_notice_timer", "20", "Time in seconds to notify players gamemode information");
g_InfiniteFocusWhenAlone = CreateConVar("hitmancsgo_infinite_focus_when_alone", "1", "If theres only 1 player on server, give him infinite focus");
g_HitmanArmor = CreateConVar("hitmancsgo_hitman_armor", "100", "Amount of armor hitman should have");
g_HitmanHasHelmet = CreateConVar("hitmancsgo_hitman_has_helmet", "1", "Should hitman have helmet");
g_TargetsArmor = CreateConVar("hitmancsgo_targets_armor", "100", "Amount of armor targets should have");
g_TargetsHaveHelmet = CreateConVar("hitmancsgo_targets_have_helmet", "0", "Should targets have helmets");
g_DisguiseOnStart = CreateConVar("hitmancsgo_disguise_hitman_on_round_start", "1", "Should the hitman be disguised on round start");
g_PunishOnFriendlyFire = CreateConVar("hitmancsgo_punish_on_friendly_fire", "1", "Should targets get damaged if they kill another target?");
g_PunishOnFriendlyFireDamage = CreateConVar("hitmancsgo_punish_on_friendly_fire_damage", "50.0", "Amount of damage to deal if 'hitmancsgo_punish_on_friendly_fire' is set to 1");
g_AllowRemovalOfSilencer = CreateConVar("hitmancsgo_allow_removal_of_silencer", "0", "Should silencers (M4A1 or USP) be removable");
g_RootNotPunishable = CreateConVar("hitmancsgo_root_non_punishable", "1", "Should users with flag 'z' not get punished as a target by killing other targets");
Handle hConf = LoadGameConfigFile("hitmancsgo.games");
int InaccuracyOffset = GameConfGetOffset(hConf, "InaccuracyOffset");
//DHOOK CWeaponCSBase::GetInaccuracy 460
g_hInaccuracy = DHookCreate(InaccuracyOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, CWeaponCSBase_GetInaccuracy);
g_hNotifyHelp = RegClientCookie("HMGO_Notify_Help", "Notify players gamemode instructions", CookieAccess_Public);
g_hNotifyHitmanInfo = RegClientCookie("HMGO_Notify_Hitman_Info", "Notify players hitman information", CookieAccess_Public);
g_hNotifyTargetInfo = RegClientCookie("HMGO_Notify_Target_Info", "Notify players target information", CookieAccess_Public);
g_hOnPickHitman = CreateGlobalForward("HitmanGO_OnHitmanPicked", ET_Ignore, Param_Cell);
g_hOnPickHitmanTarget = CreateGlobalForward("HitmanGO_OnHitmanTargetPicked", ET_Ignore, Param_Cell);
//RegAdminCmd("sm_test", Command_Test, ADMFLAG_ROOT);
RegAdminCmd("sm_hmgorefresh", Command_Refresh, ADMFLAG_ROOT, "Refresh weapons config");
RegConsoleCmd("sm_help", Command_Help);
RegConsoleCmd("sm_hmgohelp", Command_Help);
RegConsoleCmd("sm_hitmaninfo", Command_HitmanInfo);
RegConsoleCmd("sm_targetinfo", Command_TargetInfo);
RegConsoleCmd("sm_hmgonotify", Command_Notify);
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
HookEvent("player_hurt", Event_PlayerHurt);
HookEvent("weapon_fire", Event_WeaponFire);
HookEvent("decoy_started", Event_DecoyStarted);
HookEvent("decoy_firing", Event_DecoyFiring, EventHookMode_Post);
HookEvent("round_prestart", Event_RoundStart);
HookEvent("round_poststart", Event_RoundPostStart);
HookEvent("round_end", Event_RoundEnd);
AddCommandListener(OnCheatCommand, "addcond");
AddCommandListener(OnCheatCommand, "removecond");
AddCommandListener(Command_JoinTeam, "jointeam");
g_BombText = GetUserMessageId("TextMsg");
HookUserMessage(g_BombText, UserMessageHook, true);
char path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "configs/hitmancsgo_weapons.cfg");
g_Weapons = new KeyValues("weapons");
if(!g_Weapons.ImportFromFile(path))
SetFailState("Could not open %s", path);
g_Weapons.SetEscapeSequences(true);
g_cvarTimescale = FindConVar("host_timescale");
g_cvarCheats = FindConVar("sv_cheats");
g_cvarSpread = FindConVar("weapon_accuracy_nospread");
SetConVarFlags(g_cvarCheats, GetConVarFlags(g_cvarCheats) & ~FCVAR_NOTIFY);
SetConVarFlags(g_cvarTimescale, GetConVarFlags(g_cvarCheats) & ~FCVAR_NOTIFY);
g_iRagdolls = new ArrayList();
g_iMines = new ArrayList();
char strConCommand[128];
bool bIsCommand;
int iFlags;
Handle hSearch = FindFirstConCommand(strConCommand, sizeof(strConCommand), bIsCommand, iFlags);
do
{
if(bIsCommand && (iFlags & FCVAR_CHEAT))
AddCommandListener(OnCheatCommand, strConCommand);
}while(FindNextConCommand(hSearch, strConCommand, sizeof(strConCommand), bIsCommand, iFlags));
for (int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i))
OnClientPutInServer(i);
}
AutoExecConfig(true, "hitmancsgo");
}
public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int err_max)
{
CreateNative("HitmanGO_GetHitman", Native_GetHitman);
CreateNative("HitmanGO_GetHitmanKiller", Native_GetHitmanKiller);
CreateNative("HitmanGO_HasHitmanBeenSpotted", Native_HasHitmanBeenSpotted);
CreateNative("HitmanGO_GetCurrentHitmanTarget", Native_GetCurrentHitmanTarget);
CreateNative("HitmanGO_GetRoundStartPlayers", Native_GetRoundStartPlayers);
CreateNative("HitmanGO_GetTargetKills", Native_GetTargetKills);
CreateNative("HitmanGO_GetNonTargetKills", Native_GetNonTargetKills);
CreateNative("HitmanGO_IsHitmanSeen", Native_IsHitmanSeen);
CreateNative("HitmanGO_IsValidHitman", Native_IsValidHitman);
RegPluginLibrary("hitmancsgo");
return APLRes_Success;
}
public int Native_GetHitman(Handle plugin, int numParams)
{
int hitman = GetClientOfUserId(g_iHitman);
return hitman;
}
public int Native_GetHitmanKiller(Handle plugin, int numParams)
{
int hitmankiller = GetClientOfUserId(g_iHitmanKiller);
return hitmankiller;
}
public int Native_HasHitmanBeenSpotted(Handle plugin, int numParams)
{
return view_as<int>(g_bHasHitmanBeenSpotted);
}
public int Native_GetCurrentHitmanTarget(Handle plugin, int numParams)
{
int hitmantarget = GetClientOfUserId(g_iHitmanTarget);
return hitmantarget;
}
public int Native_GetRoundStartPlayers(Handle plugin, int numParams)
{
return g_iPlayersOnStart;
}
public int Native_GetTargetKills(Handle plugin, int numParams)
{
return g_iHitmanTargetKills;
}
public int Native_GetNonTargetKills(Handle plugin, int numParams)
{
return g_iHitmanNonTargetKills;
}
public int Native_IsHitmanSeen(Handle plugin, int numParams)
{
return view_as<int>(g_bIsHitmanSeen);
}
public int Native_IsValidHitman(Handle plugin, int numParams)
{
return view_as<int>(IsValidHitman());
}
/*************
* CALLBACKS *
*************/
//Remove bomb pickup/bomb drop notification
public Action UserMessageHook(UserMsg msg_id, Handle pb, const int[] players, int playersNum, bool reliable, bool init)
{
if(msg_id == g_BombText)
{
int msgindex = PbReadInt(pb, "msg_dst");
if(msgindex == 4)
return Plugin_Handled;
}
return Plugin_Continue;
}
//Called when getting weapon inaccuracy
public MRESReturn CWeaponCSBase_GetInaccuracy(int pThis, Handle hReturn, Handle hParams)
{
DHookSetReturn(hReturn, 0.0);
return MRES_Supercede;
}
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
ResetVariables();
TransferPlayersToT();
g_bPickingHitman = true;
if(GetClientCountWithoutBots() > 0)
{
if(g_PickHitmanTimer != INVALID_HANDLE)
KillTimer(g_PickHitmanTimer);
g_PickHitmanTimer = CreateTimer(1.0, Timer_PickHitman, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action Event_RoundPostStart(Event event, const char[] name, bool dontBroadcast)
{
SetConVarInt(FindConVar("mp_tagging_scale"), 200);
}
void ExecuteGamemodeCvars()
{
SetConVarInt(FindConVar("mp_playerid"), 0);
SetConVarInt(FindConVar("mp_friendlyfire"), 1);
SetConVarInt(FindConVar("mp_autoteambalance"), 0);
SetConVarInt(FindConVar("mp_teammates_are_enemies"), 1);
SetConVarInt(FindConVar("sv_deadtalk"), 0);
SetConVarInt(FindConVar("sv_alltalk"), 1);
SetConVarInt(FindConVar("sv_show_team_equipment_prohibit"), 0);
SetConVarInt(FindConVar("sv_occlude_players"), 0);
SetConVarInt(FindConVar("mp_respawn_on_death_t"), 0);
SetConVarInt(FindConVar("mp_respawn_on_death_ct"), 0);
SetConVarInt(FindConVar("mp_default_team_winner_no_objective"), 3);
SetConVarInt(FindConVar("mp_warmuptime"), 20);
SetConVarInt(FindConVar("mp_buytime"), 0);
SetConVarInt(FindConVar("mp_buy_anywhere"), 0);
SetConVarInt(FindConVar("bot_quota"), 0);
SetConVarInt(FindConVar("mp_solid_teammates"), 1);
SetConVarInt(FindConVar("sv_talk_enemy_living"), 1);
SetConVarInt(FindConVar("sv_ignoregrenaderadio"), 1);
SetConVarInt(FindConVar("mp_randomspawn"), 0);
SetConVarInt(FindConVar("mp_spawnprotectiontime"), 0);
SetConVarInt(FindConVar("mp_tagging_scale"), 200);
SetConVarInt(FindConVar("sv_gameinstructor_disable"), 1);
}
public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
DisableSlowmo();
int hitman = GetClientOfUserId(g_iHitman);
if(IsValidHitman(true))
{
if(GetAliveCount() > 1)
{
//TARGETS WIN
PrintToChatAll("Player '\x03%N\x01' \x02failed \x01to assassinate all targets!", hitman);
}
else
{
if(IsPlayerAlive(hitman))
{
if((g_iHitmanTargetKills + g_iHitmanNonTargetKills) >= g_iPlayersOnStart)
PrintToChatAll("Player '\x03%N\x01' \x04successfully \x01eliminated all targets!", hitman);
else
PrintToChatAll("Player '\x03%N\x01' \x04successfully \x01managed to get all targets eliminated!", hitman);
}
else
{
PrintToChatAll("Player '\x03%N\x01' \x02failed \x01to assassinate all targets!", hitman);
}
}
PrintToChatAll(" \x04》\x01Target Kills: \x03%d", g_iHitmanTargetKills);
PrintToChatAll(" \x04》\x01Non-Target Kills: \x03%d", g_iHitmanNonTargetKills);
}
g_iLastHitman = g_iHitman;
ResetVariables();
}
public Action Timer_PickHitman(Handle timer, any entref)
{
PrintHintTextToAll("<font size='30' color='#FFA500' face=''>Picking Hitman In: <font color='#00FF00'>%d</font>", --g_iHitmanTimer);
if(g_iHitmanTimer < -1)
{
g_PickHitmanTimer = INVALID_HANDLE;
return Plugin_Stop;
}
if(g_iHitmanTimer <= 0)
{
g_bPickingHitman = false;
PickHitman();
PickHitmanTarget();
g_PickHitmanTimer = INVALID_HANDLE;
return Plugin_Stop;
}
EmitSoundToAllAny(TIMER_SOUND, _, SNDCHAN_STATIC,_,_,0.2);
return Plugin_Continue;
}
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
int attacker = GetClientOfUserId(event.GetInt("attacker"));
int hitman = GetClientOfUserId(g_iHitman);
int hitmantarget = GetClientOfUserId(g_iHitmanTarget);
g_iGrabbed[client] = INVALID_ENT_REFERENCE;
if(!IsValidClient(hitman))
return Plugin_Continue;
if(IsValidClient(attacker) && attacker == hitman && client == hitmantarget)
{
g_iHitmanTargetKills++;
g_iHitmanFocusTime += (g_FocusPerKill.FloatValue * g_MaxFocusTime.FloatValue);
g_iHitmanGlobalTickCounter -= (g_FocusPerKill.FloatValue * g_MaxFocusTime.FloatValue);
if(g_iHitmanFocusTime > g_MaxFocusTime.FloatValue)
{
g_iHitmanFocusTime = g_MaxFocusTime.FloatValue;
g_iHitmanGlobalTickCounter = 0.0;
}
}
else if(IsValidClient(attacker) && attacker == hitman && client != hitmantarget && client != hitman)
{
g_iHitmanNonTargetKills++;
if(g_RootNotPunishable.BoolValue)
{
if(g_PenaltyType.IntValue == 1 && !g_bDidHitHitman[client] && !CheckCommandAccess(client, "", ADMFLAG_ROOT, true))
{
int armor = GetEntProp(hitman, Prop_Data, "m_ArmorValue");
SetEntProp(hitman, Prop_Data, "m_ArmorValue", 0);
SDKHooks_TakeDamage(hitman, 0, 0, g_DamagePenalty.FloatValue, DMG_SHOCK);
SetEntProp(hitman, Prop_Data, "m_ArmorValue", armor);
int health = GetEntProp(hitman, Prop_Data, "m_iHealth");
if(g_DamagePenalty.IntValue >= health)
PrintHintText(hitman, "<font size='20' color='#FF0000' face=''>Warning: <font>You've died!\nKilling wrong targets backfires.</font>");
else
PrintHintText(hitman, "<font size='20' color='#FF0000' face=''>Warning: <font>You've lost %d health!\nKilling wrong targets backfires.</font>", g_DamagePenalty.IntValue);
}
}
else
{
if(g_PenaltyType.IntValue == 1 && !g_bDidHitHitman[client])
{
int armor = GetEntProp(hitman, Prop_Data, "m_ArmorValue");
SetEntProp(hitman, Prop_Data, "m_ArmorValue", 0);
SDKHooks_TakeDamage(hitman, 0, 0, g_DamagePenalty.FloatValue, DMG_SHOCK);
SetEntProp(hitman, Prop_Data, "m_ArmorValue", armor);
int health = GetEntProp(hitman, Prop_Data, "m_iHealth");
if(g_DamagePenalty.IntValue >= health)
PrintHintText(hitman, "<font size='20' color='#FF0000' face=''>Warning: <font>You've died!\nKilling wrong targets backfires.</font>");
else
PrintHintText(hitman, "<font size='20' color='#FF0000' face=''>Warning: <font>You've lost %d health!\nKilling wrong targets backfires.</font>", g_DamagePenalty.IntValue);
}
}
}
if(IsValidClient(attacker) && attacker != hitman && client != hitman && g_PunishOnFriendlyFire.BoolValue)
{
int armor = GetEntProp(attacker, Prop_Data, "m_ArmorValue");
SetEntProp(attacker, Prop_Data, "m_ArmorValue", 0);
SDKHooks_TakeDamage(attacker, 0, 0, g_PunishOnFriendlyFireDamage.FloatValue);
SetEntProp(attacker, Prop_Data, "m_ArmorValue", armor);
}
if(client == hitman)
{
DisableSlowmo();
if(IsValidClient(attacker))
g_iHitmanKiller = GetClientUserId(attacker);
else
g_iHitmanKiller = 0;
StopSoundAny(hitman, SNDCHAN_AUTO, AGENT47_HEARTBEAT);
int hitmanglow = EntRefToEntIndex(g_iHitmanGlow);
if(hitmanglow != INVALID_ENT_REFERENCE)
{
AcceptEntityInput(hitmanglow, "Kill");
g_iHitmanGlow = INVALID_ENT_REFERENCE;
}
if(GetClientCountWithoutBots() > 0)
CS_TerminateRound(g_RoundEndTime.FloatValue, CSRoundEnd_CTWin, false);
return Plugin_Continue;
}
if(client == hitmantarget)
{
CleanUpRagdolls();
int glow = EntRefToEntIndex(g_iHitmanTargetGlow);
if(glow != INVALID_ENT_REFERENCE)
{
AcceptEntityInput(glow, "Kill");
g_iHitmanTargetGlow = INVALID_ENT_REFERENCE;
}
float pos[3], angles[3];
GetClientAbsAngles(client, angles);
GetClientAbsOrigin(client, pos);
char modelName[PLATFORM_MAX_PATH], clientName[MAX_NAME_LENGTH];
GetClientModel(client, modelName, sizeof(modelName));
GetClientName(client, clientName, sizeof(clientName));
int ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
int serverdoll = CreateEntityByName("prop_ragdoll");
g_iRagdolls.Push(EntIndexToEntRef(serverdoll));
if(ragdoll != INVALID_ENT_REFERENCE)
AcceptEntityInput(ragdoll, "Kill");
DispatchKeyValue(serverdoll, "targetname", clientName);
DispatchKeyValue(serverdoll, "model", modelName);
DispatchKeyValue(serverdoll, "spawnflags", "4");
SetEntPropEnt(client, Prop_Send, "m_hRagdoll", serverdoll);
SetEntityModel(serverdoll, modelName);
DispatchSpawn(serverdoll);
TeleportEntity(serverdoll, pos, angles, NULL_VECTOR);
//int forcebone = GetEntProp(client, Prop_Send, "m_nForceBone");
//SetEntProp(ragdoll, Prop_Send, "m_nForceBone", forcebone);
//SetEntProp(serverdoll, Prop_Send, "m_nSolidType", 0x0010);
//SetEntProp(serverdoll, Prop_Send, "m_CollisionGroup", 0);
/*int iFlags = GetEntProp(serverdoll, Prop_Send, "m_fEffects");
flagstest = iFlags;
SetEntProp(serverdoll, Prop_Send, "m_fEffects", iFlags | (1 << 0) | (1 << 4) | (1 << 6) | (1 << 9));
SetVariantString("!activator");
AcceptEntityInput(serverdoll, "SetParent", client);
SetVariantString("primary");
AcceptEntityInput(serverdoll, "SetParentAttachment", serverdoll);
RequestFrame(UnmergeCallback, serverdoll);
*/
if(!PickHitmanTarget() && IsValidClient(hitman))
{
if(GetClientCountWithoutBots() > 0)
CS_TerminateRound(g_RoundEndTime.FloatValue, CSRoundEnd_TerroristWin, false);
}
}
event.BroadcastDisabled = true;
return Plugin_Continue;
}
public Action Event_PlayerHurt(Event event, const char[] name, bool dontBroadcast)
{
int attacker = GetClientOfUserId(event.GetInt("attacker"));
int victim = GetClientOfUserId(event.GetInt("userid"));
int hitman = GetClientOfUserId(g_iHitman);
int hitmantarget = GetClientOfUserId(g_iHitmanTarget);
if(victim == hitman)
g_bDidHitHitman[attacker] = true;
if(g_PenaltyType.IntValue == 2)
{
if(attacker == hitman && victim != hitmantarget && !g_bDidHitHitman[victim])
{
int dmgdealt = event.GetInt("dmg_health");
float dmgfloat = float(dmgdealt); //weird as fuck
int health = GetEntProp(hitman, Prop_Data, "m_iHealth");
SDKHooks_TakeDamage(hitman, 0, 0, dmgfloat, DMG_SHOCK);
if(dmgdealt >= health)
PrintHintText(hitman, "<font size='20' color='#FF0000' face=''>Warning: <font>You've died!\nHurting wrong targets backfires.</font>");
else
PrintHintText(hitman, "<font size='20' color='#FF0000' face=''>Warning: <font>You've lost %d health!\nHurting wrong targets backfires.</font>", dmgdealt);
}
}
}
/*
public void UnmergeCallback(any data)
{
int ent = EntRefToEntIndex(g_iHitmanGlow);
if(ent != INVALID_ENT_REFERENCE)
{
AcceptEntityInput(ent, "ClearParent");
}
//SetEntProp(serverdoll, Prop_Send, "m_fEffects", flagstest);
//AcceptEntityInput(serverdoll, "ClearParent");
//DispatchKeyValue(serverdoll, "spawnflags", "0");
}*/
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
g_bDidHitHitman[client] = false;
if(!IsFakeClient(client))
RequestFrame(HideRadar, client);
StripWeapons(client);
}
public Action Event_WeaponFire(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
int hitman = GetClientOfUserId(g_iHitman);
if(client == hitman && !g_bIsHitmanSeen)
{
char weaponName[64];
event.GetString("weapon", weaponName, sizeof(weaponName));
int weapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
bool silencer = (!!GetEntProp(weapon, Prop_Send, "m_bSilencerOn") ||
StrContains(weaponName, "bayonet", false) != -1 ||
StrContains(weaponName, "knife", false) != -1 ||
StrContains(weaponName, "decoy", false) != -1);
if(!silencer)
{
float pos[3], angles[3];
GetClientAbsOrigin(client, pos);
GetClientEyeAngles(client, angles);
angles[2] = 0.0;
angles[0] = 0.0;
TeleportHitmanGlow(pos, angles);
}
}
}
public Action Event_DecoyStarted(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
int hitman = GetClientOfUserId(g_iHitman);
if(client == hitman)
{
float pos[3], angles[3];
pos[0] = event.GetFloat("x");
pos[1] = event.GetFloat("y");
pos[2] = event.GetFloat("z");
GetClientEyeAngles(hitman, angles);
angles[2] = 0.0;
angles[0] = 0.0;
if(!g_bIsHitmanSeen)
TeleportHitmanGlow(pos, angles);
}
}
public Action Event_DecoyFiring(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
int hitman = GetClientOfUserId(g_iHitman);
if(client == hitman)
{
int ent = event.GetInt("entityid");
if(ent != INVALID_ENT_REFERENCE)
AcceptEntityInput(ent, "Kill");
}
}
public void HideRadar(any client)
{
SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_RADAR);
}
public Action OnCheatCommand(int client, const char[] command, int argc)
{
if(client <= 0)
return Plugin_Continue;
if(g_bFocusMode)
{
PrintToConsole(client, "Cheater!");
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action Command_JoinTeam(int client, const char[] command, int args)
{
char arg[PLATFORM_MAX_PATH];
GetCmdArg(1, arg, sizeof(arg));
int team = StringToInt(arg);
if(team == CS_TEAM_SPECTATOR)
return Plugin_Continue;
if(IsPlayerAlive(client))
return Plugin_Handled;
CS_SwitchTeam(client, CS_TEAM_T);
if(GetClientCountWithoutBots() == 2)
ServerCommand("mp_restartgame 1");
return Plugin_Handled;
}
public Action Command_Refresh(int client, int args)
{
char path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), "configs/hitmancsgo_weapons.cfg");
g_Weapons = new KeyValues("weapons");
if(!g_Weapons.ImportFromFile(path))
PrintToServer("[hitmancsgo.smx] Could not open %s", path);
return Plugin_Handled;
}
public Action Command_Help(int client, int args)
{
PrintToChat(client, "%s Type !hitmaninfo or !targetinfo for detailed information", HITMAN_PREFIX);
}
public Action Command_HitmanInfo(int client, int args)
{
PrintHitmanInfo(client);
}
public Action Command_TargetInfo(int client, int args)
{
PrintTargetInfo(client);
}
public Action Command_Notify(int client, int args)
{
g_bNotifyHelp[client] = !g_bNotifyHelp[client];
PrintToChat(client, "%s Notifications are now %s", HITMAN_PREFIX, (g_bNotifyHelp[client]) ? "\x02OFF":"\x04ON");
SetClientCookie(client, g_hNotifyHelp, (g_bNotifyHelp[client]) ? "1":"0");
}
/*
public Action Command_Test(int client, int args)
{
PrintToChat(client, "%d", GetEntProp(client, Prop_Data, "m_iTeamNum"));
}*/
public bool TraceFilterNotSelfAndParent(int entityhit, int mask, any entity)
{
int parent = GetEntPropEnt(entity, Prop_Data, "m_hMoveParent");
if(entityhit > 0 && entityhit != entity && entityhit != parent)
return true;
return false;
}
public bool TraceFilterNotSelf(int entityhit, int mask, any entity)
{
if(entityhit >= 0 && entityhit != entity)
return true;
return false;
}
public void OnThinkPostManager(int entity)
{
for (int i = 0; i < MAXPLAYERS;i++)
{
SetEntProp(entity, Prop_Send, "m_bAlive", 1, _, i);
SetEntProp(entity, Prop_Send, "m_iTeam", CS_TEAM_T, _, i);
SetEntProp(entity, Prop_Send, "m_iPendingTeam", CS_TEAM_T, _, i);
SetEntProp(entity, Prop_Send, "m_iArmor", 0, _, i);
SetEntProp(entity, Prop_Send, "m_bHasHelmet", false, _, i);
SetEntProp(entity, Prop_Send, "m_iScore", 101, _, i);
SetEntProp(entity, Prop_Send, "m_iKills", 101, _, i);
}
SetEntProp(entity, Prop_Send, "m_iPlayerC4", 0);
}
public Action SetTransmitTarget(int entity, int client)
{
// Show target if hitman
if(!IsValidHitman())
return Plugin_Handled;
int hitman = GetClientOfUserId(g_iHitman);
return (client == hitman) ? Plugin_Continue : Plugin_Handled;
}
public Action SetTransmitHitman(int entity, int client)
{
if(!IsValidHitman())
return Plugin_Handled;
// Show target if hitman
int hitman = GetClientOfUserId(g_iHitman);
return (client != hitman) ? Plugin_Continue : Plugin_Handled;
}
public Action OnPostThinkPost(int client)
{
SetEntProp(client, Prop_Send, "m_iAddonBits", 0);
int entity = EntRefToEntIndex(g_iGrabbed[client]);
if (entity != INVALID_ENT_REFERENCE)
{
float vecView[3], vecFwd[3], vecPos[3], vecVel[3];
GetClientEyeAngles(client, vecView);
GetAngleVectors(vecView, vecFwd, NULL_VECTOR, NULL_VECTOR);
GetClientEyePosition(client, vecPos);
vecPos[0] += vecFwd[0] * GRAB_DISTANCE;
vecPos[1] += vecFwd[1] * GRAB_DISTANCE;
vecPos[2] += vecFwd[2] * GRAB_DISTANCE;
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vecFwd);
SubtractVectors(vecPos, vecFwd, vecVel);
char classname[PLATFORM_MAX_PATH];
GetEntityClassname(entity, classname, sizeof(classname));
if(StrEqual(classname, "prop_ragdoll", false))
ScaleVector(vecVel, 50.0);
else
ScaleVector(vecVel, 10.0);
TeleportEntity(entity, NULL_VECTOR, NULL_VECTOR, vecVel);
}
}
public void OnClientWeaponSwitchPost(int client, int weaponid)
{
int hitman = GetClientOfUserId(g_iHitman);
if(client == hitman)
{
char classname[PLATFORM_MAX_PATH];
GetEntityClassname(weaponid, classname, sizeof(classname));
if(StrEqual(classname, "weapon_c4", false) ||
StrEqual(classname, "weapon_decoy", false))
{
PrintActiveHitmanSettings(classname);
}
}
else
{
char classname[PLATFORM_MAX_PATH];
GetEntityClassname(weaponid, classname, sizeof(classname));
if(StrEqual(classname, "weapon_decoy", false))
{
PrintActiveTargetSettings(client, classname);
}
else if(StrEqual(classname, "weapon_c4", false))
{
SDKHooks_DropWeapon(client, weaponid);
AcceptEntityInput(weaponid, "Kill");
}
}
}
public Action OnDecoySpawned(int entity)
{
int owner = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");
int hitman = GetClientOfUserId(g_iHitman);
if(owner > 0 && owner <= MaxClients)
{
if(owner == hitman)
{
g_iHitmanDecoys--;
if(g_iHitmanDecoys > 0)
{
GivePlayerItem(owner, "weapon_decoy");
}
PrintActiveHitmanSettings("weapon_decoy");
}
else
{
g_iDecoys[owner]--;
if(g_iDecoys[owner] > 0)
{
GivePlayerItem(owner, "weapon_decoy");
}
SDKHook(entity, SDKHook_TouchPost, DecoyTouchPost);
PrintActiveTargetSettings(owner, "weapon_decoy");
}
}
return Plugin_Continue;
}
public Action DecoyTouchPost(int entity, int other)
{
if(other == 0)
{
if(IsValidHitman())
{
float pos[3];
GetEntPropVector(entity, Prop_Data, "m_vecOrigin", pos);
CreateIdentityScan(pos);
AcceptEntityInput(entity, "Kill");
}
else
return Plugin_Continue;
}
return Plugin_Continue;
}
public void DownloadFilterCallback(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, any value)
{
if(!StrEqual(cvarValue, "all", false))
{
KickClient(client, "Change cl_downloadfilter to 'all'");
}
}
/*************
* FUNCTIONS *
*************/
stock int GetAliveCount()
{
int count = 0;
for (int i = 1; i <= MaxClients;i++)
{
if(IsClientInGame(i) && IsPlayerAlive(i) && (GetClientTeam(i) == CS_TEAM_T || GetClientTeam(i) == CS_TEAM_CT))
count++;
}
return count;
}
stock bool IsValidClient(int client)
{
if(client > 0 && client <= MaxClients)
{
if(IsClientInGame(client))
return true;
}
return false;
}
stock int GetAliveCountWithoutBots()
{
int count = 0;
for (int i = 1; i <= MaxClients;i++)
{
if(IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i) && (GetClientTeam(i) == CS_TEAM_T || GetClientTeam(i) == CS_TEAM_CT))
count++;
}
return count;
}
stock void CreateTargetGlowEntity(int target)
{
char red[16] = "255 0 0 255";
int glow = CreateEntityByName("prop_dynamic_override");
g_iHitmanTargetGlow = EntIndexToEntRef(glow);
SDKHook(glow, SDKHook_SetTransmit, SetTransmitTarget);
char model[PLATFORM_MAX_PATH];
GetClientModel(target, model, sizeof(model));
DispatchKeyValue(glow, "model", model);
DispatchKeyValue(glow, "disablereceiveshadows", "1");
DispatchKeyValue(glow, "disableshadows", "1");
DispatchKeyValue(glow, "solid", "0");
DispatchKeyValue(glow, "spawnflags", "256");
DispatchKeyValue(glow, "targetname", "red");
DispatchSpawn(glow);
SetEntProp(glow, Prop_Send, "m_bShouldGlow", true);
SetEntPropFloat(glow, Prop_Send, "m_flGlowMaxDist", 10000000.0);
SetEntPropEnt(glow, Prop_Data, "m_hOwnerEntity", target);
int iFlags = GetEntProp(glow, Prop_Send, "m_fEffects");
SetEntProp(glow, Prop_Send, "m_fEffects", iFlags | (1 << 0) | (1 << 4) | (1 << 6) | (1 << 9));
SetGlowColor(glow, red);
SetVariantString("!activator");
AcceptEntityInput(glow, "SetParent", target);
SetVariantString("primary");
AcceptEntityInput(glow, "SetParentAttachment", glow);
}
stock void CreateHitmanGlowEntity(float pos[3], float angles[3], bool bonemerge = false)
{
if(!IsValidHitman())
return;
int hitman = GetClientOfUserId(g_iHitman);
char yellow[16] = "255 255 0 50";
int glow = CreateEntityByName("prop_dynamic_override");
SetEntityRenderMode(glow, RENDER_TRANSALPHA);
SetEntityRenderColor(glow, 255, 255, 255, 50);
g_iHitmanGlow = EntIndexToEntRef(glow);