-
Notifications
You must be signed in to change notification settings - Fork 5
/
csdm_itemmode.sma
1036 lines (912 loc) · 23.2 KB
/
csdm_itemmode.sma
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
/**
* csdm_itemmode.sma
* Allows for Counter-Strike to be played as DeathMatch.
*
* CSDM Item Mode - Spawns different types of items all over the map.
*
* (C)2003-2006 Borja "FALUCO" Ferrer
* (C)2003-2006 David "BAILOPAN" Anderson
*
* Give credit where due.
* Share the source - it sets you free
* http://www.opensource.org/
* http://www.gnu.org/
*/
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <csdm>
#define MAX_ITEMS 250
#define MAX_ENTS 1400
#define MAX_PACKS 50
#define ITEMTYPES_NUM 42
#define SLOTS 12
#define ITEM_LONGJUMP 31
#define ITEM_MEDKIT 32
#define ITEM_BATTERY 33
#define ITEM_PISTOLAMMO 34
#define ITEM_RIFLEAMMO 35
#define ITEM_SHOTAMMO 36
#define ITEM_SMGAMMO 37
#define ITEM_AWPAMMO 38
#define ITEM_PARAAMMO 39
#define ITEM_FULLAMMO 40
#define ITEM_ARMOR 41
#define ITEM_PACK (MAX_ITEMS + 1)
#define CWRAP(%1,%2) (containi(%1,%2) != -1)
// Config variables
new bool:g_Enabled = false
new bool:g_EnabledCfg = false
new bool:g_droppacks = true
new g_battery = 15
new g_medkit = 15
new Float:g_itemTime = 20.0
new Float:g_packTime = 20.0
// Entity arrays
new g_EntModels[][] =
{
"",
"models/w_p228.mdl",
"",
"models/w_scout.mdl",
"models/w_hegrenade.mdl",
"models/w_xm1014.mdl",
"",
"models/w_mac10.mdl",
"models/w_aug.mdl",
"models/w_smokegrenade.mdl",
"models/w_elite.mdl",
"models/w_fiveseven.mdl",
"models/w_ump45.mdl",
"models/w_sg550.mdl",
"models/w_galil.mdl",
"models/w_famas.mdl",
"models/w_usp.mdl",
"models/w_glock18.mdl",
"models/w_awp.mdl",
"models/w_mp5.mdl",
"models/w_m249.mdl",
"models/w_m3.mdl",
"models/w_m4a1.mdl",
"models/w_tmp.mdl",
"models/w_g3sg1.mdl",
"models/w_flashbang.mdl",
"models/w_deagle.mdl",
"models/w_sg552.mdl",
"models/w_ak47.mdl",
"",
"models/w_p90.mdl",
"models/w_longjump.mdl",
"models/w_medkit.mdl",
"models/w_battery.mdl",
"models/w_357ammobox.mdl",
"models/w_9mmarclip.mdl",
"models/w_shotbox.mdl",
"models/w_9mmclip.mdl",
"models/w_crossbow_clip.mdl",
"models/w_chainammo.mdl",
"models/w_isotopebox.mdl",
"models/w_assault.mdl"
}
new g_EntClass[][] =
{
"",
"csdmw_p228",
"",
"csdmw_scout",
"csdmw_hegrenade",
"csdmw_xm1014",
"",
"csdmw_mac10",
"csdmw_aug",
"csdmw_smokegrenade",
"csdmw_elite",
"csdmw_fiveseven",
"csdmw_ump45",
"csdmw_sg550",
"csdmw_galil",
"csdmw_famas",
"csdmw_usp",
"csdmw_glock18",
"csdmw_awp",
"csdmw_mp5navy",
"csdmw_m249",
"csdmw_m3",
"csdmw_m4a1",
"csdmw_tmp",
"csdmw_g3sg1",
"csdmw_flashbang",
"csdmw_deagle",
"csdmw_sg552",
"csdmw_ak47",
"",
"csdmw_p90",
"csdm_longjump",
"csdm_medkit",
"csdm_battery",
"csdm_pistolammo",
"csdm_rifleammo",
"csdm_shotammo",
"csdm_smgammo",
"csdm_awpammo",
"csdm_paraammo",
"csdm_fullammo",
"csdm_armor"
}
stock g_Weap2Ammo[] =
{
0,
ITEM_PISTOLAMMO,//CSW_P228
0,
ITEM_RIFLEAMMO, //CSW_SCOUT
0, //CSW_HEGRENADE
ITEM_SHOTAMMO, //CSW_XM1014
0, //CSW_C4
ITEM_SMGAMMO, //CSW_MAC10
ITEM_RIFLEAMMO, //CSW_AUG
0, //CSW_SMOKEGRENADE
ITEM_PISTOLAMMO,//CSW_ELITE
ITEM_PISTOLAMMO,//CSW_FIVESEVEN
ITEM_SMGAMMO, //CSW_UMP45
ITEM_RIFLEAMMO, //CSW_SG550
ITEM_RIFLEAMMO, //CSW_GALIL
ITEM_RIFLEAMMO, //CSW_FAMAS
ITEM_PISTOLAMMO,//CSW_USP
ITEM_PISTOLAMMO,//CSW_GLOCK18
ITEM_AWPAMMO, //CSW_AWP
ITEM_SMGAMMO, //CSW_MP5NAVY
ITEM_PARAAMMO, //CSW_M249
ITEM_SHOTAMMO, //CSW_M3
ITEM_RIFLEAMMO, //CSW_M4A1
ITEM_SMGAMMO, //CSW_TMP
ITEM_RIFLEAMMO, //CSW_G3SG1
0, //CSW_FLASHBANG
ITEM_PISTOLAMMO,//CSW_DEAGLE
ITEM_RIFLEAMMO, //CSW_SG552
ITEM_RIFLEAMMO, //CSW_AK47
0, //CSW_KNIFE
ITEM_SMGAMMO //CSW_P90
}
new g_EntTable[MAX_ENTS] // Contains the item_id (1-250) in the entid position(0-1500)
new g_EntType[MAX_ITEMS] // Contains the item type (ammos, armor, ...) in the file order
new g_EntCount // Global item count in the map (deathpacks not included)
new g_EntVecs[MAX_ITEMS][3] // Contains the item position in the file order
new g_EntId[MAX_ITEMS] // Contains the entid (0-1500) in the file order
new bool:HasLongJump[33] = false
new bool:IsRestricted[ITEMTYPES_NUM] = false // Contains if an item is restricted or not
new bool:g_PackID[MAX_PACKS] = {true, ...} // If true the packid can be used, else it's being use by another pack
new g_PackContents[MAX_PACKS][SLOTS] // Contains the pack contents in the packid position(1-64)
// [0]=size [1]=entid [2]=packid [3]=longjump [4...]=weapons
new g_MaxPlayers
new g_AllocStr
//Tampering with the author and name lines can violate the copyrights
new PLUGINNAME[] = "CSDM Item Mode"
new VERSION[] = CSDM_VERSION
new AUTHORS[] = "FALUCO"
public csdm_Init(const version[])
{
if (version[0] == 0)
{
set_fail_state("CSDM failed to load.")
return
}
}
public csdm_CfgInit()
{
g_AllocStr = engfunc(EngFunc_AllocString, "info_target")
csdm_reg_cfg("items", "cfgmain")
csdm_reg_cfg("item_restrictions", "cfgrestricts")
}
public plugin_init()
{
register_plugin(PLUGINNAME, VERSION, AUTHORS)
register_cvar("itemmode_version", CSDM_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
register_forward(FM_Touch, "hook_touch")
g_MaxPlayers = get_maxplayers()
}
public plugin_precache()
{
precache_model("models/w_medkit.mdl")
precache_model("models/w_battery.mdl")
precache_model("models/w_357ammobox.mdl") //Pistol Ammo
precache_model("models/w_shotbox.mdl") //Shotgun Ammo
precache_model("models/w_9mmclip.mdl") //SMG Ammo
precache_model("models/w_9mmarclip.mdl") //Rifle Ammo
precache_model("models/w_crossbow_clip.mdl") //Awp Ammo
precache_model("models/w_isotopebox.mdl") //Full ammo
precache_model("models/w_isotopeboxt.mdl") //Full ammo
precache_model("models/w_chainammo.mdl") //Full ammo
precache_model("models/w_weaponbox.mdl") //Drop pack
precache_model("models/w_assault.mdl") //assaultsuit
precache_model("models/w_longjump.mdl") //longjump - thanks asskicr
precache_model("models/w_longjumpt.mdl") //"
precache_sound("items/smallmedkit1.wav")
precache_sound("items/gunpickup2.wav")
precache_sound("items/suitchargeok1.wav")
precache_sound("items/ammopickup2.wav")
precache_sound("items/clipinsert1.wav")
return PLUGIN_CONTINUE
}
public csdm_StateChange(csdm_state)
{
if (g_Enabled && csdm_state == CSDM_DISABLE)
{
destroyAllItems()
destroyAllPacks()
g_Enabled = false
}
if (g_EnabledCfg && csdm_state == CSDM_ENABLE)
{
g_Enabled = true
ReadFile()
SetEnts()
}
}
public cfgmain(readAction, line[], section[])
{
if (!csdm_active())
return
if (readAction == CFG_READ)
{
new setting[24], sign[3], value[32]
parse(line, setting, 23, sign, 2, value, 31)
if (equali(setting, "enabled"))
{
g_Enabled = str_to_num(value) ? true : false
g_EnabledCfg = g_Enabled
}
else if (equali(setting, "drop_packs"))
{
g_droppacks = str_to_num(value) ? true : false
}
else if (equali(setting, "battery"))
{
g_battery = str_to_num(value)
}
else if (equali(setting, "medkit"))
{
g_medkit = str_to_num(value)
}
else if (equali(setting, "item_time"))
{
g_itemTime = str_to_float(value)
}
else if (equali(setting, "item_time"))
{
g_itemTime = str_to_float(value)
g_itemTime = (g_itemTime > 30.0) ? 30.0 : g_itemTime
}
}
}
public cfgrestricts(readAction, line[], section[])
{
if (!csdm_active())
return
if (readAction == CFG_READ)
{
new itemname[24]
parse(line, itemname, 23)
if (equali(itemname, "longjump"))
{
IsRestricted[ITEM_LONGJUMP] = true
}
else if (equali(itemname, "medkit"))
{
IsRestricted[ITEM_MEDKIT] = true
}
else if (equali(itemname, "battery"))
{
IsRestricted[ITEM_BATTERY] = true
}
else if (equali(itemname, "pistolammo"))
{
IsRestricted[ITEM_PISTOLAMMO] = true
}
else if (equali(itemname, "rifleammo"))
{
IsRestricted[ITEM_RIFLEAMMO] = true
}
else if (equali(itemname, "shotammo"))
{
IsRestricted[ITEM_SHOTAMMO] = true
}
else if (equali(itemname, "smgammo"))
{
IsRestricted[ITEM_SMGAMMO] = true
}
else if (equali(itemname, "awpammo"))
{
IsRestricted[ITEM_AWPAMMO] = true
}
else if (equali(itemname, "paraammo"))
{
IsRestricted[ITEM_PARAAMMO] = true
}
else if (equali(itemname, "fullammo"))
{
IsRestricted[ITEM_FULLAMMO] = true
}
else if (equali(itemname, "armor"))
{
IsRestricted[ITEM_ARMOR] = true
} else {
new weapname[24], weaptype
format(weapname, 23, "weapon_%s", itemname)
weaptype = getWeapId(weapname)
if (weaptype != 0)
IsRestricted[weaptype] = true
else
log_amx("^"%s^" is not a valid name. Check your restrictions for item mode.", itemname)
}
}
if (readAction == CFG_RELOAD)
{
// Reset all restrictions
arrayset(IsRestricted, false, ITEMTYPES_NUM)
}
if (readAction == CFG_DONE)
{
destroyAllItems()
destroyAllPacks()
if (g_Enabled)
{
ReadFile()
SetEnts()
}
}
}
ReadFile()
{
new Map[32], config[32], File[64]
get_mapname(Map, 31)
get_localinfo("amxx_configsdir", config, 31)
format(File, 63, "%s\csdm\items\ents_%s.cfg", config, Map)
g_EntCount = 1
if (file_exists(File))
{
new Data[51], len, EntName[25]
new line = 0
new pos[3][8]
while ((g_EntCount < MAX_ITEMS) && ((line = read_file(File, line, Data, 50, len)) != 0))
{
if (strlen(Data) < 2)
continue
parse(Data, EntName, 24, pos[0], 7, pos[1], 7, pos[2], 7)
g_EntVecs[g_EntCount][0] = str_to_num(pos[0])
g_EntVecs[g_EntCount][1] = str_to_num(pos[1])
g_EntVecs[g_EntCount][2] = str_to_num(pos[2])
if (CWRAP(EntName, "item_longjump") && !(IsRestricted[ITEM_LONGJUMP]))
g_EntType[g_EntCount] = ITEM_LONGJUMP
else if (CWRAP(EntName, "item_healthkit") && !(IsRestricted[ITEM_MEDKIT]))
g_EntType[g_EntCount] = ITEM_MEDKIT
else if (CWRAP(EntName, "item_battery") && !(IsRestricted[ITEM_BATTERY]))
g_EntType[g_EntCount] = ITEM_BATTERY
else if (CWRAP(EntName, "pistol_ammo") && !(IsRestricted[ITEM_PISTOLAMMO]))
g_EntType[g_EntCount] = ITEM_PISTOLAMMO
else if (CWRAP(EntName, "rifle_ammo") && !(IsRestricted[ITEM_RIFLEAMMO]))
g_EntType[g_EntCount] = ITEM_RIFLEAMMO
else if (CWRAP(EntName, "shotgun_ammo") && !(IsRestricted[ITEM_SHOTAMMO]))
g_EntType[g_EntCount] = ITEM_SHOTAMMO
else if (CWRAP(EntName, "smg_ammo") && !(IsRestricted[ITEM_SMGAMMO]))
g_EntType[g_EntCount] = ITEM_SMGAMMO
else if (CWRAP(EntName, "full_ammo") && !(IsRestricted[ITEM_FULLAMMO]))
g_EntType[g_EntCount] = ITEM_FULLAMMO
else if (CWRAP(EntName, "armor") && !(IsRestricted[ITEM_ARMOR]))
g_EntType[g_EntCount] = ITEM_ARMOR
else if (CWRAP(EntName, "awp_ammo") && !(IsRestricted[ITEM_AWPAMMO]))
g_EntType[g_EntCount] = ITEM_AWPAMMO
else if (CWRAP(EntName, "para_ammo") && !(IsRestricted[ITEM_PARAAMMO]))
g_EntType[g_EntCount] = ITEM_PARAAMMO
else
{
new weaptype = getWeapId(EntName)
if (weaptype != 0 && !(IsRestricted[weaptype]))
g_EntType[g_EntCount] = weaptype
}
g_EntCount++
}
log_amx("Loaded %d items for map %s.", g_EntCount, Map)
} else {
log_amx("No items file found (%s)", File)
g_Enabled = false
}
}
SetEnts()
{
if (g_EntCount > 1)
for (new i = 1; i < g_EntCount; i++)
g_EntId[i] = MakeEnt(i)
}
MakeEnt(item_id)
{
new entid = CreateEntId()
if (!entid)
return 0
new Float:Vec[3]
IVecFVec(g_EntVecs[item_id], Vec)
new type = g_EntType[item_id]
g_EntTable[entid] = item_id
set_pev(entid, pev_classname, g_EntClass[type])
engfunc(EngFunc_SetModel, entid, g_EntModels[type])
set_pev(entid, pev_origin, Vec)
set_pev(entid, pev_solid, 1)
set_pev(entid, pev_movetype, 6)
if (type <= 30) // Is it a Weapon?
{
set_pev(entid, pev_angles, Float:{0.0, 0.0, 0.0})
set_pev(entid, pev_velocity, Float:{0.0, 0.0, 0.0})
}
return entid
}
CreateEntId()
{
return engfunc(EngFunc_CreateNamedEntity, g_AllocStr)
}
public hook_touch(ptr, ptd)
{
if (!g_Enabled)
return FMRES_HANDLED
if (!g_EntTable[ptr])
return FMRES_HANDLED
if (ptd < 1 || ptd > g_MaxPlayers)
return FMRES_HANDLED
new item_id[1], item_type
item_id[0] = g_EntTable[ptr]
item_type = (g_EntTable[ptr] < MAX_ITEMS) ? g_EntType[g_EntTable[ptr]] : g_EntTable[ptr]
// Death Pack
if (item_type > ITEM_PACK)
{
new packid = item_type - ITEM_PACK
new maxiter = g_PackContents[packid][0] + 4
new weap, weapname[24]
new value = get_user_armor(ptd)
if (value + 15 < 100)
set_pev(ptd, pev_armorvalue, float(value + 15))
else
set_pev(ptd, pev_armorvalue, float(100))
value = get_user_health(ptd)
if (value + 15 < 100)
set_pev(ptd, pev_health, float(value + 15))
else
set_pev(ptd, pev_health, float(100))
emit_sound(ptd, CHAN_ITEM, "items/ammopickup2.wav", 0.85, ATTN_NORM, 0, 150)
for (new i = 4; i < maxiter; i++)
{
weap = g_PackContents[packid][i]
if (weap == CSW_C4)
continue
if (CanGetWeapon(ptd, weap))
{
get_weaponname(weap, weapname, 23)
csdm_give_item(ptd, weapname)
}
GiveAmmo(ptd, g_Weap2Ammo[weap])
}
if (g_PackContents[packid][3] == ITEM_LONGJUMP && !HasLongJump[ptd])
{
csdm_give_item(ptd, "item_longjump")
HasLongJump[ptd] = true
client_print(ptd, print_chat, "[CSDM] To use LongJump, press DUCK+JUMP while moving FORWARD!")
}
remove_task(packid)
engfunc(EngFunc_RemoveEntity, ptr)
g_EntTable[ptr] = 0
g_PackID[packid] = true
ZeroPack(packid)
return FMRES_HANDLED
}
// Ammo
if ((item_type >= 34) && (item_type <= 39))
{
if (CanGetAmmo(ptd, item_type))
{
GiveAmmo(ptd, item_type)
engfunc(EngFunc_RemoveEntity, ptr)
g_EntTable[ptr] = 0
g_EntId[item_id[0]] = 0
set_task(g_itemTime, "Replenish", 0, item_id, 1)
}
return FMRES_HANDLED
}
// Weapon
if ((item_type >= 1) && (item_type <= 30))
{
if (CanGetWeapon(ptd, item_type))
{
new weapname[24]
get_weaponname(item_type, weapname, 23)
csdm_give_item(ptd, weapname)
engfunc(EngFunc_RemoveEntity, ptr)
g_EntTable[ptr] = 0
g_EntId[item_id[0]] = 0
set_task(g_itemTime, "Replenish", 0, item_id, 1)
}
return FMRES_HANDLED
}
// Battery
if (item_type == ITEM_BATTERY)
{
new armor = get_user_armor(ptd)
if (armor < 100)
{
if (armor + g_battery < 100)
set_pev(ptd, pev_armorvalue, float(armor + g_battery))
else
set_pev(ptd, pev_armorvalue, float(100))
emit_sound(ptr, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
engfunc(EngFunc_RemoveEntity, ptr)
g_EntTable[ptr] = 0
g_EntId[item_id[0]] = 0
set_task(g_itemTime, "Replenish", 0, item_id, 1)
}
return FMRES_HANDLED
}
// Medkit
if (item_type == ITEM_MEDKIT)
{
new health = get_user_health(ptd)
if (health < 100)
{
if (health + g_medkit < 100)
set_pev(ptd, pev_health, float(health + g_medkit))
else
set_pev(ptd, pev_health, float(100))
emit_sound(ptr, CHAN_ITEM, "items/smallmedkit1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
engfunc(EngFunc_RemoveEntity, ptr)
g_EntTable[ptr] = 0
g_EntId[item_id[0]] = 0
set_task(g_itemTime, "Replenish", 0, item_id, 1)
}
return FMRES_HANDLED
}
// Armor
if (item_type == ITEM_ARMOR)
{
if (get_user_armor(ptd) < 100)
{
csdm_give_item(ptd, "item_assaultsuit")
engfunc(EngFunc_RemoveEntity, ptr)
g_EntTable[ptr] = 0
g_EntId[item_id[0]] = 0
set_task(g_itemTime, "Replenish", 0, item_id, 1)
}
return FMRES_HANDLED
}
// Full Ammo
if (item_type == ITEM_FULLAMMO)
{
if (CanGetAmmo(ptd, ITEM_PISTOLAMMO) || CanGetAmmo(ptd, ITEM_RIFLEAMMO) || CanGetAmmo(ptd, ITEM_SHOTAMMO) || CanGetAmmo(ptd, ITEM_SMGAMMO)
|| CanGetAmmo(ptd, ITEM_AWPAMMO) || CanGetAmmo(ptd, ITEM_PARAAMMO))
{
GiveAmmo(ptd, ITEM_PISTOLAMMO)
GiveAmmo(ptd, ITEM_RIFLEAMMO)
GiveAmmo(ptd, ITEM_SHOTAMMO)
GiveAmmo(ptd, ITEM_SMGAMMO)
GiveAmmo(ptd, ITEM_AWPAMMO)
GiveAmmo(ptd, ITEM_PARAAMMO)
engfunc(EngFunc_RemoveEntity, ptr)
g_EntTable[ptr] = 0
g_EntId[item_id[0]] = 0
set_task(g_itemTime, "Replenish", 0, item_id, 1)
}
return FMRES_HANDLED
}
// Longjump
if (item_type == ITEM_LONGJUMP)
{
if (!HasLongJump[ptd])
{
csdm_give_item(ptd, "item_longjump")
HasLongJump[ptd] = true
emit_sound(ptr, CHAN_ITEM, "items/clipinsert1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
engfunc(EngFunc_RemoveEntity, ptr)
g_EntTable[ptr] = 0
g_EntId[item_id[0]] = 0
set_task(g_itemTime, "Replenish", 0, item_id, 1)
client_print(ptd, print_chat, "[CSDM] To use LongJump, press DUCK+JUMP while moving FORWARD!")
}
return FMRES_HANDLED
}
return FMRES_HANDLED
}
public Replenish(item_id[])
{
g_EntId[item_id[0]] = MakeEnt(item_id[0])
emit_sound(g_EntId[item_id[0]], CHAN_ITEM, "items/suitchargeok1.wav", 0.85, ATTN_NORM, 0, 150)
}
public csdm_PostDeath(killer, victim, headshot, const weapon[])
{
if (!g_Enabled)
return
if (HasLongJump[victim])
HasLongJump[victim] = false
}
public csdm_RoundRestart()
{
if (!g_Enabled)
return
new players[32], num, player
get_players(players, num)
for (new i = 0; i < num; i++)
{
player = players[i]
if (HasLongJump[player] && is_user_alive(player))
csdm_give_item(player, "item_longjump")
}
destroyAllPacks()
destroyAllItems(false)
SetEnts()
}
public csdm_PreDeath(killer, victim, headshot, const weapon[])
{
if (!g_Enabled || !g_droppacks)
return
new packid = GetPackId()
if (packid < 0)
return
new entid = CreateEntId()
if (!entid)
{
g_PackID[packid] = true
return
}
new Float:Pos[3], Orig[3]
get_user_origin(victim, Orig)
IVecFVec(Orig, Pos)
g_EntTable[entid] = ITEM_PACK + packid
set_pev(entid, pev_classname, "csdm_deathpack")
engfunc(EngFunc_SetModel, entid, "models/w_weaponbox.mdl")
set_pev(entid, pev_origin, Pos)
set_pev(entid, pev_solid, 1)
set_pev(entid, pev_movetype, 6)
set_pev(entid, pev_owner, victim)
new Weapons[32], weapnum = 0
get_user_weapons(victim, Weapons, weapnum)
for (new i = 0; i < weapnum; i++)
{
g_PackContents[packid][i + 4] = Weapons[i]
}
if (HasLongJump[victim])
{
g_PackContents[packid][3] = ITEM_LONGJUMP
}
g_PackContents[packid][0] = weapnum
g_PackContents[packid][1] = entid
g_PackContents[packid][2] = packid
new info[2]
info[0] = entid
info[1] = packid
set_task(g_packTime, "DeletePack", packid, info, 2)
}
public DeletePack(pack_info[])
{
new packid = pack_info[1]
new entid = pack_info[0]
engfunc(EngFunc_RemoveEntity, entid)
g_PackID[packid] = true
g_EntTable[entid] = 0
ZeroPack(packid)
}
GetPackId()
{
for (new i = 1; i < MAX_PACKS; i++)
{
if (g_PackID[i])
{
g_PackID[i] = false
return i
}
}
return -1
}
ZeroPack(packid)
{
arrayset(g_PackContents[packid], 0, SLOTS)
}
public client_connect(id)
{
if (!g_Enabled)
return
HasLongJump[id] = false
}
public csdm_HandleDrop(id, weapon, death)
{
return (g_Enabled && g_droppacks) ? CSDM_DROP_REMOVE : CSDM_DROP_CONTINUE
}
bool:CanGetAmmo(id, ammotype)
{
switch (ammotype)
{
case ITEM_PISTOLAMMO:
{
if (cs_get_user_bpammo(id, CSW_DEAGLE) < g_MaxBPAmmo[CSW_DEAGLE])
return true
if (cs_get_user_bpammo(id, CSW_P228) < g_MaxBPAmmo[CSW_P228])
return true
if (cs_get_user_bpammo(id, CSW_USP) < g_MaxBPAmmo[CSW_USP])
return true
if (cs_get_user_bpammo(id, CSW_GLOCK18) < g_MaxBPAmmo[CSW_GLOCK18])
return true
if (cs_get_user_bpammo(id, CSW_FIVESEVEN) < g_MaxBPAmmo[CSW_FIVESEVEN])
return true
}
case ITEM_SHOTAMMO:
{
if (cs_get_user_bpammo(id, CSW_XM1014) < g_MaxBPAmmo[CSW_XM1014])
return true
}
case ITEM_RIFLEAMMO:
{
if (cs_get_user_bpammo(id, CSW_M4A1) < g_MaxBPAmmo[CSW_M4A1])
return true
if (cs_get_user_bpammo(id, CSW_AK47) < g_MaxBPAmmo[CSW_AK47])
return true
}
case ITEM_SMGAMMO:
{
if (cs_get_user_bpammo(id, CSW_MP5NAVY) < g_MaxBPAmmo[CSW_MP5NAVY])
return true
if (cs_get_user_bpammo(id, CSW_MAC10) < g_MaxBPAmmo[CSW_MAC10])
return true
}
case ITEM_AWPAMMO:
{
if (cs_get_user_bpammo(id, CSW_AWP) < g_MaxBPAmmo[CSW_AWP])
return true
}
case ITEM_PARAAMMO:
{
if (cs_get_user_bpammo(id, CSW_M249) < g_MaxBPAmmo[CSW_M249])
return true
}
}
return false
}
GiveAmmo(id, ammotype)
{
switch (ammotype)
{
case ITEM_PISTOLAMMO:
{
csdm_give_item(id, "ammo_357sig")
csdm_give_item(id, "ammo_57mm")
csdm_give_item(id, "ammo_45acp")
csdm_give_item(id, "ammo_50ae")
csdm_give_item(id, "ammo_9mm")
}
case ITEM_SHOTAMMO:
{
csdm_give_item(id, "ammo_buckshot")
}
case ITEM_RIFLEAMMO:
{
csdm_give_item(id, "ammo_762nato")
csdm_give_item(id, "ammo_556nato")
}
case ITEM_SMGAMMO:
{
csdm_give_item(id, "ammo_9mm")
csdm_give_item(id, "ammo_45acp")
}
case ITEM_AWPAMMO:
{
csdm_give_item(id, "ammo_338magnum")
}
case ITEM_PARAAMMO:
{
csdm_give_item(id, "ammo_556natobox")
}
}
}
bool:CanGetWeapon(id, wid)
{
new Weapons[MAX_WEAPONS], num, slot = g_WeaponSlots[wid]
get_user_weapons(id, Weapons, num)
for (new i = 0; i < num; i++)
{
if (g_WeaponSlots[Weapons[i]] == slot && (slot != 4))
return false
}
// check if it's a grenade (we can have 2 flashbangs)
if ((slot == 4) && (cs_get_user_bpammo(id, wid) >= g_MaxBPAmmo[wid]))
return false
return true
}
destroyAllItems(bool:mapchange = true)
{
new iter, entid
// abort any respawn task to avoid double respawns on plugin reload
if (task_exists())
remove_task()
// destroy all items
for (iter = 0; iter < MAX_ITEMS; iter++)
{
entid = g_EntId[iter]
if (pev_valid(entid))
engfunc(EngFunc_RemoveEntity, entid)
}
arrayset(g_EntId, 0, MAX_ITEMS)
arrayset(g_EntTable, 0, MAX_ENTS)
if (mapchange)
arrayset(g_EntType, 0, MAX_ITEMS)
}
destroyAllPacks()
{
new packid, entid
for (new i = 1; i < MAX_PACKS; i++)
{
if (g_PackContents[i][0])
{
entid = g_PackContents[i][1]
packid = g_PackContents[i][2]
if (pev_valid(entid))
engfunc(EngFunc_RemoveEntity, entid)
remove_task(packid)
ZeroPack(packid)
}
}
arrayset(g_PackID, true, MAX_PACKS)
}
stock getWeapId(wp[])
{
if (equali(wp, "weapon_p228")) {
return CSW_P228
} else if (equali(wp, "weapon_scout")) {
return CSW_SCOUT
} else if (equali(wp, "weapon_hegrenade")) {
return CSW_HEGRENADE
} else if (equali(wp, "weapon_xm1014")) {
return CSW_XM1014
} else if (equali(wp, "weapon_c4")) {
return CSW_C4
} else if (equali(wp, "weapon_mac10")) {
return CSW_MAC10
} else if (equali(wp, "weapon_aug")) {
return CSW_AUG
} else if (equali(wp, "weapon_smokegrenade")) {
return CSW_SMOKEGRENADE
} else if (equali(wp, "weapon_elite")) {
return CSW_ELITE
} else if (equali(wp, "weapon_fiveseven")) {
return CSW_FIVESEVEN
} else if (equali(wp, "weapon_ump45")) {
return CSW_UMP45
} else if (equali(wp, "weapon_sg550")) {
return CSW_SG550
} else if (equali(wp, "weapon_galil")) {
return CSW_GALIL