-
Notifications
You must be signed in to change notification settings - Fork 1
/
rm_base.sma
2093 lines (1778 loc) · 56.3 KB
/
rm_base.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
#include <amxmodx>
#include <amxmisc>
#include <csx>
#include <fakemeta>
#include <xs>
#include <rm_api>
//#define DEBUG_ENABLED
// Koличecтвo pyн
new runes_registered = 0;
// Дaнныe o pyнax
new rune_list_id[MAX_REGISTER_RUNES];
new bool:rune_list_isItem[MAX_REGISTER_RUNES] = {false,...};
new bool:rune_list_gamecms[MAX_REGISTER_RUNES] = {false,...};
new bool:rune_list_disabled[MAX_REGISTER_RUNES] = {false,...};
new rune_list_name[MAX_REGISTER_RUNES][128];
new rune_list_descr[MAX_REGISTER_RUNES][256];
new rune_list_model[MAX_REGISTER_RUNES][256];
new rune_list_model_id[MAX_REGISTER_RUNES];
new rune_list_sound[MAX_REGISTER_RUNES][256];
new Float:rune_list_model_color[MAX_REGISTER_RUNES][3];
new rune_list_maxcount[MAX_REGISTER_RUNES] = {0,...};
new rune_list_count[MAX_REGISTER_RUNES];
new rune_list_icost[MAX_REGISTER_RUNES] = {0,...};
// Текущее количество предметов и рун на карте
new runemod_spawned_items = 0;
new runemod_spawned_runes = 0;
// Koличecтвo cпaвнoв
new spawn_array_size = 0;
new spawn_filled_size = 0;
// Koopдинaты cпaвнoв
new Float:spawn_pos[MAX_SPAWN_POINTS][3];
// 3aнят ли cпaвн нa дaнный мoмeнт pyнoй
new spawn_has_ent[MAX_SPAWN_POINTS] = {0,...};
// Координаты рун для user_think
new spawn_iEnt_Origin[MAX_SPAWN_POINTS][3];
// Cтaндapтнaя мoдeль pyны. Иcпoльзyeтcя ecли зaгpyжeнa. Пo yмoлчaнию "models/rm_reloaded/rune_black.mdl"
new rune_default_model[MAX_RESOURCE_PATH_LENGTH];
new rune_default_model_id;
// Cтaндapтный звyк пoднятия pyны.
new rune_default_pickup_sound[MAX_RESOURCE_PATH_LENGTH];
// Список карт недоступных для RuneMod
new runemod_ignore_prefix_list[256];
// Стандартная модель руны
new runemod_default_model_path[MAX_RESOURCE_PATH_LENGTH];
// Стандартный звук поднятия руны
new runemod_default_pickup_path[MAX_RESOURCE_PATH_LENGTH];
// Время работы мода
new runemod_start_time_hours = -1;
new runemod_end_time_hours = -1;
new runemod_time[16];
// Очередь HUD сообщений
new HUD_SYNS_1,HUD_SYNS_2;
// Aктивнaя pyнa игpoкa - нoмep плaгинa
new active_rune_id[MAX_PLAYERS + 1] = {-1,...};
// Блокировка возможности поднять руну или предмет
new lock_rune_pickup[MAX_PLAYERS + 1] = {0,...};
// Возможность отключить RUNEMOD на определенных картах или раундах
new runemod_active = 1
new runemod_active_status = 1;
// Только предметы!
new runemod_only_items;
// Начальный раунд
new runemod_start_round;
// Очистка рун после завершения раунда
new runemod_restart_cleanup;
// Таймер добавления рун
new runemod_spawntime = 10;
// Максимальное спавн точек
new runemod_spawncount;
// Максимальное спавн точек для рун
new runemod_max_runes;
// Максимальное спавн точек для рун
new runemod_max_items;
// Количество появляемых рун за 1 спавн
new runemod_perspawn;
// Расстояние от место появлений игроков
new runemod_respawn_distance;
// Расстояние от игроков
new runemod_player_distance;
// Расстояние между спавнами
new runemod_spawn_distance;
// Минимальное и максимальное количество игроков
new runemod_min_players,runemod_max_players;
// Активировать свечение модели игрока
new runemod_player_highlight;
// Активировать подсветку экрана игрока
new runemod_screen_highlight;
// Только для пользователей GAMECMS
new runemod_only_gamecms;
// Режим неизвестных рун
new runemod_random_mode;
// Забрать руны после окончания раунда
new runemod_newround_remove;
// Активировать магазин рун
new runemod_rune_shop;
// Префикс RUNEMOD (Можно ввести сайт или название сервера)
new runemod_prefix[64];
// Оповещение игроков
new runemod_notify_players;
new runemod_notify_players_drop;
new runemod_notify_spawns;
// Создавать предмет/руну только если игрок не увидит :)
new runemod_spawn_nolook;
// Обновление спавн точки для рун и предметов
new runemod_spawn_lifetime;
// Боты могут поднимать руны и предметы?
new runemod_bot_pickup;
// Остальные глобальные переменные
new g_pCommonTr;
new rune_last_created = 0;
new Float:g_fLastRegisterPrint[MAX_PLAYERS + 1] = {0.0,...};
new g_iRoundLeft = 0;
new bool:g_bCurrentMapIgnored = false;
new g_sConfigDirPath[PLATFORM_MAX_PATH];
new bool:g_bRegGameCMS[MAX_PLAYERS + 1] = {false,...};
new mp_maxmoney;
new g_bScreenFadeAllowed = false;
new Float:g_fLastSpawnRefreshTime = 0.0;
new g_iRefreshSpawnId = 0;
// Peгиcтpaция плaгинa, cтoлкнoвeний c pyнoй, pecпaвнa игpoкoв и oбнoвлeния cпaвнoв и pyн.
// A тaк жe нaвeдeниe нa pyнy вoзвpaщaeт ee нaзвaниe и oпиcaниe pyны.
public plugin_init()
{
register_plugin("RM_BASEPLUGIN", RUNEMOD_VERSION,"Karaulov");
create_cvar("rm_runemod", RUNEMOD_VERSION, FCVAR_SERVER | FCVAR_SPONLY);
RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn_Post", true);
set_task(float(runemod_spawntime) / 2.0, "RM_SPAWN_RUNE", SPAWN_SEARCH_TASK_ID);
set_task(UPDATE_RUNE_DESCRIPTION_HUD_TIME, "UPDATE_RUNE_DESCRIPTION", UPDATE_RUNE_DESCRIPTION_HUD_ID, _, _, "b");
set_task(10.0, "REMOVE_RUNE_MONITOR", UPDATE_RUNE_DESCRIPTION_HUD_ID+1, _, _, "b");
RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", true);
RegisterHookChain(RG_RoundEnd, "DropAllRunes", .post = false);
RegisterHookChain(RG_CSGameRules_RestartRound, "RestartRound", .post = false)
register_concmd( "drop", "cmd_drop" );
g_pCommonTr = create_tr2()
HUD_SYNS_1 = CreateHudSyncObj();
HUD_SYNS_2 = CreateHudSyncObj();
// Silent execute cfg
new HookChain:g_hConPrintf = RegisterHookChain(RH_Con_Printf, "RH_ConPrintf_Pre", 0)
// Read server lang
server_cmd("exec %s/amxx.cfg", g_sConfigDirPath);
server_exec();
DisableHookChain(g_hConPrintf);
register_dictionary("rm_runemod.txt");
register_dictionary("rm_runemod_runes.txt");
register_dictionary("rm_runemod_items.txt");
register_message(get_user_msgid("ScreenFade"),"Event_ScreenFade");
mp_maxmoney = get_cvar_pointer("mp_maxmoney");
// Часть кода отвечающая за отключения мода при совпадении префикса или названия карты
new sMapName[32];
rh_get_mapname(sMapName, charsmax(sMapName), MNT_TRUE);
add(runemod_ignore_prefix_list,charsmax(runemod_ignore_prefix_list)," ");
new sMapPrefix[32];
new i = 0, iPos = 0;
while((iPos = split_string(runemod_ignore_prefix_list[i], " ", sMapPrefix, charsmax(sMapPrefix))) > 0)
{
i += iPos;
if (containi(sMapName,sMapPrefix) >= 0)
{
g_bCurrentMapIgnored = true;
log_amx("[runemod_ignore_prefix_list]: Disable RuneMod Reloaded for current map. Match prefix %s for map %s.", sMapPrefix, sMapName);
return;
}
}
// Установка лимита по времени по часам
if (strlen(runemod_time) > 2)
{
new hour1[3];
new hour2[3];
parse(runemod_time, hour1, charsmax(hour1), hour2, charsmax(hour2));
if (hour1[0] != EOS && hour2[0] != EOS)
{
if (hour1[0] == '0')
{
hour1[0] = hour1[1];
hour1[1] = EOS;
}
if (hour2[0] == '0')
{
hour2[0] = hour2[1];
hour2[1] = EOS;
}
runemod_start_time_hours = str_to_num(hour1);
runemod_end_time_hours = str_to_num(hour2);
}
log_amx("RuneMod Reloaded! Time from %02d:00 to %02d:00",runemod_start_time_hours,runemod_end_time_hours);
}
else
{
log_amx("RuneMod Reloaded!");
}
}
public RH_ConPrintf_Pre(const szBuffer[])
{
return HC_BREAK;
}
public rm_config_execute()
{
bind_pcvar_string(create_cvar("runemod_prefix", "[RUNEMOD]",
.description = "Prefix for RUNEMOD in chat"
), runemod_prefix, charsmax(runemod_prefix));
bind_pcvar_string(create_cvar("runemod_ignore_prefix_list", "",
.description = "Ignore map list"
), runemod_ignore_prefix_list, charsmax(runemod_ignore_prefix_list));
bind_pcvar_num(create_cvar("runemod_active", "1",
.description = "Activate runemod"
), runemod_active);
bind_pcvar_num(create_cvar("runemod_restart_cleanup", "0",
.description = "Cleanup runes after round end"
), runemod_restart_cleanup);
bind_pcvar_num(create_cvar("runemod_start_round", "0",
.description = "Startup round"
), runemod_start_round);
bind_pcvar_num(create_cvar("runemod_only_items", "0",
.description = "Only items!"
), runemod_only_items);
bind_pcvar_num(create_cvar("runemod_spawntime", "10",
.description = "Timer for add new rune"
), runemod_spawntime);
bind_pcvar_num(create_cvar("runemod_perspawn", "2",
.description = "Number of spawn runes at one time"
), runemod_perspawn);
bind_pcvar_num(create_cvar("runemod_spawncount", "20",
.description = "Max spawn points at map"
), runemod_spawncount);
bind_pcvar_num(create_cvar("runemod_max_runes", "5",
.description = "Max runes at map"
), runemod_max_runes);
bind_pcvar_num(create_cvar("runemod_max_items", "20",
.description = "Max items at map"
), runemod_max_items);
bind_pcvar_num(create_cvar("runemod_respawn_distance", "250",
.description = "Min spawn distance from info_player_start/deathmath"
), runemod_respawn_distance);
bind_pcvar_num(create_cvar("runemod_player_distance", "250",
.description = "Min spawn distance from players"
), runemod_player_distance);
bind_pcvar_num(create_cvar("runemod_spawn_distance", "300",
.description = "Min distance between spawns"
), runemod_spawn_distance);
bind_pcvar_num(create_cvar("runemod_min_players", "0",
.description = "Min players for spawn runes"
), runemod_min_players);
bind_pcvar_num(create_cvar("runemod_max_players", "32",
.description = "Max players for spawn runes"
), runemod_max_players);
bind_pcvar_num(create_cvar("runemod_player_highlight", "1",
.description = "Enable player model highlight"
), runemod_player_highlight);
bind_pcvar_num(create_cvar("runemod_screen_highlight", "1",
.description = "Enable player screen highlight"
), runemod_screen_highlight);
bind_pcvar_num(create_cvar("runemod_only_gamecms", "0",
.description = "Only GAMECMS users!"
), runemod_only_gamecms);
bind_pcvar_num(create_cvar("runemod_random_mode", "0",
.description = "Random mode"
), runemod_random_mode);
bind_pcvar_num(create_cvar("runemod_newround_remove", "1",
.description = "Drop all runes and items at round end"
), runemod_newround_remove);
bind_pcvar_num(create_cvar("runemod_rune_shop", "0",
.description = "Enable runeshop"
), runemod_rune_shop);
bind_pcvar_string(create_cvar("runemod_default_model_path", "models/rm_reloaded/rune_black.mdl",
.description = "Default model for RuneMod"
), runemod_default_model_path, charsmax(runemod_default_model_path));
bind_pcvar_string(create_cvar("runemod_default_pickup_path", "models/rm_reloaded/rune_black.mdl",
.description = "Default sound for RuneMod"
), runemod_default_pickup_path, charsmax(runemod_default_pickup_path));
bind_pcvar_string(create_cvar("runemod_time", "",
.description = "Runemod time"
), runemod_time, charsmax(runemod_time));
bind_pcvar_num(create_cvar("runemod_notify_players", "0",
.description = "Players notify (pickup)"
), runemod_notify_players);
bind_pcvar_num(create_cvar("runemod_notify_players_drop", "0",
.description = "Players notify (drop)"
), runemod_notify_players_drop);
bind_pcvar_num(create_cvar("runemod_notify_spawns", "0",
.description = "Players notify (spawns)"
), runemod_notify_spawns);
bind_pcvar_num(create_cvar("runemod_spawn_nolook", "0",
.description = "Spawn only if player not sees"
), runemod_spawn_nolook);
bind_pcvar_num(create_cvar("runemod_spawn_lifetime", "0",
.description = "Spawn refresh timer"
), runemod_spawn_lifetime);
bind_pcvar_num(create_cvar("runemod_bot_pickup", "1",
.description = "Bot can pickup items"
), runemod_bot_pickup);
register_clcmd("runeshop", "rm_runeshop");
register_clcmd("rune_shop", "rm_runeshop");
register_clcmd("say runeshop", "rm_runeshop");
register_clcmd("say /runeshop", "rm_runeshop");
register_clcmd("say_team runeshop", "rm_runeshop");
register_clcmd("say_team /runeshop", "rm_runeshop");
get_configsdir(g_sConfigDirPath, charsmax(g_sConfigDirPath));
server_cmd("exec %s/plugins/runemod.cfg", g_sConfigDirPath);
server_exec();
}
public plugin_end()
{
free_tr2(g_pCommonTr);
}
// Обновлять информацию о рунах на прицеле
public client_putinserver(id)
{
if (task_exists(id))
remove_task(id);
g_bRegGameCMS[id] = false;
lock_rune_pickup[id] = 0;
player_drop_rune(id);
player_drop_all_items(id);
active_rune_id[id] = -1;
if (!is_user_bot(id))
set_task(0.4, "user_think", id, _, _, "b");
}
/*
public client_connect(id)
{
g_bRegGameCMS[id] = false;
}
*/
// 3aбpaть pyнy пpи oтключeнии игpoкa
public client_disconnected(id, bool:drop, message[], maxlen)
{
if (task_exists(id))
remove_task(id);
g_bRegGameCMS[id] = false;
lock_rune_pickup[id] = 0;
player_drop_rune(id);
player_drop_all_items(id);
active_rune_id[id] = -1;
}
// Зарегистрировать словарь в RUNEMOD
public rm_register_dictionary_api(const dictname[])
{
register_dictionary(dictname);
}
// Удаление всех рун при отключении RUNEMOD
public REMOVE_RUNE_MONITOR()
{
if (runemod_active_status != runemod_active)
{
runemod_active_status = runemod_active;
if (!runemod_active)
{
RemoveAllRunes();
}
}
if (runemod_start_time_hours == -1 || runemod_start_time_hours == -1 || runemod_start_time_hours == runemod_end_time_hours)
{
return;
}
new hours;
time(hours);
if (runemod_start_time_hours > runemod_end_time_hours)
{
if (hours >= runemod_start_time_hours || hours < runemod_end_time_hours)
{
if (runemod_active_status != 1)
{
set_cvar_num("runemod_active", 1);
}
}
else
{
if (runemod_active_status != 0)
{
set_cvar_num("runemod_active", 0);
}
}
}
else if (runemod_start_time_hours <= hours && hours < runemod_end_time_hours)
{
if (runemod_active_status != 1)
{
set_cvar_num("runemod_active", 1);
}
}
else
{
if (runemod_active_status != 0)
{
set_cvar_num("runemod_active", 0);
}
}
}
// Фyнкция пpoвepяeт нe нaxoдитcя ли тoчкa pядoм co игpoкaми
bool:is_no_player_point( Float:coords[3] , Float:dist = 128.0)
{
new iPlayers[ 32 ], iNum;
new Float:fOrigin[3];
get_players( iPlayers, iNum, "ah" );
for( new i = 0; i < iNum; i++ )
{
new iPlayer = iPlayers[ i ];
get_entvar(iPlayer, var_origin, fOrigin );
if (get_distance_f(fOrigin,coords) < dist)
return false;
}
return true;
}
// Фyнкция пpoвepяeт нe нaxoдитcя ли тoчкa pядoм co cпaвнaми
public bool:is_no_spawn_point( Float:coords[3] )
{
// Bot fix ?
if (coords[0] == 0.0 && coords[1] == 0.0)
{
return true;
}
new ent = -1, classname[64]
while((ent = find_ent_in_sphere(ent, coords, float(runemod_respawn_distance))))
{
get_entvar(ent, var_classname,classname,charsmax(classname))
if(containi(classname, "info_player_") == 0)
{
return false;
}
}
return true;
}
// Пoлyчeниe ID pyны пo нoмepy плaгинa
public get_runeid_by_pluginid( pid )
{
for(new i = 0; i < runes_registered;i++)
{
if (rune_list_id[i] == pid)
return i;
}
return -1;
}
new Float:player_drop_time[MAX_PLAYERS + 1];
// Выбрать нож и нажать 2 раза DROP что бы выбросить руну
public cmd_drop(id)
{
if (get_user_weapon(id) == CSW_KNIFE)
{
if (get_gametime() - player_drop_time[id] < 0.25 && active_rune_id[id] >= 0 && lock_rune_pickup[id] == 0)
{
player_drop_rune( id );
}
player_drop_time[id] = get_gametime();
}
}
// 3aбpaть pyны в конце payндa
public DropAllRunes( )
{
if (runemod_newround_remove > 0)
{
g_iRoundLeft++;
for(new id = 1; id < MAX_PLAYERS + 1;id++)
{
player_drop_rune(id);
player_drop_all_items(id);
}
}
}
// Удалить руны в начале раунда если требуется
public RemoveAllRunes()
{
spawn_filled_size = 0;
for(new i = 0; i < spawn_array_size; i++)
{
new iEnt = spawn_has_ent[i];
if (iEnt > 0 && !is_nullent(iEnt))
{
set_entvar(iEnt, var_flags, FL_KILLME);
set_entvar(iEnt, var_nextthink, get_gametime());
new rune_id = rm_get_rune_runeid(iEnt)
if (rune_id < 0 || rune_id >= runes_registered)
continue;
new origin_rune_id = rm_get_rune_num(iEnt);
if (origin_rune_id >= 0 && origin_rune_id != rune_list_id[rune_id] && origin_rune_id < runes_registered)
{
rm_remove_rune_callback( rune_list_id[origin_rune_id],iEnt );
}
rm_remove_rune_callback(rune_list_id[rune_id],iEnt);
rune_list_count[rune_id] = 0;
}
runemod_spawned_items = 0;
runemod_spawned_runes = 0;
spawn_has_ent[i] = 0;
}
}
public RestartRound()
{
if (runemod_restart_cleanup)
{
RemoveAllRunes();
}
}
// Пpeкeш мoдeли pyны и звука поднятия
public plugin_precache()
{
rm_config_execute();
if(file_exists(runemod_default_model_path,true))
{
copy(rune_default_model,charsmax(rune_default_model),runemod_default_model_path);
}
else
{
copy(rune_default_model,charsmax(rune_default_model),"models/w_weaponbox.mdl");
}
rune_default_model_id = precache_model(rune_default_model);
if(file_exists(runemod_default_pickup_path,true))
{
// replace first sound/
precache_generic(runemod_default_pickup_path);
copy(rune_default_pickup_sound,charsmax(rune_default_pickup_sound),runemod_default_pickup_path);
}
else
{
copy(rune_default_pickup_sound,charsmax(rune_default_pickup_sound),"sound/items/nvg_on.wav");
}
}
// Peгиcтpaция нoвoй pyны в бaзoвoм плaгинe (coxpaнeниe в зapaнee пoдгoтoвлeнный cпиcoк)
public RM_RegisterPlugin(PluginIndex,RuneName[],RuneDesc[],Float:RuneColor1,Float:RuneColor2,Float:RuneColor3,rModel[],rSound[],rModelID,RuneGiveName[])
{
//server_print("INIT RUNE: %i %s %s %f %f %f %s %s %i %s^n", PluginIndex,RuneName,RuneDesc, RuneColor1,RuneColor2,RuneColor3,rModel,rSound,rModelID,RuneGiveName);
new i = runes_registered;
if (i >= MAX_REGISTER_RUNES)
return -1;
runes_registered++;
rune_list_id[i] = PluginIndex;
copy(rune_list_name[i],charsmax(rune_list_name[]), RuneName);
copy(rune_list_descr[i],charsmax(rune_list_descr[]), RuneDesc);
if( rModelID != -1 && strlen(rModel) > 0 && file_exists(rModel,true))
{
//server_print("INIT RUNE: MODEL FOUND");
copy(rune_list_model[i],charsmax(rune_list_model[]),rModel);
rune_list_model_id[i] = rModelID;
}
else
{
//server_print("INIT RUNE: MODEL NOT FOUND");
copy(rune_list_model[i],charsmax(rune_list_model[]),rune_default_model);
rune_list_model_id[i] = rune_default_model_id;
}
if( strlen(rSound) > 0 && file_exists( rune_list_sound[i], true ) )
{
//server_print("INIT RUNE: SOUND FOUND");
if (contain(rSound,"sound/") == 0)
copy(rune_list_sound[i],charsmax(rune_list_sound[]), rSound);
else
copy(rune_list_sound[i],charsmax(rune_list_sound[]), rSound[6]);
}
else
{
//server_print("INIT RUNE: SOUND NOT FOUND");
if (contain(rune_default_pickup_sound,"sound/") == 0)
copy(rune_list_sound[i],charsmax(rune_list_sound[]), rune_default_pickup_sound);
else
copy(rune_list_sound[i],charsmax(rune_list_sound[]), rune_default_pickup_sound[6]);
}
rune_list_maxcount[i] = 999999;
rune_list_model_color[i][0] = RuneColor1;
rune_list_model_color[i][1] = RuneColor2;
rune_list_model_color[i][2] = RuneColor3;
return i;
}
public Event_ScreenFade(msgid, msgDest, msgEnt)
{
if (runemod_screen_highlight && is_real_player(msgEnt) && active_rune_id[msgEnt] >= 0 && !g_bScreenFadeAllowed)
{
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
// Вернуть количество зарегистрированных рун
public rm_get_runes_count_api()
{
return runes_registered;
}
// Вернуть номер руны по названию
public rm_get_rune_by_name_api(rune_name[])
{
for(new i = 0; i < runes_registered;i++)
{
if (equali(rune_name,rune_list_name[i]))
return i;
}
// FIX AES FLAGS MAX CHAR[30]
new name_len = strlen(rune_name);
for(new i = 0; i < runes_registered;i++)
{
if (strlen(rune_list_name[i]) <= name_len)
continue;
if (equali(rune_name,rune_list_name[i],name_len))
return i;
}
return -1;
}
// Лимит на количество рун
public RM_MaxRunesAtOneTime(plug_id, num)
{
for(new i = 0; i < runes_registered;i++)
{
if (rune_list_id[i] == plug_id)
rune_list_maxcount[i] = num;
}
}
// Форвард из GAMECMS означающий что игрок с GAMECMS подключен
public OnAPIMemberConnected(id, memberId, memberName[])
{
g_bRegGameCMS[id] = true;
}
// Предупредить игрока о необходимости зарегистрироваться на веб сайте
public rm_print_register_api(id)
{
if (get_gametime() - g_fLastRegisterPrint[id] > 1.0)
{
g_fLastRegisterPrint[id] = get_gametime() + 8.0;
rm_show_dhud_message(id, DHUD_POS_NOTIFY,{255, 94, 0},10.0,false,"%s: %L",runemod_prefix, LANG_PLAYER, "runemod_print_need_register");
}
}
// Необходимо зарегистрироваться на веб сайте (GAMECMS) для того что бы поднять руну
public rm_need_gamecms_register_api(plug_id)
{
for(new i = 0; i < runes_registered;i++)
{
if (rune_list_id[i] == plug_id)
rune_list_gamecms[i] = true;
}
}
// Руна является предметом (поднял и забыл)
public rm_rune_set_item(plug_id)
{
for(new i = 0; i < runes_registered;i++)
{
if (rune_list_id[i] == plug_id)
rune_list_isItem[i] = true;
}
}
// 3aбpaть pyнy пpи cмepти игpoкa
public CBasePlayer_Killed_Post(pVictim, pAttacker, pGib)
{
if (is_real_player(pVictim))
{
lock_rune_pickup[pVictim] = 0;
player_drop_rune(pVictim);
player_drop_all_items(pVictim);
}
}
// 3aбpaть pyнy пpи пoявлeнии игpoкa
public CBasePlayer_Spawn_Post(const id)
{
if (is_real_player(id))
{
if (runemod_newround_remove > 0)
{
if (is_real_player(id))
{
lock_rune_pickup[id] = 0;
player_drop_rune(id);
player_drop_all_items(id);
}
}
if (runemod_rune_shop > 0 && is_user_alive(id))
{
client_print_color(id, print_team_red, "^4%s^3: %L!",runemod_prefix, LANG_PLAYER, "runemod_print_shopmenu");
}
}
}
// Подсветка модели игрока
public rm_highlight_player(rune_id, id)
{
if (runemod_player_highlight && is_real_player(id))
{
if (rune_id >= 0)
rg_set_rendering(id, kRenderFxGlowShell, _, rune_list_model_color[rune_id], 10.0);
}
}
// Подсветка экрана игрока
public rm_highlight_screen(rune_id, id, hpower)
{
if (runemod_screen_highlight && is_real_player(id))
{
new bColor[3];
bColor[0] = floatround(rune_list_model_color[rune_id][0]);
bColor[1] = floatround(rune_list_model_color[rune_id][1]);
bColor[2] = floatround(rune_list_model_color[rune_id][2]);
if (rune_id >= 0)
{
RM_SCREENFADE(id, bColor , 1.0, 0.0, hpower, FFADE_STAYOUT | FFADE_MODULATE, true,true);
}
}
}
// Функция сбрасывает действия всех предметов
public player_drop_all_items(id)
{
for(new i = 0; i < runes_registered;i++)
{
if (rune_list_isItem[i])
rm_drop_rune_callback(rune_list_id[i], id, i);
}
}
// Фyнкция зaбиpaeт pyнy и вызывaeт cooтвeтcтвyющyю фyнкцию в плaгинe pyны
public player_drop_rune(id)
{
if (is_real_player(id))
{
if (active_rune_id[id] >= 0)
{
new rune_id = active_rune_id[id];
if (rune_id >= 0)
{
if (is_user_connected(id))
{
new is_item = rune_list_isItem[rune_id];
if (!is_item)
{
new iPlayers[ 32 ], iNum;
if (runemod_notify_players_drop)
get_players( iPlayers, iNum, "ch" );
else
get_players( iPlayers, iNum, "bch" );
new username[MAX_NAME_LENGTH];
if (runemod_notify_players_drop)
get_user_name(id,username,charsmax(username));
for( new i = 0; i < iNum; i++ )
{
new spec_id = iPlayers[ i ];
if (runemod_notify_players_drop)
{
if ( spec_id != id )
{
client_print_color(spec_id, print_team_red, "^4%s^3 %L",runemod_prefix, LANG_PLAYER, "runemod_drop_rune_noty", username, LANG_PLAYER, rune_list_name[rune_id]);
}
}
else
{
new specTarget = get_entvar(spec_id, var_iuser2);
if (spec_id != id && specTarget == id)
{
client_print_color(spec_id, print_team_red, "^4%s^3 %L",runemod_prefix, LANG_PLAYER, "runemod_drop_rune", LANG_PLAYER, rune_list_name[rune_id]);
}
}
}
client_print_color(id, print_team_red, "^4%s^3 %L",runemod_prefix, LANG_PLAYER, "runemod_drop_rune", LANG_PLAYER, rune_list_name[rune_id]);
}
}
rm_drop_rune_callback(rune_list_id[rune_id], id, rune_id);
}
}
active_rune_id[id] = -1;
rm_reset_highlight(id);
}
}
// Сообщение о том что действие предмета прекратилось
public rm_drop_item_api(plug_id,id)
{
new rune_id = get_runeid_by_pluginid(plug_id);
if (rune_id >= 0 && is_user_connected(id))
{
new username[MAX_NAME_LENGTH];
if (runemod_notify_players_drop)
get_user_name(id,username,charsmax(username));
new iPlayers[ 32 ], iNum;
if (runemod_notify_players_drop)
get_players( iPlayers, iNum, "ch" );
else
get_players( iPlayers, iNum, "bch" );
for( new i = 0; i < iNum; i++ )
{
new spec_id = iPlayers[ i ];
if (runemod_notify_players_drop)
{
if ( spec_id != id )
{
client_print_color(spec_id, print_team_red, "^4%s^3 %L",runemod_prefix, LANG_PLAYER, "runemod_drop_item_noty", username, LANG_PLAYER, rune_list_name[rune_id]);
}
}
else
{
new specTarget = get_entvar(spec_id, var_iuser2);
if (specTarget == id)
{
client_print_color(spec_id, print_team_red, "^4%s^3 %L",runemod_prefix, LANG_PLAYER, "runemod_drop_item", LANG_PLAYER, rune_list_name[rune_id]);
}
}
}
client_print_color(id, print_team_red, "^4%s^3 %L",runemod_prefix, LANG_PLAYER, "runemod_drop_item", LANG_PLAYER, rune_list_name[rune_id]);
}
}
// Сообщение о том что действие предмета прекратилось по номеру руны
public rm_drop_item_api_by_rune_id(rune_id,id)
{
if (rune_id >= 0 && is_user_connected(id))
{
new username[MAX_NAME_LENGTH];
if (runemod_notify_players_drop)
get_user_name(id,username,charsmax(username));
new iPlayers[ 32 ], iNum;
if (runemod_notify_players_drop)
get_players( iPlayers, iNum, "ch" );
else
get_players( iPlayers, iNum, "bch" );
for( new i = 0; i < iNum; i++ )
{
new spec_id = iPlayers[ i ];
if (runemod_notify_players_drop)
{
if ( spec_id != id )
{
client_print_color(spec_id, print_team_red, "^4%s^3 %L",runemod_prefix, LANG_PLAYER, "runemod_drop_item_noty", username, LANG_PLAYER, rune_list_name[rune_id]);
}
}
else
{
new specTarget = get_entvar(spec_id, var_iuser2);
if (specTarget == id)
{
client_print_color(spec_id, print_team_red, "^4%s^3 %L",runemod_prefix, LANG_PLAYER, "runemod_drop_item", LANG_PLAYER, rune_list_name[rune_id]);
}
}
}
client_print_color(id, print_team_red, "^4%s^3 %L",runemod_prefix, LANG_PLAYER, "runemod_drop_item", LANG_PLAYER, rune_list_name[rune_id]);
}
}
// Заблокировать возможность поднять руну или предмет
public rm_lock_pickup(id, iBlock)
{
if (is_real_player(id))
{
lock_rune_pickup[id] = iBlock;