-
Notifications
You must be signed in to change notification settings - Fork 0
/
econ_resource_data.sp
891 lines (736 loc) · 22.3 KB
/
econ_resource_data.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
#pragma semicolon 1
#pragma newdecls required
#pragma tabsize 0
/*
* Credits to legendary Dr. McKay for the language file parsing code, loaning from enhanced_items.sp (Enhanced Item Notifications) plugin
* Credits to dragokas for some fixes.
* Check 'Enhanced Item Notifications' made by legendary Dr. McKay.
*/
public Plugin myinfo =
{
name = "Econ Resource Data",
author = "nukkonyan",
description = "Localize tokens and translation strings.",
version = "1.1.1",
url = "https://github.com/nukkonyan"
}
#define items_game_txt "scripts/items/items_game.txt"
#define clientscheme_res "resource/clientscheme.res"
char folder_name[16];
enum struct ResourceInfo
{
int language;
char token[96];
char value[1024];
}
enum struct ItemsGameRes
{
KeyValues Schema;
StringMap Languages;
ArrayList LanguagesBackup;
StringMap Colours;
ArrayList Classnames;
ArrayList Skins;
StringMap ClassnamesPrefab;
ArrayList Graffitis;
void Load()
{
this.Schema = new KeyValues("items_game");
if(this.Schema.ImportFromFile(items_game_txt))
{
CallSchemaForward();
}
this.Languages = new StringMap();
this.LanguagesBackup = new ArrayList(sizeof(ResourceInfo));
this.Colours = new StringMap();
this.Classnames = new ArrayList(16);
this.ClassnamesPrefab = new StringMap();
switch(GetEngineVersion())
{
case Engine_TF2:
{
if(StrEqual(folder_name, "tf", false))
{
this.Skins = new ArrayList();
}
}
case Engine_CSGO:
{
this.Skins = new ArrayList();
this.Graffitis = new ArrayList();
}
}
KeyValues kv = new KeyValues("Scheme");
kv.ImportFromFile(clientscheme_res);
if(kv.JumpToKey("Colors"))
{
kv.GotoFirstSubKey(false);
do
{
char name[32];
kv.GetSectionName(name, sizeof(name));
int r, g, b, colour;
kv.GetColor(NULL_STRING, r, g, b, colour);
colour = (r << 16) | (g << 8) | (b << 0);
StrToLower(name);
this.Colours.SetValue(name, colour);
}
while(kv.GotoNextKey(false));
kv.GoBack();
}
if(kv.JumpToKey("BaseSettings"))
{
kv.GotoFirstSubKey(false);
do
{
char name[32];
kv.GetSectionName(name, sizeof(name));
int r, g, b, colour;
kv.GetColor(NULL_STRING, r, g, b, colour);
colour = (r << 16) | (g << 8) | (b << 0);
StrToLower(name);
this.Colours.SetValue(name, colour);
}
while(kv.GotoNextKey(false));
}
delete kv;
this.GetClassnames();
this.GetSkins();
this.GetGraffitis();
}
bool LocalizeToken(int client, const char[] token, char[] output, int maxlen)
{
StringMap lang = this.GetLanguage(client);
if(lang == null)
{
LogError("Unable to localize token '%s' for server language!", token);
return false;
}
char fallback[128];
bool rtrn = lang.GetString(token, fallback, sizeof(fallback));
// Some tokens just fails to be read even though it's stored.
if(!rtrn)
{
int index = -1, language = (client == LANG_SERVER) ? GetServerLanguage() : GetClientLanguage(client);
if((index = this.LanguagesBackup.FindValue(language)) >= 0)
{
ResourceInfo info;
this.LanguagesBackup.GetArray(index, info, sizeof(info));
if(StrEqual(fallback[1], info.token, false))
{
strcopy(fallback, sizeof(fallback), info.value);
rtrn = true;
}
}
}
strcopy(output, maxlen, fallback);
return rtrn;
}
bool GetItemName(int client, int itemdef, char[] name, int maxlen)
{
switch(GetEngineVersion())
{
case Engine_TF2:
{
char index[24];
IntToString(itemdef, index, sizeof(index));
this.Schema.Rewind();
this.Schema.JumpToKey("items");
if(!this.Schema.JumpToKey(index))
{
return false;
}
char item_name[128];
this.Schema.GetString("item_name", item_name, sizeof(item_name));
if(strlen(item_name) < 1)
{
char prefab[64];
this.Schema.GetString("prefab", prefab, sizeof(prefab));
if(strlen(prefab) < 1)
{
return false;
}
char armory_desc[32];
this.Schema.GetString("armory_desc", armory_desc, sizeof(armory_desc));
bool baseitem = (StrContainsEx(armory_desc, "stockitem") || (this.Schema.GetNum("baseitem", -1) == 1));
this.Schema.Rewind();
this.Schema.JumpToKey("prefabs");
char buffer[3][64];
ExplodeString(prefab, " ", buffer, sizeof(buffer), sizeof(prefab));
for(int i = 0; i < sizeof(buffer); i++)
{
if(this.Schema.JumpToKey(buffer[i]))
{
this.Schema.GetString("item_name", item_name, sizeof(item_name));
if(baseitem)
{
this.Schema.SetNum("propername", 1);
}
break;
}
}
if(strlen(item_name) < 1)
{
return false;
}
}
StringMap lang = this.GetLanguage(client); //No memory leak to be worried about, since we don't clone it.
if(lang == null)
{
LogError("Unable to get item name for server language (attempting to print to \"%L\")!", client);
return false;
}
if(!this.LocalizeToken(client, item_name[1], name, maxlen))
{
return false;
}
char language_name[32];
lang.GetString("__name__", language_name, sizeof(language_name));
if(StrEqual(language_name, "english") && this.Schema.GetNum("propername"))
{
Format(name, maxlen, "The %s", name);
}
return true;
}
case Engine_CSGO:
{
char index[24];
IntToString(itemdef, index, sizeof(index));
this.Schema.Rewind();
this.Schema.JumpToKey("items");
if(!this.Schema.JumpToKey(index))
{
return false;
}
char item_name[128];
this.Schema.GetString("item_name", item_name, sizeof(item_name));
if(strlen(item_name) < 1)
{
char prefab[64];
this.Schema.GetString("prefab", prefab, sizeof(prefab));
if(strlen(prefab) < 1)
{
return false;
}
this.Schema.Rewind();
this.Schema.JumpToKey("prefabs");
char buffer[3][64];
ExplodeString(prefab, " ", buffer, sizeof(buffer), sizeof(prefab));
for(int i = 0; i < sizeof(buffer); i++)
{
if(this.Schema.JumpToKey(buffer[i]))
{
this.Schema.GetString("item_name", item_name, sizeof(item_name));
break;
}
}
if(strlen(item_name) < 1)
{
return false;
}
StringMap lang = this.GetLanguage(client);
if(lang == null)
{
LogError("Unable to get item name for server language (attempting to print to \"%L\")!", client);
return false;
}
return this.LocalizeToken(client, item_name[1], name, maxlen);
}
}
}
return false;
}
bool GetItemClassname(int itemdef, char[] classname, int maxlen)
{
switch(GetEngineVersion())
{
case Engine_TF2:
{
// to be added
}
case Engine_CSGO:
{
char str_itemdef[11];
IntToString(itemdef, str_itemdef, sizeof(str_itemdef));
this.Schema.Rewind();
this.Schema.JumpToKey("items");
if(this.Schema.JumpToKey(str_itemdef))
{
this.Schema.GetString("name", classname, maxlen);
}
}
}
return false;
}
StringMap GetLanguage(int client)
{
int language = (client == LANG_SERVER) ? GetServerLanguage() : GetClientLanguage(client);
char language_name[64];
GetLanguageInfo(language, _, _, language_name, sizeof(language_name));
StringMap lang;
if(!this.Languages.GetValue(language_name, lang))
{
lang = this.ParseLanguage(language_name, language);
this.Languages.SetValue(language_name, lang);
}
if(lang == null && client != LANG_SERVER)
{
return this.GetLanguage(LANG_SERVER);
}
//else if(lang == null) return null;
return lang;
}
StringMap ParseLanguage(const char[] language_name, int language)
{
char filename[64];
Format(filename, sizeof(filename), "resource/%s_%s.txt", folder_name, language_name);
File file;
if((file = OpenFile(filename, "r")) == null)
{
return null;
}
StringMap lang = new StringMap();
lang.SetString("__name__", language_name);
int data, i = 0, high_surrogate, low_surrogate;
char line[4096];
while(ReadFileCell(file, data, 2) == 1)
{
if(high_surrogate)
{
// for characters in range 0x10000 <= X <= 0x10FFFF
low_surrogate = data;
data = ((high_surrogate - 0xD800) << 10) + (low_surrogate - 0xDC00) + 0x10000;
line[i++] = ((data >> 18) & 0x07) | 0xF0;
line[i++] = ((data >> 12) & 0x3F) | 0x80;
line[i++] = ((data >> 6) & 0x3F) | 0x80;
line[i++] = (data & 0x3F) | 0x80;
high_surrogate = 0;
}
else if(data < 0x80)
{
// It's a single-byte character
line[i++] = data;
if(data == '\n')
{
line[i] = '\0';
this.HandleLangLine(line, lang, language);
i = 0;
}
}
else if(data < 0x800)
{
// It's a two-byte character
line[i++] = ((data >> 6) & 0x1F) | 0xC0;
line[i++] = (data & 0x3F) | 0x80;
}
/*
else if(data < 0x8000)
{
// It's a three-byte character
// code to be put in here
}
*/
else if(data <= 0xFFFF)
{
if(0xD800 <= data <= 0xDFFF)
{
high_surrogate = data;
continue;
}
line[i++] = ((data >> 12) & 0x0F) | 0xE0;
line[i++] = ((data >> 6) & 0x3F) | 0x80;
line[i++] = (data & 0x3F) | 0x80;
}
}
delete file;
return lang;
}
void HandleLangLine(char[] line, StringMap lang, int language) {
TrimString(line);
// Not a line containing at least one quoted string
if(line[0] != '"') return;
char token[96], value[1024];
int pos = BreakString(line, token, sizeof(token));
// This line doesn't have two quoted strings
if(pos == -1) return;
BreakString(line[pos], value, sizeof(value));
lang.SetString(token, value);
// StringMap() limitation.
ResourceInfo info;
info.language = language;
info.token = token;
info.value = value;
this.LanguagesBackup.PushArray(info);
}
void GetClassnames()
{
switch(GetEngineVersion())
{
case Engine_CSGO:
{
this.Schema.Rewind();
if(this.Schema.JumpToKey("prefabs"))
{
if(this.Schema.GotoFirstSubKey())
{
do
{
char classname[64];
this.Schema.GetString("item_class", classname, sizeof(classname));
if(strlen(classname) > 0)
{
if(this.Classnames.FindString(classname) == -1)
{
this.Classnames.PushString(classname);
}
}
this.Schema.GetString("anim_class", classname, sizeof(classname));
if(strlen(classname) > 0)
{
if(this.Classnames.FindString(classname) == -1)
{
this.Classnames.PushString(classname);
}
}
}
while(this.Schema.GotoNextKey());
this.Schema.GoBack();
}
this.Schema.GoBack();
}
if(this.Schema.JumpToKey("items"))
{
if(this.Schema.GotoFirstSubKey())
{
do
{
char classname[64];
this.Schema.GetString("item_class", classname, sizeof(classname));
if(strlen(classname) >= 1)
{
if(this.Classnames.FindString(classname) == -1)
{
this.Classnames.PushString(classname);
}
}
}
while(this.Schema.GotoNextKey());
}
}
}
case Engine_TF2:
{
if(!StrEqual(folder_name, "tf", false))
{
return;
}
if(!this.Schema.JumpToKey("prefabs"))
{
return;
}
if(this.Schema.GotoFirstSubKey())
{
do
{
char section[64], item_class[64];
this.Schema.GetSectionName(section, sizeof(section));
this.Schema.GetString("item_class", item_class, sizeof(item_class));
// valid item classname
if(strlen(item_class) > 0)
{
if(this.Classnames.FindString(item_class) == -1)
{
this.Classnames.PushString(item_class);
}
}
// no item classname, must find prefab within
else
{
char prefabs[96];
this.Schema.GetString("prefab", prefabs, sizeof(prefabs));
this.Schema.GoBack();
char buffer1[4][64];
int found1 = ExplodeString(prefabs, " ", buffer1, sizeof(buffer1), 64);
for(int i = 0; i < found1; i++)
{
// found valid prefab within
if(this.Schema.JumpToKey(buffer1[i]))
{
this.Schema.GetString("item_class", item_class, sizeof(item_class));
this.Schema.GoBack();
if(strlen(item_class) > 0)
{
if(this.Classnames.FindString(item_class) == -1)
{
this.Classnames.PushString(item_class);
}
}
else
{
char buffer2[4][64];
int found2 = ExplodeString(prefabs, " ", buffer2, sizeof(buffer2), 64);
this.Schema.GetString("prefab", prefabs, sizeof(prefabs));
for(int x = 0; x < found2; x++)
{
if(this.Schema.JumpToKey(buffer2[x]))
{
this.Schema.GetString("item_class", item_class, sizeof(item_class));
this.Schema.GoBack();
if(strlen(item_class) > 0)
{
if(this.Classnames.FindString(item_class) == -1)
{
this.Classnames.PushString(item_class);
}
}
}
}
}
}
}
this.Schema.JumpToKey(section);
}
}
//delete prefabs;
while(this.Schema.GotoNextKey());
}
}
}
}
void GetSkins() {
switch(GetEngineVersion()) {
case Engine_CSGO: {
this.Schema.Rewind();
if(this.Schema.GotoFirstSubKey()) {
do {
char section[16];
this.Schema.GetSectionName(section, sizeof(section));
if(StrEqual(section, "paint_kits")) {
if(this.Schema.GotoFirstSubKey()) {
do {
this.Schema.GetSectionName(section, sizeof(section));
int paintkit_id = StringToInt(section);
if(paintkit_id < 1 || paintkit_id == 9001) continue;
if(this.Skins.FindValue(paintkit_id) == -1) this.Skins.Push(paintkit_id);
}
while(this.Schema.GotoNextKey());
this.Schema.GoBack();
}
}
}
while(this.Schema.GotoNextKey());
}
}
case Engine_TF2: {
if(StrEqual(folder_name, "tf", false)) {
this.Schema.Rewind();
if(this.Schema.JumpToKey("items")) {
if(this.Schema.GotoFirstSubKey()) {
do {
if(this.Schema.JumpToKey("static_attrs")) {
int paintkit_proto_def_index = this.Schema.GetNum("paintkit_proto_def_index");
if(this.Skins.FindValue(paintkit_proto_def_index) == -1) this.Skins.Push(paintkit_proto_def_index);
this.Schema.GoBack();
}
}
while(this.Schema.GotoNextKey());
}
}
}
}
}
}
void GetGraffitis()
{
if(GetEngineVersion() == Engine_CSGO)
{
this.Schema.Rewind();
// search after 'sticker_kits', graffitis are stored in same array as stickers..
if(this.Schema.GotoFirstSubKey())
{
// found 'sticker_kits', lets read through it's KeyValue arrayed information..
do
{
char section_name[32];
this.Schema.GetSectionName(section_name, sizeof(section_name));
if(StrEqual(section_name, "sticker_kits"))
{
if(this.Schema.GotoFirstSubKey())
{
do
{
char str_itemdef[11];
this.Schema.GetSectionName(str_itemdef, sizeof(str_itemdef));
if(strlen(str_itemdef) > 0)
{
int itemdef = StringToInt(str_itemdef);
char sticker_material[64];
this.Schema.GetString("sticker_material", sticker_material, sizeof(sticker_material));
if(StrContains(sticker_material, "graffiti") != -1)
{
this.Graffitis.Push(itemdef);
//PrintToServer("found graffiti %s '%s'", str_itemdef, sticker_material);
}
}
}
while(this.Schema.GotoNextKey());
this.Schema.GoBack();
}
}
}
while(this.Schema.GotoNextKey());
this.Schema.GoBack();
}
}
}
}
ItemsGameRes ItemsGame;
void CallSchemaForward() {
GlobalForward fwd = new GlobalForward("EconResData_OnItemsGameLoaded", ET_Ignore, Param_Any);
KeyValues clone = view_as<KeyValues>(CloneHandle(ItemsGame.Schema));
Call_StartForward(fwd);
Call_PushCell(clone);
Call_Finish();
delete clone;
delete fwd;
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) {
RegPluginLibrary("EconResourceData");
CreateNative("EconResData_LocalizeToken", Native_LocalizeToken);
CreateNative("EconResData_GetColour", Native_GetColour);
CreateNative("EconResData_GetItemName", Native_GetItemName);
CreateNative("EconResData_GetItemClassname", Native_GetItemClassname);
CreateNative("EconResData_ValidItemClassname", Native_ValidItemClassname);
CreateNative("EconResData_GetKeyValues", Native_GetKeyValues);
CreateNative("EconResData_GetGameSkins", Native_GetGameSkins);
CreateNative("EconResData_GetGameClassnames", Native_GetGameClassnames);
CreateNative("EconResData_ValidGameSkin", Native_ValidGameSkin);
CreateNative("EconResData_GetGameGraffitis", Native_GetGameGraffitis);
CreateNative("EconResData_ValidGameGraffiti", Native_ValidGameGraffiti);
return APLRes_Success;
}
public void OnPluginStart()
{
GetGameFolderName(folder_name, sizeof(folder_name));
ItemsGame.Load();
// Debug
#if defined DEBUG
RegConsoleCmd("sm_translate_token", TranslateTokenCmd, "Econ Resource Data - Translate a language token string.");
#endif
}
#if defined DEBUG
Action TranslateTokenCmd(int client, int args)
{
if(args != 1)
{
ReplyToCommand(client, "[EconResData] Usage: sm_translate_token \"token here\"");
return;
}
char token[64], translated[128];
if(GetCmdArg(1, token, sizeof(token)) < 1)
{
ReplyToCommand(client, "[EconResData] Token key may not be NULL");
return;
}
switch(ItemsGame.LocalizeToken(client, token, translated, sizeof(translated)))
{
case false: ReplyToCommand(client, "[EconResData] Token '%s' was not found :(", token);
case true: ReplyToCommand(client, "[EconResData] Token '%s' was translated to '%s'", token, translated);
}
}
#endif
// --
// EconResData_LocalizeToken(int client, const char[] token, char[] output, int maxlen)
any Native_LocalizeToken(Handle plugin, int params) {
int client = GetNativeCell(1);
int maxlen1 = GetNativeStringLengthEx(2);
char[] token = new char[maxlen1];
GetNativeString(2, token, maxlen1);
int maxlen2 = GetNativeCell(4);
char[] output = new char[maxlen2];
bool rtrn = ItemsGame.LocalizeToken(client, token, output, maxlen2);
SetNativeString(3, output, maxlen2);
return rtrn;
}
// EconResData_GetColour(const char[] token)
any Native_GetColour(Handle plugin, int params) {
int maxlen = GetNativeStringLengthEx(1);
char[] token = new char[maxlen];
GetNativeString(1, token, maxlen);
int value;
ItemsGame.Colours.GetValue(token, value);
return value;
}
// EconResData_GetKeyValues()
any Native_GetKeyValues(Handle plugin, int params) {
return CloneHandle(ItemsGame.Schema);
}
// EconResData_GetItemName(int client, int itemdef, char[] name, int maxlen)
any Native_GetItemName(Handle plugin, int params) {
int client = GetNativeCell(1);
int itemdef = GetNativeCell(2);
int maxlen = GetNativeCell(4);
char[] name = new char[maxlen];
bool rtrn = ItemsGame.GetItemName(client, itemdef, name, maxlen);
SetNativeString(3, name, maxlen);
return rtrn;
}
// EconResData_GetItemClassname(int itemdef, char[] classname, int maxlen)
any Native_GetItemClassname(Handle plugin, int params) {
int itemdef = GetNativeCell(1);
int maxlen = GetNativeCell(3);
char[] name = new char[maxlen];
bool rtrn = ItemsGame.GetItemClassname(itemdef, name, maxlen);
SetNativeString(2, name, maxlen);
return rtrn;
}
any Native_ValidItemClassname(Handle plugin, int params) {
int maxlen = GetNativeStringLengthEx(1);
char[] classname = new char[maxlen];
GetNativeString(1, classname, maxlen);
switch(GetEngineVersion()) {
case Engine_CSGO: {
if(StrEqual(classname, "weapon_m4a1_silencer", false)
|| StrEqual(classname, "weapon_usp_silencer", false)) return true;
}
}
StrToLower(classname);
return ItemsGame.Classnames.FindString(classname) != -1;
}
any Native_GetGameSkins(Handle plugin, int params) {
if(ItemsGame.Skins == null) return view_as<Handle>(null);
if(ItemsGame.Skins.Length < 1) return view_as<Handle>(null);
return CloneHandle(ItemsGame.Skins);
}
any Native_GetGameClassnames(Handle plugin, int params) {
if(ItemsGame.Classnames == null) return view_as<Handle>(null);
if(ItemsGame.Classnames.Length < 1) return view_as<Handle>(null);
return CloneHandle(ItemsGame.Classnames);
}
any Native_ValidGameSkin(Handle plugin, int params) {
if(ItemsGame.Skins == null) return false;
if(ItemsGame.Skins.Length < 1) return view_as<Handle>(null);
return ItemsGame.Skins.FindValue(GetNativeCell(1)) != -1;
}
// EconResData_GetGameGraffitis()
any Native_GetGameGraffitis(Handle plugin, int params)
{
return CloneHandle(ItemsGame.Graffitis);
}
// EconResData_ValidGameGraffiti(int itemdef)
any Native_ValidGameGraffiti(Handle plugin, int params)
{
if(ItemsGame.Graffitis == null) return false;
if(ItemsGame.Graffitis.Length < 1) return false;
return ItemsGame.Graffitis.FindValue(GetNativeCell(1)) != -1;
}
// --
void StrToLower(char[] str) { for(int i = 0; i < strlen(str); i++) str[i] = CharToLower(str[i]); }
int GetNativeStringLengthEx(int param) {
int value;
GetNativeStringLength(param, value);
return value+1;
}
bool StrContainsEx(const char[] str, const char[] subStr) {
return view_as<bool>(StrContains(str, subStr, false) > -1);
}