-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdice.sp
More file actions
1005 lines (822 loc) · 27.5 KB
/
dice.sp
File metadata and controls
1005 lines (822 loc) · 27.5 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
#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
#include <clientprefs>
#include <sdktools>
#include <sdkhooks>
#include <multicolors>
#include <outbreak>
#include <stamm>
#include <emitsoundany>
#include <autoexecconfig>
#include <futuristicgrenades>
#include <verstecken>
#include <krieg>
#include <gohan>
#undef REQUIRE_PLUGIN
#include <jail>
#include <knockout>
#include <lastrequest>
#pragma newdecls required
#define DICE_SOUND "outbreak/jail/dice/dice.mp3"
#define NEGATIVE_SOUND "outbreak/jail/dice/negative.mp3"
#define NEUTRAL_SOUND "outbreak/jail/dice/neutral.mp3"
#define POSITIVE_SOUND "outbreak/jail/dice/positive.mp3"
#define JIHAD_SOUND "outbreak/jail/dice/jihad/jihad.mp3"
#define EXPLOSION_SOUND "outbreak/jail/dice/jihad/explosion.mp3"
// Auto Dice
Handle g_hAutoCTDice = null;
bool g_bAutoCTDice[MAXPLAYERS + 1] = { false, ... };
Handle g_hAutoT1Dice = null;
bool g_bAutoT1Dice[MAXPLAYERS + 1] = { false, ... };
Handle g_hAutoT2Dice = null;
bool g_bAutoT2Dice[MAXPLAYERS + 1] = { false, ... };
int g_iClip1 = -1;
int g_iCount[MAXPLAYERS + 1] = { 0, ... };
int g_iNoclipCounter[MAXPLAYERS + 1] = {5, ...};
int g_iFroggyAir[MAXPLAYERS + 1] = { 0, ... };
bool g_bInWater[MAXPLAYERS + 1] = {false, ...};
bool g_bFroggyjump[MAXPLAYERS + 1] = { false, ... };
bool g_bFroggyPressed[MAXPLAYERS + 1] = { false, ... };
bool g_bLongjump[MAXPLAYERS + 1] = { false, ... };
bool g_bBhop[MAXPLAYERS + 1] = { false, ... };
bool g_bAssassine[MAXPLAYERS + 1] = { false, ... };
bool g_bTollpatsch[MAXPLAYERS + 1] = { false, ... };
bool g_bLose[MAXPLAYERS + 1] = { false, ... };
bool g_bMirrorMovement[MAXPLAYERS + 1] = { false, ... };
bool g_bZombie[MAXPLAYERS + 1] = { false, ... };
bool g_bDecoy[MAXPLAYERS + 1] = { false, ... };
bool g_bJihad[MAXPLAYERS + 1] = { false, ... };
bool g_bNoFallDamage[MAXPLAYERS + 1] = { false, ... };
bool g_bRentner[MAXPLAYERS + 1] = { false, ... };
bool g_bAWP[MAXPLAYERS + 1] = { false, ... };
int g_iLover[MAXPLAYERS + 1] = { -1, ... };
Handle g_hDrugsTimer[MAXPLAYERS + 1] = { null, ... };
Handle g_hDrunkTimer[MAXPLAYERS + 1] = { null, ... };
Handle g_hDelayedSlay[MAXPLAYERS + 1] = { null, ... };
DecoyMode g_dmFuturistic[MAXPLAYERS + 1] = { DecoyMode_Normal, ... };
float g_fDamage[MAXPLAYERS + 1] = {0.0, ...};
bool g_bMoreDamage[MAXPLAYERS + 1] = {false, ...};
bool g_bLessDamage[MAXPLAYERS + 1] = {false, ...};
bool g_bHeadshot[MAXPLAYERS + 1] = {false, ...};
bool g_bRespawn[MAXPLAYERS + 1] = {false, ...};
Handle g_hBitchSlap[MAXPLAYERS + 1] = { null, ... };
int g_iBSCount[MAXPLAYERS + 1] = { -1, ... };
Handle g_hLowGravity[MAXPLAYERS + 1] = { null, ... };
Handle g_hHighGravity[MAXPLAYERS + 1] = { null, ... };
Handle g_hNoclip[MAXPLAYERS + 1] = { null, ... };
Database g_dDB = null;
bool g_bHosties = false;
bool g_bJail = false;
bool g_bKnockout = false;
// Pots
bool g_bReady = false;
ArrayList g_aT1Pot = null;
ArrayList g_aT2Pot = null;
ArrayList g_aCTPot = null;
bool g_bBusy[MAXPLAYERS + 1] = {false, ...};
Handle g_hDiceTimer[MAXPLAYERS + 1] = {null, ...};
ConVar g_cDebug = null;
bool g_bLateLoad = false;
enum struct DiceOption {
char Name[32];
bool Delete;
bool Debug;
}
#include "dice/sql.sp"
#include "dice/functions.sp"
#include "dice/configs.sp"
#include "dice/options.sp"
#include "dice/autodice.sp"
public Plugin myinfo =
{
name = "Dice - Dice that includes CT and 2 T dices",
author = "Bara",
description = "",
version = "1.0",
url = "github.com/Bara"
};
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
CreateNative("Dice_IsClientAssassine", Native_IsAssassine);
CreateNative("Dice_HasClientBhop", Native_HasClientBhop);
CreateNative("Dice_LoseAll", Native_LoseAll);
RegPluginLibrary("dice");
g_bLateLoad = late;
return APLRes_Success;
}
public void OnPluginStart()
{
RegConsoleCmd("sm_w", Command_Dice);
RegConsoleCmd("sm_autow", Command_AutoDice);
HookEvent("player_jump", Event_PlayerJump);
HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Pre);
HookEvent("round_start", Event_RoundStart);
HookEvent("round_end", Event_RoundEnd);
HookEvent("smokegrenade_detonate", Event_SmokeDetonate, EventHookMode_Post);
HookEvent("decoy_started", Event_DecoyStarted, EventHookMode_Pre);
AutoExecConfig_SetCreateFile(true);
AutoExecConfig_SetFile("plugin.dice");
g_cDebug = AutoExecConfig_CreateConVar("dice_debug", "0", "Enable/Disable debug mode for dice", _, true, 0.0, true, 1.0);
AutoExecConfig_ExecuteFile();
AutoExecConfig_CleanFile();
CSetPrefix("{green}[Dice]{default}");
g_bHosties = LibraryExists("hosties");
g_bJail = LibraryExists("jail");
g_bKnockout = LibraryExists("knockout");
if (g_bLateLoad)
{
g_bReady = ReadDiceOptions();
}
g_iClip1 = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1");
if (g_iClip1 == -1)
{
SetFailState("Unable to find offset for clip.");
}
g_hAutoCTDice = RegClientCookie("dice_auto_ct_dice", "Auto for T-Dice", CookieAccess_Private);
g_hAutoT1Dice = RegClientCookie("dice_auto_t1_dice", "Auto for T-Dice", CookieAccess_Private);
g_hAutoT2Dice = RegClientCookie("dice_auto_t2_dice", "Auto for T-Dice", CookieAccess_Private);
LoopClients(i)
{
if (!AreClientCookiesCached(i))
{
continue;
}
SDKHook(i, SDKHook_OnTakeDamageAlive, OnTakeDamageAlive);
OnClientCookiesCached(i);
}
}
public void OnClientCookiesCached(int client)
{
char sBuffer[4];
GetClientCookie(client, g_hAutoCTDice, sBuffer, sizeof(sBuffer));
g_bAutoCTDice[client] = view_as<bool>(StringToInt(sBuffer));
GetClientCookie(client, g_hAutoT1Dice, sBuffer, sizeof(sBuffer));
g_bAutoT1Dice[client] = view_as<bool>(StringToInt(sBuffer));
GetClientCookie(client, g_hAutoT2Dice, sBuffer, sizeof(sBuffer));
g_bAutoT2Dice[client] = view_as<bool>(StringToInt(sBuffer));
}
public void OnAllPluginsLoaded()
{
if (LibraryExists("hosties"))
{
g_bHosties = true;
}
else if (LibraryExists("jail"))
{
g_bJail = true;
}
else if (LibraryExists("knockout"))
{
g_bKnockout = true;
}
if (!STAMM_IsAvailable())
{
SetFailState("Can't Load Feature, Stamm is not installed!");
}
STAMM_RegisterFeature("VIP SecondDice");
}
public int STAMM_OnClientRequestFeatureInfo(int client, int block, Handle &array)
{
PushArrayString(array, "Zugang zum 2. T-Würfel");
}
public void OnLibraryAdded(const char[] name)
{
if (StrEqual(name, "hosties"))
{
g_bHosties = true;
}
else if (StrEqual(name, "jail"))
{
g_bJail = true;
}
else if (StrEqual(name, "knockout"))
{
g_bKnockout = true;
}
}
public void OnLibraryRemoved(const char[] name)
{
if (StrEqual(name, "hosties"))
{
g_bHosties = false;
}
else if (StrEqual(name, "jail"))
{
g_bJail = false;
}
else if (StrEqual(name, "knockout"))
{
g_bKnockout = false;
}
}
public void OnMapStart()
{
PrecacheSoundAny(DICE_SOUND);
AddFileToDownloadsTable("sound/" ... DICE_SOUND);
PrecacheSoundAny(NEGATIVE_SOUND);
AddFileToDownloadsTable("sound/" ... NEGATIVE_SOUND);
PrecacheSoundAny(NEUTRAL_SOUND);
AddFileToDownloadsTable("sound/" ... NEUTRAL_SOUND);
PrecacheSoundAny(POSITIVE_SOUND);
AddFileToDownloadsTable("sound/" ... POSITIVE_SOUND);
PrecacheSoundAny(JIHAD_SOUND, true);
AddFileToDownloadsTable("sound/" ... JIHAD_SOUND);
PrecacheSoundAny(EXPLOSION_SOUND, true);
AddFileToDownloadsTable("sound/" ... EXPLOSION_SOUND);
// g_bReady = false;
// Create hostage zone to fix for shield option
int iEntity = -1;
if((iEntity = FindEntityByClassname(iEntity, "func_hostage_rescue")) == -1) {
int iHostageRescueEnt = CreateEntityByName("func_hostage_rescue");
DispatchKeyValue(iHostageRescueEnt, "targetname", "fake_hostage_rescue");
DispatchKeyValue(iHostageRescueEnt, "origin", "-3141 -5926 -5358");
DispatchSpawn(iHostageRescueEnt);
}
}
public int Native_IsAssassine(Handle plugin, int numParams)
{
return g_bAssassine[GetNativeCell(1)];
}
public int Native_HasClientBhop(Handle plugin, int numParams)
{
return g_bBhop[GetNativeCell(1)];
}
public int Native_LoseAll(Handle plugin, int numParams)
{
return g_bLose[GetNativeCell(1)];
}
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_OnTakeDamageAlive, OnTakeDamageAlive);
}
public void OnClientDisconnect(int client)
{
ResetDice(client);
}
public Action OnTakeDamageAlive(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int HitGroup)
{
if (!IsClientValid(victim))
{
return Plugin_Continue;
}
if (g_bNoFallDamage[victim] && damagetype & DMG_FALL)
{
return Plugin_Handled;
}
if (IsClientValid(attacker))
{
if (g_bHosties)
{
if (IsClientInLastRequest(attacker) || IsClientInLastRequest(victim))
{
return Plugin_Continue;
}
}
if (g_bTollpatsch[attacker])
{
bool bDamage = view_as<bool>(GetRandomInt(0, 1));
if (!bDamage)
{
damage = 0.0;
return Plugin_Changed;
}
}
if (g_bMoreDamage[attacker])
{
damage *= g_fDamage[attacker];
return Plugin_Changed;
}
if (g_bLessDamage[victim])
{
damage /= g_fDamage[victim];
return Plugin_Changed;
}
if (g_bHeadshot[victim] && damagetype & CS_DMG_HEADSHOT)
{
return Plugin_Handled;
}
if (g_bAWP[attacker])
{
int iEntity = GetEntPropEnt(attacker, Prop_Send, "m_hActiveWeapon");
if (!IsValidEntity(iEntity))
{
return Plugin_Continue;
}
char sClass[32];
GetEntityClassname(iEntity, sClass, sizeof(sClass));
if (StrContains(sClass, "awp", false) != -1)
{
g_bAWP[attacker] = false;
damage = 0.0;
return Plugin_Changed;
}
}
}
return Plugin_Continue;
}
public Action FGrenades_OnSwitchMode(int client, DecoyMode previousmode, DecoyMode &newmode, int weapon)
{
if (newmode != g_dmFuturistic[client])
{
newmode = g_dmFuturistic[client];
return Plugin_Handled;
}
return Plugin_Continue;
}
public Action Command_Dice(int client, int args)
{
if (Outbreak_IsHideActive() || IsWarActive())
{
CReplyToCommand(client, "Dice ist im %s deaktiviert.", Outbreak_IsHideActive() ? "Hide&Seek" : "Krieg");
return Plugin_Handled;
}
if (!g_bReady)
{
CReplyToCommand(client, "Die Würfel sind noch nicht gezinkt.");
return Plugin_Handled;
}
char sOption[32];
if (g_cDebug.BoolValue)
{
GetCmdArg(1, sOption, sizeof(sOption));
bool bReset = false;
if (!CheckCommandAccess(client, "sm_admin", ADMFLAG_ROOT, true))
{
sOption[0] = '\0';
}
if (bReset || strlen(sOption) < 2)
{
sOption[0] = '\0';
}
}
if (IsClientValid(client))
{
if (IsPlayerAlive(client))
{
if ((g_bJail && Jail_IsClientCapitulate(client)) || (g_bKnockout && IsClientKnockout(client)))
{
return Plugin_Handled;
}
int team = GetClientTeam(client);
bool bAccess = false;
if (team == CS_TEAM_CT && g_iCount[client] == 0)
{
bAccess = true;
}
else if (team == CS_TEAM_T)
{
if (g_iCount[client] == 0)
{
bAccess = true;
}
else if (g_iCount[client] == 1)
{
if (STAMM_HaveClientFeature(client))
{
bAccess = true;
}
else
{
CReplyToCommand(client, "Sie haben nicht den nötigen Stamm Rank um ein zweites mal zu würfeln.");
}
}
}
if (bAccess)
{
if (!g_bBusy[client] && g_hDiceTimer[client] == null)
{
g_bBusy[client] = true;
EmitSoundToClientAny(client, DICE_SOUND);
Panel panel = new Panel();
panel.SetTitle("Der Würfel rollt...");
panel.DrawText("(Glücksspiel kann süchtig machen!)");
panel.Send(client, Panel_Nothing, 3);
delete panel;
DataPack pack = new DataPack();
pack.WriteCell(GetClientUserId(client));
pack.WriteCell(team);
pack.WriteString(sOption);
g_hDiceTimer[client] = CreateTimer(2.0, Timer_Dice, pack);
}
else
{
CReplyToCommand(client, "Der Würfel rollt gerade...");
}
}
else
{
CReplyToCommand(client, "Du hast schon %s%dx %sgewürfelt.", SPECIAL, g_iCount[client], TEXT);
}
}
else
{
CReplyToCommand(client, "Das macht kein Sinn...");
}
}
return Plugin_Handled;
}
public Action Timer_Dice(Handle timer, DataPack pack)
{
pack.Reset();
int client = GetClientOfUserId(pack.ReadCell());
int team = pack.ReadCell();
char sOption[32];
pack.ReadString(sOption, sizeof(sOption));
delete pack;
if (IsClientValid(client))
{
if (IsPlayerAlive(client))
{
// Types: 0 - Negative, 1 - Neutral, 2 - Positive
int type = -1;
Panel panel = new Panel();
if (g_iCount[client] == 0)
{
if (team == CS_TEAM_T)
{
g_iCount[client]++;
int iIndex = GetRandomInt(0, g_aT1Pot.Length - 1);
DiceOption Option;
g_aT1Pot.GetArray(iIndex, Option, sizeof(Option));
int iCount = 0;
for (int i = 0; i < g_aT1Pot.Length; i++)
{
DiceOption tmp;
g_aT1Pot.GetArray(i, tmp, sizeof(tmp));
if (StrEqual(tmp.Name, Option.Name, false))
{
iCount++;
}
}
float fChance = float(g_aT1Pot.Length) / float(100) * float (iCount);
if (Option.Delete)
{
g_aT1Pot.Erase(iIndex);
}
g_aT1Pot.Sort(Sort_Random, Sort_Integer);
if (strlen(sOption) > 2)
{
strcopy(Option.Name, sizeof(DiceOption::Name), sOption);
Option.Debug = true;
}
type = GiveDiceOption(client, Option, CS_TEAM_T, 1, panel, fChance);
}
else if (team == CS_TEAM_CT)
{
g_iCount[client]++;
int iIndex = GetRandomInt(0, g_aCTPot.Length - 1);
DiceOption Option;
g_aCTPot.GetArray(iIndex, Option, sizeof(Option));
int iCount = 0;
for (int i = 0; i < g_aCTPot.Length; i++)
{
DiceOption tmp;
g_aCTPot.GetArray(i, tmp, sizeof(tmp));
if (StrEqual(tmp.Name, Option.Name, false))
{
iCount++;
}
}
float fChance = float(g_aCTPot.Length) / float(100) * float (iCount);
if (Option.Delete)
{
g_aCTPot.Erase(iIndex);
}
g_aCTPot.Sort(Sort_Random, Sort_Integer);
if (strlen(sOption) > 2)
{
strcopy(Option.Name, sizeof(DiceOption::Name), sOption);
Option.Debug = true;
}
type = GiveDiceOption(client, Option, CS_TEAM_CT, 1, panel, fChance);
}
}
else
{
if (GetClientTeam(client) == CS_TEAM_T)
{
g_iCount[client]++;
int iIndex = GetRandomInt(0, g_aT2Pot.Length - 1);
DiceOption Option;
g_aT2Pot.GetArray(iIndex, Option, sizeof(Option));
int iCount = 0;
for (int i = 0; i < g_aT2Pot.Length; i++)
{
DiceOption tmp;
g_aT2Pot.GetArray(i, tmp, sizeof(tmp));
if (StrEqual(tmp.Name, Option.Name, false))
{
iCount++;
}
}
float fChance = float(g_aT2Pot.Length) / float(100) * float (iCount);
if (Option.Delete)
{
g_aT2Pot.Erase(iIndex);
}
g_aT2Pot.Sort(Sort_Random, Sort_Integer);
if (strlen(sOption) > 2)
{
strcopy(Option.Name, sizeof(DiceOption::Name), sOption);
Option.Debug = true;
}
type = GiveDiceOption(client, Option, CS_TEAM_T, 2, panel, fChance);
}
}
panel.Send(client, Panel_Nothing, 4);
delete panel;
if (type == 0)
{
EmitSoundToClientAny(client, NEGATIVE_SOUND);
}
else if (type == 1)
{
EmitSoundToClientAny(client, NEUTRAL_SOUND);
}
else if (type == 2)
{
EmitSoundToClientAny(client, POSITIVE_SOUND);
}
if (team == CS_TEAM_T && g_iCount[client] == 1 && g_bAutoT2Dice[client])
{
CPrintToChat(client, "Dein 2. Würfel rollt in 3 Sekunden...");
CreateTimer(3.0, Timer_AutoDice, GetClientUserId(client));
}
}
else
{
CPrintToChat(client, "Das macht keinen Sinn mehr...");
}
g_bBusy[client] = false;
g_hDiceTimer[client] = null;
}
return Plugin_Stop;
}
// Events
public Action Event_PlayerJump(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (IsClientValid(client) && IsPlayerAlive(client) && g_bLongjump[client])
{
Longjump(client);
}
return Plugin_Handled;
}
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
if (GetAliveTPlayers() == 1 && GetAliveCTPlayers() >= 1)
{
LoopClients(client)
{
if (IsPlayerAlive(client))
{
SetEntProp(client, Prop_Send, "m_ArmorValue", 0, 1);
}
}
}
int client = GetClientOfUserId(event.GetInt("userid"));
if (!IsClientValid(client))
{
return Plugin_Continue;
}
LoopClients(i)
{
if (IsClientInGame(i) && IsPlayerAlive(i) && g_iLover[i] == client)
{
CPrintToChat(i, "Dein Liebling ist gefallen, dein Herz gebrochen und nun fällst auch du.");
ForcePlayerSuicide(i);
}
}
if (GetAliveTPlayers() >= 1 && GetAliveCTPlayers() >= 1)
{
if (g_bRespawn[client])
{
if (GetRandomInt(1, 2) == 1)
{
CPrintToChat(client, "Du hast durch den Würfel eine 2. Chance verdient! Respawn in 2 Sekunden...");
CreateTimer(2.0, Timer_RespawnPlayer, GetClientUserId(client));
}
}
}
int attacker = GetClientOfUserId(event.GetInt("attacker"));
char sWeapon[32];
event.GetString("weapon", sWeapon, sizeof(sWeapon));
if (IsClientValid(attacker))
{
if (g_bAssassine[attacker] && (StrContains(sWeapon, "awp", false) == -1))
{
event.BroadcastDisabled = true;
return Plugin_Changed;
}
}
return Plugin_Continue;
}
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (IsClientValid(client))
{
CreateTimer(0.5, Timer_AutoDice, GetClientUserId(client));
SetEntityGravity(client, 1.0);
ResetDice(client);
}
return Plugin_Handled;
}
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
g_bReady = ReadDiceOptions();
return Plugin_Continue;
}
public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
LoopClients(client)
{
if (IsPlayerAlive(client))
{
SetEntProp(client, Prop_Send, "m_ArmorValue", 0, 1);
}
}
return Plugin_Handled;
}
public Action Event_SmokeDetonate(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
int entity = event.GetInt("entityid");
if (!IsClientValid(client) || !IsValidEntity(entity))
{
return Plugin_Continue;
}
DataPack pack = new DataPack();
CreateDataTimer(1.0, Timer_CheckPlayers, pack, TIMER_FLAG_NO_MAPCHANGE);
pack.WriteCell(GetClientUserId(client));
pack.WriteCell(EntIndexToEntRef(entity));
return Plugin_Continue;
}
public Action Event_DecoyStarted(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
int entity = event.GetInt("entityid");
if (!IsClientValid(client))
{
return Plugin_Continue;
}
FGrenades_SwitchMode(client, DecoyMode_Normal);
if (!g_bDecoy[client] || !IsValidEntity(entity))
{
return Plugin_Continue;
}
AcceptEntityInput(entity, "kill");
float fOldPos[3];
GetClientAbsOrigin(client, fOldPos);
float fPos[3];
fPos[0] = event.GetFloat("x");
fPos[1] = event.GetFloat("y");
fPos[2] = (event.GetFloat("z") + 5.0);
TeleportEntity(client, fPos, NULL_VECTOR, NULL_VECTOR);
bool stuck = WillClientStuck(client);
if (stuck)
{
TeleportEntity(client, fOldPos, NULL_VECTOR, NULL_VECTOR);
CPrintToChat(client, "Du wurdest zurück teleportiert, weil du sonst stucken würdest.");
}
g_bDecoy[client] = false;
return Plugin_Continue;
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
if (IsClientValid(client) && IsPlayerAlive(client))
{
if (g_bJihad[client])
{
if (buttons & IN_USE)
{
int iEntity = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
if (!IsValidEntity(iEntity))
{
return Plugin_Continue;
}
char sClassname[32];
GetEntityClassname(iEntity, sClassname, sizeof(sClassname));
if (StrContains(sClassname, "c4", false) == -1)
{
return Plugin_Continue;
}
StartJihad(client);
g_bJihad[client] = false;
}
}
if (g_bRentner[client])
{
if (buttons & IN_JUMP)
{
if (GetEntityFlags(client) & FL_ONGROUND && GetEntityMoveType(client) != MOVETYPE_LADDER)
{
buttons &= ~IN_JUMP;
}
}
}
if (g_bFroggyjump[client])
{
if (GetEntityFlags(client) & FL_ONGROUND)
{
g_iFroggyAir[client] = 0;
g_bFroggyPressed[client] = false;
}
else
{
if (buttons & IN_JUMP)
{
if (!g_bFroggyPressed[client])
{
if (g_iFroggyAir[client]++ == 1)
{
Froggyjump(client);
}
}
g_bFroggyPressed[client] = true;
}
else
{
g_bFroggyPressed[client] = false;
}
}
}
if (g_bBhop[client])
{
if (buttons & IN_JUMP)
{
if (!(GetEntityMoveType(client) & MOVETYPE_LADDER))
{
SetEntPropFloat(client, Prop_Send, "m_flStamina", 0.0);
if (!(GetEntityFlags(client) & FL_ONGROUND))
{
buttons &= ~IN_JUMP;
}
}
}
}
if (g_bMirrorMovement[client])
{
vel[1] = -vel[1];
if (buttons & IN_MOVELEFT) {
buttons &= ~IN_MOVELEFT;
buttons |= IN_MOVERIGHT;
} else if (buttons & IN_MOVERIGHT) {
buttons &= ~IN_MOVERIGHT;
buttons |= IN_MOVELEFT;
}
vel[2] = -vel[2];
if (buttons & IN_DUCK) {
buttons &= ~IN_DUCK;
buttons |= IN_JUMP;
} else if (buttons & IN_JUMP) {
buttons &= ~IN_JUMP;
buttons |= IN_DUCK;
}
vel[0] = -vel[0];
if (buttons & IN_FORWARD) {
buttons &= ~IN_FORWARD;
buttons |= IN_BACK;
} else if (buttons & IN_BACK) {
buttons &= ~IN_BACK;
buttons |= IN_FORWARD;
}
}
if (g_bZombie[client])
{
if (buttons & IN_JUMP)
{
if (GetEntityFlags(client) & FL_ONGROUND && GetEntityMoveType(client) != MOVETYPE_LADDER)
{
buttons &= ~IN_JUMP;
}
}
if (!(buttons & IN_DUCK))
{
buttons ^= IN_DUCK;
}
return Plugin_Changed;
}
// Remove fire with water contact
if (GetEntityFlags(client) & FL_INWATER)
{
int iFire = GetEntPropEnt(client, Prop_Data, "m_hEffectEntity");
if (IsValidEdict(iFire))
{
SetEntPropFloat(iFire, Prop_Data, "m_flLifetime", 0.0);
}
if (g_hHighGravity[client] != null)
{
SetEntityGravity(client, 1.0);
g_bInWater[client] = true;
}
}
else if (g_bInWater[client] && GetEntityFlags(client) & FL_ONGROUND || GetEntityFlags(client) & FL_DUCKING)
{
CreateTimer(0.5, Timer_ResetInWater, GetClientUserId(client));