This repository has been archived by the owner on Jan 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bb_walkguard.sma
1243 lines (1011 loc) · 33.4 KB
/
bb_walkguard.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 <fakemeta>
#include <xs>
#include <zombieplague>
#include <colorchat>
#define PLUGIN "WalkGuard"
#define VERSION "1.3.2"
#define AUTHOR "mogel"
#define TASK_NUKE 9987
#define TASK_AMBIENCE 1234
/*
* fakemeta-version by djmd378
*/
enum ZONEMODE {
ZM_NOTHING,
ZM_CAMPING,
ZM_CAMPING_T1, // Team 1 -> e.g. Terrorist
ZM_CAMPING_T2, // Team 2 -> e.g. Counter-Terroris
ZM_BLOCK_ALL,
ZM_KILL,
ZM_KILL_T1, // DoD-Unterstzung
ZM_KILL_T2
}
new zonemode[ZONEMODE][] = { "ZONE_MODE_NONE", "ZONE_MODE_CAMPER", "ZONE_MODE_CAMPER_T1", "ZONE_MODE_CAMPER_T2", "ZONE_MODE_BLOCKING", "ZONE_MODE_CHEATER", "ZONE_MODE_CHEATER_T1", "ZONE_MODE_CHEATER_T2" }
new zonename[ZONEMODE][] = { "wgz_none", "wgz_camper", "wgz_camper_t1", "wgz_camper_t2", "wgz_block_all", "wgz_kill", "wgz_kill_t1", "wgz_kill_t2" }
new solidtyp[ZONEMODE] = { SOLID_NOT, SOLID_TRIGGER, SOLID_TRIGGER, SOLID_TRIGGER, SOLID_BBOX, SOLID_TRIGGER, SOLID_TRIGGER, SOLID_TRIGGER }
new zonecolor[ZONEMODE][3] = {
{ 255, 0, 255 }, // nichts
{ 0, 255, 0 }, // Camperzone
{ 0, 255, 128 }, // Camperzone T1
{ 128, 255, 0 }, // Camperzone T2
{ 255, 255, 255 }, // alle Blockieren
{ 255, 0, 0 }, // Kill
{ 255, 0, 128 }, // Kill - T1
{ 255, 128, 0 } // Kill - T2
}
#define ZONEID pev_iuser1
#define CAMPERTIME pev_iuser2
new zone_color_aktiv[3] = { 0, 0, 255 }
new zone_color_red[3] = { 255, 0, 0 }
new zone_color_green[3] = { 255, 255, 0 }
new g_touched[33]
new g_nukelaunched = false
new g_firsttouch
new g_semiclipoffed = false
new g_closed = false
// 所有的区
#define MAXZONES 100
new zone[MAXZONES]
new maxzones // 这么多的存在
new index // 当前区域
// 编辑功能
new setupunits = 10 // 大小在这些单位要求
new direction = 0 // 0 -> X-Koorinaten / 1 -> Y-Koords / 2 -> Z-Koords
new koordinaten[3][] = { "TRANSLATE_X_KOORD", "TRANSLATE_Y_KOORD", "TRANSLATE_Z_KOORD" }
new spr_dot // ben飆igt f die Lininen
new editor = 0 // 该球员目前上创建..男人?verkraftet nur einen Editor
new camperzone[33] // 最后一条消息露营区
new Float:campertime[33] // 到达的区域中的第一次约会
new Float:camping[33] // 露营的最后日期
#define TASK_BASIS_CAMPER 2000
#define TASK_BASIS_SHOWZONES 1000
new pcv_damage
new pcv_botdamage
new pcv_immunity
new pcv_direction
new pcv_botdirection
new pcv_damageicon
// 更少的CPU
new slap_direction
new slap_botdirection
new slap_damage
new slap_botdamage
new admin_immunity
new icon_damage // 损伤图标
new bool:no_change_bgm = false
enum ROUNDSTATUS {
RS_UNDEFINED,
RS_RUNNING,
RS_FREEZETIME,
RS_END,
}
new ROUNDSTATUS:roundstatus = RS_UNDEFINED
new amblist[][] = {
"sound/zmParadise/ze_showdown.mp3",
"sound/zmParadise/ze_rescue2.mp3"
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("WalkGuard", VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED)
server_cmd("WalkGuard %s", VERSION)
pcv_damage = register_cvar("wg_damage", "10")
pcv_botdamage = register_cvar("wg_botdamage", "0") // 机器人只是普通的愚蠢......也看不懂
pcv_immunity = register_cvar("wg_immunity", "0") // 管理员免疫力酹不需要
pcv_direction = register_cvar("wg_direction", "1") // 训练鄟谎言对掴
pcv_botdirection = register_cvar("wg_botdirection", "1") // dito f Bots
pcv_damageicon = register_cvar("wg_damageicon", "262144") // 实际上箭头
register_menu("MainMenu", -1, "MainMenuAction", 0)
register_menu("EditMenu", -1, "EditMenuAction", 0)
register_menu("KillMenu", -1, "KillMenuAction", 0)
// 菜单
register_clcmd("walkguardmenu", "InitWalkGuard", ADMIN_RCON, " - open the WalkGuard-Menu")
// 语言
register_dictionary("walkguard.txt")
// 变量的加载设置
register_event("HLTV", "Event_FreezeTime", "a", "1=0", "2=0")
register_logevent("Event_RoundStart", 2, "1=Round_Start")
register_logevent("Event_RoundEnd", 2, "1=Round_End")
register_srvcmd("zp_no_change_bgm", "no_ch_bgm")
register_forward(FM_Touch, "fw_touch")
// 补给区
set_task(1.0, "LoadWGZ")
}
public no_ch_bgm()
{
no_change_bgm = true
}
public plugin_precache() {
precache_model("models/gib_skull.mdl")
spr_dot = precache_model("sprites/dot.spr")
}
public client_disconnect(player) {
// aus irgend welchen Grden ist der Spieler einfach wech........
if (player == editor) HideAllZones()
}
public Event_FreezeTime() {
roundstatus = RS_FREEZETIME
}
public Event_RoundStart() {
roundstatus = RS_RUNNING
// 不错的CPU和注意变量在同一个开始
slap_damage = get_pcvar_num(pcv_damage)
slap_direction = get_pcvar_num(pcv_direction)
slap_botdamage = get_pcvar_num(pcv_botdamage)
slap_botdirection = get_pcvar_num(pcv_botdirection)
admin_immunity = get_pcvar_num(pcv_immunity)
icon_damage = get_pcvar_num(pcv_damageicon)
remove_task(TASK_NUKE)
remove_task(TASK_AMBIENCE)
g_nukelaunched = false
g_semiclipoffed = false
g_closed = false
for(new i = 0; i<33; i++)
{
g_touched[i] = false
}
new cfgdir[32]
get_configsdir(cfgdir, charsmax(cfgdir))
// 执行配置文件 (zombieplague.cfg)
new mapname[64]
get_mapname(mapname, 63)
if(containi(mapname, "ze_") == 0)
{
server_cmd("exec %s/zombieescape.cfg", cfgdir)
}
else
{
server_cmd("exec %s/zombieplague.cfg", cfgdir)
}
}
public Event_RoundEnd() {
roundstatus = RS_END
no_change_bgm = false
}
// -----------------------------------------------------------------------------------------
//
// WalkGuard-Action
//
// -> 这里的一切都发生了什么
//
// -----------------------------------------------------------------------------------------
public fw_touch(zone, player) {
if (editor) return FMRES_IGNORED
if (!pev_valid(zone) || !is_user_connected(player))
return FMRES_IGNORED
static classname[33]
pev(player, pev_classname, classname, 32)
if (!equal(classname, "player"))
return FMRES_IGNORED
pev(zone, pev_classname, classname, 32)
if (!equal(classname, "walkguardzone"))
return FMRES_IGNORED
if (roundstatus == RS_RUNNING)
ZoneTouch(player, zone)
return FMRES_IGNORED
}
public ZoneTouch(player, zone) {
new zm = pev(zone, ZONEID)
new userteam = get_user_team(player)
if( (ZONEMODE:zm == ZM_KILL_T1) && !g_closed )
{
g_closed = true
g_semiclipoffed = true
server_cmd("semiclip_offnow")
}
if((ZONEMODE:zm == ZM_CAMPING) && (!g_semiclipoffed))
{
g_semiclipoffed = true
// 运行服务器命令
server_cmd("semiclip_offnow")
new cfgdir[32]
get_configsdir(cfgdir, charsmax(cfgdir))
// 执行配置文件 (zombieplague.cfg)
server_cmd("exec %s/zp_norespawn.cfg", cfgdir)
if(!g_closed)
{
ColorChat(0, GREY, "Console: ** SOMEONE REACHED RESCUE ZONE. SEMICLIP DISABLED **")
server_cmd("sayserver @** 到達救援地點,人穿人功能已經關閉 **")
if(!no_change_bgm)
{
// 停止目前的氛围和玩一个新的
server_cmd("zp_stop_amb")
set_task(1.0, "startamb", TASK_AMBIENCE)
}
}
g_nukelaunched = false
}
if(ZONEMODE:zm == ZM_KILL)
{
g_touched[player] = true
if(!g_nukelaunched)
{
ColorChat(0, GREY, "Console: ** NUCLEAR IN 5 SECONDS **")
server_cmd("sayserver @** 核弹将在 5 秒后入境 **")
g_firsttouch = zp_get_user_zombie(player)
g_nukelaunched = true
set_task(5.0, "nukebomb", TASK_NUKE, _, _, "b")
}
}
// 露营
if ( ((ZONEMODE:zm == ZM_CAMPING_T1) && (userteam == 1)) || ((ZONEMODE:zm == ZM_CAMPING_T2) && (userteam == 2)) ) {
if (!camping[player]) {
client_print(player, print_center, "%L", player, "WALKGUARD_CAMPING_INIT")
// Gratulation ... Du wirst beobachtet
camperzone[player] = zone
campertime[player] = get_gametime()
camping[player] = get_gametime()
set_task(0.5, "ZoneModeCamper", TASK_BASIS_CAMPER + player, _, _, "b")
} else {
// immer fleissig mitz鄣len
camping[player] = get_gametime()
}
}
// Kill Bill
//if ( ((ZONEMODE:zm == ZM_KILL_T1) && (userteam == 1)) || ((ZONEMODE:zm == ZM_KILL_T2) && (userteam == 2)))
// set_task(0.1, "ZoneModeKill", player)
}
public startamb(taskid)
{
client_cmd(0, "mp3 play %s", amblist[random_num(0, sizeof amblist - 1)])
}
public nukebomb(TASKID)
{
for(new id = 0; id<33; id++)
{
if(is_user_connected(id) && is_user_alive(id))
if(zp_get_user_zombie(id) != g_firsttouch)
user_silentkill(id)
client_cmd(0,"speak ambience/thunder_clap.wav")
}
}
public ZoneModeKill(player) {
if (!is_user_connected(player) || !is_user_alive(player)) return
user_silentkill(player)
for(new i = 0; i < 5; i++) client_print(player, print_chat, "[WalkGuard] %L", player, "WALKGUARD_KILL_MESSAGE")
client_cmd(player,"speak ambience/thunder_clap.wav")
}
public ZoneModeCamper(player) {
player -= TASK_BASIS_CAMPER
if (!is_user_connected(player))
{
// so ein Feigling ... hat sich einfach verdrkt ^^
remove_task(TASK_BASIS_CAMPER + player)
return
}
new Float:gametime = get_gametime();
if ((gametime - camping[player]) > 0.5)
{
// *juhu* ... wieder frei
campertime[player] = 0.0
camping[player] = 0.0
remove_task(TASK_BASIS_CAMPER + player)
return
}
new ct = pev(camperzone[player], CAMPERTIME)
new left = ct - floatround( gametime - campertime[player])
if (left < 1)
{
client_print(player, print_center, "%L", player, "WALKGUARD_CAMPING_DAMG")
if (is_user_bot(player))
{
if (slap_botdirection) RandomDirection(player)
fm_fakedamage(player, "camping", float(slap_botdamage), 0)
} else
{
if (slap_direction) RandomDirection(player)
fm_fakedamage(player, "camping", float(slap_damage), icon_damage)
}
} else
{
client_print(player, print_center, "%L", player, "WALKGUARD_CAMPING_TIME", left)
}
}
public RandomDirection(player) {
new Float:velocity[3]
velocity[0] = random_float(-256.0, 256.0)
velocity[1] = random_float(-256.0, 256.0)
velocity[2] = random_float(-256.0, 256.0)
set_pev(player, pev_velocity, velocity)
}
// -----------------------------------------------------------------------------------------
//
// Zonenerstellung
//
// -----------------------------------------------------------------------------------------
public CreateZone(Float:position[3], Float:mins[3], Float:maxs[3], zm, campertime) {
new entity = fm_create_entity("info_target")
set_pev(entity, pev_classname, "walkguardzone")
fm_entity_set_model(entity, "models/gib_skull.mdl")
fm_entity_set_origin(entity, position)
set_pev(entity, pev_movetype, MOVETYPE_FLY)
new id = pev(entity, ZONEID)
if (editor)
{
set_pev(entity, pev_solid, SOLID_NOT)
} else
{
set_pev(entity, pev_solid, solidtyp[ZONEMODE:id])
}
fm_entity_set_size(entity, mins, maxs)
fm_set_entity_visibility(entity, 0)
set_pev(entity, ZONEID, zm)
set_pev(entity, CAMPERTIME, campertime)
//log_amx("create zone '%s' with campertime %i seconds", zonename[ZONEMODE:zm], campertime)
return entity
}
public CreateNewZone(Float:position[3]) {
new Float:mins[3] = { -32.0, -32.0, -32.0 }
new Float:maxs[3] = { 32.0, 32.0, 32.0 }
return CreateZone(position, mins, maxs, 0, 10); // ZM_NONE
}
public CreateZoneOnPlayer(player) {
// Position und erzeugen
new Float:position[3]
pev(player, pev_origin, position)
new entity = CreateNewZone(position)
FindAllZones()
for(new i = 0; i < maxzones; i++) if (zone[i] == entity) index = i;
}
// -----------------------------------------------------------------------------------------
//
// Load & Save der WGZ
//
// -----------------------------------------------------------------------------------------
public SaveWGZ(player) {
new zonefile[200]
new mapname[50]
// Verzeichnis holen
get_configsdir(zonefile, 199)
format(zonefile, 199, "%s/walkguard", zonefile)
if (!dir_exists(zonefile)) mkdir(zonefile)
// Namen er Map erstellen
get_mapname(mapname, 49)
format(zonefile, 199, "%s/%s.wgz", zonefile, mapname)
delete_file(zonefile) // pauschal
FindAllZones() // zur Sicherheit
// Header
write_file(zonefile, "; V1 - WalkGuard Zone-File")
write_file(zonefile, "; <zonename> <position (x/y/z)> <mins (x/y/z)> <maxs (x/y/z)> [<parameter>] ")
write_file(zonefile, ";")
write_file(zonefile, ";")
write_file(zonefile, "; parameter")
write_file(zonefile, ";")
write_file(zonefile, "; - wgz_camper <time>")
write_file(zonefile, "; - wgz_camper_t1 <time>")
write_file(zonefile, "; - wgz_camper_t2 <time>")
write_file(zonefile, "; - wgz_camper_t3 <time>")
write_file(zonefile, "; - wgz_camper_t4 <time>")
write_file(zonefile, ";")
write_file(zonefile, "")
// alle Zonen speichern
for(new i = 0; i < maxzones; i++)
{
new z = zone[i] // das Entity
// diverse Daten der Zone
new zm = pev(z, ZONEID)
// Koordinaten holen
new Float:pos[3]
pev(z, pev_origin, pos)
// Dimensionen holen
new Float:mins[3], Float:maxs[3]
pev(z, pev_mins, mins)
pev(z, pev_maxs, maxs)
// Ausgabe formatieren
// -> Type und CamperTime
new output[1000]
format(output, 999, "%s", zonename[ZONEMODE:zm])
// -> Position
format(output, 999, "%s %.1f %.1f %.1f", output, pos[0], pos[1], pos[2])
// -> Dimensionen
format(output, 999, "%s %.0f %.0f %.0f", output, mins[0], mins[1], mins[2])
format(output, 999, "%s %.0f %.0f %.0f", output, maxs[0], maxs[1], maxs[2])
// diverse Parameter
if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
{
new ct = pev(z, CAMPERTIME)
format(output, 999, "%s %i", output, ct)
}
// und schreiben
write_file(zonefile, output)
}
client_print(player, print_chat, "%L", player, "ZONE_FILE_SAVED", zonefile)
}
public LoadWGZ() {
new zonefile[200]
new mapname[50]
// Verzeichnis holen
get_configsdir(zonefile, 199)
format(zonefile, 199, "%s/walkguard", zonefile)
// Namen er Map erstellen
get_mapname(mapname, 49)
format(zonefile, 199, "%s/%s.wgz", zonefile, mapname)
if (!file_exists(zonefile))
{
log_amx("no zone-file found")
return
}
// einlesen der Daten
new input[1000], line = 0, len
while( (line = read_file(zonefile , line , input , 127 , len) ) != 0 )
{
if (!strlen(input) || (input[0] == ';')) continue; // Kommentar oder Leerzeile
new data[20], zm = 0, ct // "abgebrochenen" Daten - ZoneMode - CamperTime
new Float:mins[3], Float:maxs[3], Float:pos[3] // Gr廲e & Position
// Zone abrufen
strbreak(input, data, 20, input, 999)
zm = -1
for(new i = 0; ZONEMODE:i < ZONEMODE; ZONEMODE:i++)
{
// 瓏derungen von CS:CZ zu allen Mods
if (equal(data, "wgz_camper_te")) format(data, 19, "wgz_camper_t1")
if (equal(data, "wgz_camper_ct")) format(data, 19, "wgz_camper_t2")
if (equal(data, zonename[ZONEMODE:i])) zm = i;
}
if (zm == -1)
{
log_amx("undefined zone -> '%s' ... dropped", data)
continue;
}
// Position holen
strbreak(input, data, 20, input, 999); pos[0] = str_to_float(data);
strbreak(input, data, 20, input, 999); pos[1] = str_to_float(data);
strbreak(input, data, 20, input, 999); pos[2] = str_to_float(data);
// Dimensionen
strbreak(input, data, 20, input, 999); mins[0] = str_to_float(data);
strbreak(input, data, 20, input, 999); mins[1] = str_to_float(data);
strbreak(input, data, 20, input, 999); mins[2] = str_to_float(data);
strbreak(input, data, 20, input, 999); maxs[0] = str_to_float(data);
strbreak(input, data, 20, input, 999); maxs[1] = str_to_float(data);
strbreak(input, data, 20, input, 999); maxs[2] = str_to_float(data);
if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
{
// Campertime wird immer mitgeliefert
strbreak(input, data, 20, input, 999)
ct = str_to_num(data)
}
// und nun noch erstellen
CreateZone(pos, mins, maxs, zm, ct);
}
FindAllZones()
HideAllZones()
}
// -----------------------------------------------------------------------------------------
//
// WalkGuard-Menu
//
// -----------------------------------------------------------------------------------------
public FX_Box(Float:sizemin[3], Float:sizemax[3], color[3], life) {
// FX
message_begin(MSG_ALL, SVC_TEMPENTITY);
write_byte(31);
write_coord( floatround( sizemin[0] ) ); // x
write_coord( floatround( sizemin[1] ) ); // y
write_coord( floatround( sizemin[2] ) ); // z
write_coord( floatround( sizemax[0] ) ); // x
write_coord( floatround( sizemax[1] ) ); // y
write_coord( floatround( sizemax[2] ) ); // z
write_short(life) // Life
write_byte(color[0]) // Color R / G / B
write_byte(color[1])
write_byte(color[2])
message_end();
}
public FX_Line(start[3], stop[3], color[3], brightness) {
message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, editor)
write_byte( TE_BEAMPOINTS )
write_coord(start[0])
write_coord(start[1])
write_coord(start[2])
write_coord(stop[0])
write_coord(stop[1])
write_coord(stop[2])
write_short( spr_dot )
write_byte( 1 ) // framestart
write_byte( 1 ) // framerate
write_byte( 4 ) // life in 0.1's
write_byte( 5 ) // width
write_byte( 0 ) // noise
write_byte( color[0] ) // r, g, b
write_byte( color[1] ) // r, g, b
write_byte( color[2] ) // r, g, b
write_byte( brightness ) // brightness
write_byte( 0 ) // speed
message_end()
}
public DrawLine(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, color[3]) {
new start[3]
new stop[3]
start[0] = floatround( x1 )
start[1] = floatround( y1 )
start[2] = floatround( z1 )
stop[0] = floatround( x2 )
stop[1] = floatround( y2 )
stop[2] = floatround( z2 )
FX_Line(start, stop, color, 200)
}
public ShowAllZones() {
FindAllZones() // zur Sicherheit alle suchen
for(new i = 0; i < maxzones; i++)
{
new z = zone[i]
remove_task(TASK_BASIS_SHOWZONES + z)
set_pev(z, pev_solid, SOLID_NOT)
set_task(0.2, "ShowZoneBox", TASK_BASIS_SHOWZONES + z, _, _, "b")
}
}
public ShowZoneBox(entity) {
entity -= TASK_BASIS_SHOWZONES
if ((!fm_is_valid_ent(entity)) || !editor) return
// Koordinaten holen
new Float:pos[3]
pev(entity, pev_origin, pos)
if (!fm_is_in_viewcone(editor, pos) && (entity != zone[index])) return // sieht der Editor eh nicht
// jetzt vom Editor zur Zone testen... Zonen hinter der Wand aber im ViewCone
// msen nicht gezeichnet werden
new Float:editorpos[3]
pev(editor, pev_origin, editorpos)
new Float:hitpoint[3] // da ist der Treffer
fm_trace_line(-1, editorpos, pos, hitpoint)
// Linie zur Zone zeichnen ... dann wird sie schneller gefunden
if (entity == zone[index]) DrawLine(editorpos[0], editorpos[1], editorpos[2] - 16.0, pos[0], pos[1], pos[2], { 255, 0, 0} )
// Distanz zum Treffer ... ist Wert gr廲er dann war da etwas
new Float:dh = vector_distance(editorpos, pos) - vector_distance(editorpos, hitpoint)
if ( (floatabs(dh) > 128.0) && (entity != zone[index])) return // hinter einer Wand
// -+*+- die Zone muss gezeichnet werden -+*+-
// Dimensionen holen
new Float:mins[3], Float:maxs[3]
pev(entity, pev_mins, mins)
pev(entity, pev_maxs, maxs)
// Gr廲e in Absolut umrechnen
mins[0] += pos[0]
mins[1] += pos[1]
mins[2] += pos[2]
maxs[0] += pos[0]
maxs[1] += pos[1]
maxs[2] += pos[2]
new id = pev(entity, ZONEID)
new color[3]
color[0] = (zone[index] == entity) ? zone_color_aktiv[0] : zonecolor[ZONEMODE:id][0]
color[1] = (zone[index] == entity) ? zone_color_aktiv[1] : zonecolor[ZONEMODE:id][1]
color[2] = (zone[index] == entity) ? zone_color_aktiv[2] : zonecolor[ZONEMODE:id][2]
// einzelnen Linien der Box zeichnen
// -> alle Linien beginnen bei maxs
DrawLine(maxs[0], maxs[1], maxs[2], mins[0], maxs[1], maxs[2], color)
DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], maxs[2], color)
DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], maxs[1], mins[2], color)
// -> alle Linien beginnen bei mins
DrawLine(mins[0], mins[1], mins[2], maxs[0], mins[1], mins[2], color)
DrawLine(mins[0], mins[1], mins[2], mins[0], maxs[1], mins[2], color)
DrawLine(mins[0], mins[1], mins[2], mins[0], mins[1], maxs[2], color)
// -> die restlichen 6 Lininen
DrawLine(mins[0], maxs[1], maxs[2], mins[0], maxs[1], mins[2], color)
DrawLine(mins[0], maxs[1], mins[2], maxs[0], maxs[1], mins[2], color)
DrawLine(maxs[0], maxs[1], mins[2], maxs[0], mins[1], mins[2], color)
DrawLine(maxs[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], color)
DrawLine(maxs[0], mins[1], maxs[2], mins[0], mins[1], maxs[2], color)
DrawLine(mins[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], color)
// der Rest wird nur gezeichnet wenn es sich um ide aktuelle Box handelt
if (entity != zone[index]) return
// jetzt noch die Koordinaten-Linien
if (direction == 0) // X-Koordinaten
{
DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], mins[2], zone_color_green)
DrawLine(maxs[0], maxs[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_green)
DrawLine(mins[0], maxs[1], maxs[2], mins[0], mins[1], mins[2], zone_color_red)
DrawLine(mins[0], maxs[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red)
}
if (direction == 1) // Y-Koordinaten
{
DrawLine(mins[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_red)
DrawLine(maxs[0], mins[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red)
DrawLine(mins[0], maxs[1], mins[2], maxs[0], maxs[1], maxs[2], zone_color_green)
DrawLine(maxs[0], maxs[1], mins[2], mins[0], maxs[1], maxs[2], zone_color_green)
}
if (direction == 2) // Z-Koordinaten
{
DrawLine(maxs[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2], zone_color_green)
DrawLine(maxs[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], zone_color_green)
DrawLine(maxs[0], maxs[1], mins[2], mins[0], mins[1], mins[2], zone_color_red)
DrawLine(maxs[0], mins[1], mins[2], mins[0], maxs[1], mins[2], zone_color_red)
}
}
public HideAllZones() {
editor = 0 // Men?f den n踄hsten wieder frei geben ... ufnktionalit酹 aktivieren
for(new i = 0; i < maxzones; i++)
{
new id = pev(zone[i], ZONEID)
set_pev(zone[i], pev_solid, solidtyp[ZONEMODE:id])
remove_task(TASK_BASIS_SHOWZONES + zone[i])
}
}
public FindAllZones() {
new entity = -1
maxzones = 0
while( (entity = fm_find_ent_by_class(entity, "walkguardzone")) )
{
zone[maxzones] = entity
maxzones++
}
}
public InitWalkGuard(player) {
new name[33], steam[33]
get_user_name(player, name, 32)
get_user_authid(player, steam, 32)
if (!(get_user_flags(player) & ADMIN_RCON))
{
log_amx("no access-rights for '%s' <%s>", name, steam)
return PLUGIN_HANDLED
}
editor = player
FindAllZones();
ShowAllZones();
set_task(0.1, "OpenWalkGuardMenu", player)
return PLUGIN_HANDLED
}
public OpenWalkGuardMenu(player) {
new trans[70]
new menu[1024]
new zm = -1
new ct
new menukeys = MENU_KEY_0 + MENU_KEY_4 + MENU_KEY_9
if (fm_is_valid_ent(zone[index]))
{
zm = pev(zone[index], ZONEID)
ct = pev(zone[index], CAMPERTIME)
}
format(menu, 1023, "\dWalkGuard-Menu - Version %s\w", VERSION)
format(menu, 1023, "%s^n", menu) // Leerzeile
format(menu, 1023, "%s^n", menu) // Leerzeile
format(menu, 1023, "%L", player, "WGM_ZONE_FOUND", menu, maxzones)
if (zm != -1)
{
format(trans, 69, "%L", player, zonemode[ZONEMODE:zm])
if (ZONEMODE:zm == ZM_CAMPING)
{
format(menu, 1023, "%L", player, "WGM_ZONE_CURRENT_CAMP", menu, index + 1, trans, ct)
} else
{
format(menu, 1023, "%L", player, "WGM_ZONE_CURRENT_NONE", menu, index + 1, trans)
}
menukeys += MENU_KEY_2 + MENU_KEY_3 + MENU_KEY_1
format(menu, 1023, "%s^n", menu) // Leerzeile
format(menu, 1023, "%s^n", menu) // Leerzeile
format(menu, 1023, "%L", player, "WGM_ZONE_EDIT", menu)
format(menu, 1023, "%L", player, "WGM_ZONE_CHANGE", menu)
}
format(menu, 1023, "%s^n", menu) // Leerzeile
format(menu, 1023, "%L" ,player, "WGM_ZONE_CREATE", menu)
if (zm != -1)
{
menukeys += MENU_KEY_6
format(menu, 1023, "%L", player, "WGM_ZONE_DELETE", menu)
}
format(menu, 1023, "%L", player, "WGM_ZONE_SAVE", menu)
format(menu, 1023, "%s^n", menu) // Leerzeile
format(menu, 1023, "%L" ,player, "WGM_ZONE_EXIT", menu)
show_menu(player, menukeys, menu, -1, "MainMenu")
client_cmd(player, "spk sound/buttons/blip1.wav")
}
public MainMenuAction(player, key) {
key = (key == 10) ? 0 : key + 1
switch(key)
{
case 1: {
// Zone editieren
if (fm_is_valid_ent(zone[index])) OpenEditMenu(player); else OpenWalkGuardMenu(player);
}
case 2: {
// vorherige Zone
index = (index > 0) ? index - 1 : index;
OpenWalkGuardMenu(player)
}
case 3: {
// n踄hste Zone
index = (index < maxzones - 1) ? index + 1 : index;
OpenWalkGuardMenu(player)
}
case 4: {
// neue Zone er dem Spieler
if (maxzones < MAXZONES - 1)
{
CreateZoneOnPlayer(player);
ShowAllZones();
MainMenuAction(player, 0); // selber aufrufen
} else
{
client_print(player, print_chat, "%L", player, "ZONE_FULL")
client_cmd(player, "spk sound/buttons/button10.wav")
set_task(0.5, "OpenWalkGuardMenu", player)
}
}
case 6: {
// aktuelle Zone l飉chen
OpenKillMenu(player);
}
case 9: {
// Zonen speichern
SaveWGZ(player)
OpenWalkGuardMenu(player)
}
case 10:{
editor = 0
HideAllZones()
}
}
}
public OpenEditMenu(player) {
new trans[70]
new menu[1024]
new menukeys = MENU_KEY_0 + MENU_KEY_1 + MENU_KEY_4 + MENU_KEY_5 + MENU_KEY_6 + MENU_KEY_7 + MENU_KEY_8 + MENU_KEY_9
format(menu, 1023, "\dEdit WalkGuard-Zone\w")
format(menu, 1023, "%s^n", menu) // Leerzeile
format(menu, 1023, "%s^n", menu) // Leerzeile
new zm = -1
new ct
if (fm_is_valid_ent(zone[index]))
{
zm = pev(zone[index], ZONEID)
ct = pev(zone[index], CAMPERTIME)
}
if (zm != -1)
{
format(trans, 69, "%L", player, zonemode[ZONEMODE:zm])
if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
{
format(menu, 1023, "%L", player, "WGE_ZONE_CURRENT_CAMP", menu, trans, ct)
format(menu, 1023, "%L", player, "WGE_ZONE_CURRENT_CHANGE", menu)
menukeys += MENU_KEY_2 + MENU_KEY_3
} else
{
format(menu, 1023, "%L", player, "WGE_ZONE_CURRENT_NONE", menu, trans)
format(menu, 1023, "%s^n", menu) // Leerzeile
}
}
format(menu, 1023, "%s^n", menu) // Leerzeile
format(trans, 49, "%L", player, koordinaten[direction])
format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_INIT", menu, trans)
format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_MINS", menu)
format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_MAXS", menu)
format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_STEP", menu, setupunits)
format(menu, 1023, "%s^n", menu) // Leerzeile
format(menu, 1023, "%s^n", menu) // Leerzeile
format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_QUIT", menu)
show_menu(player, menukeys, menu, -1, "EditMenu")
client_cmd(player, "spk sound/buttons/blip1.wav")
}
public EditMenuAction(player, key) {
key = (key == 10) ? 0 : key + 1
switch(key)
{
case 1: {
// n踄hster ZoneMode
new zm = -1
zm = pev(zone[index], ZONEID)
if (ZONEMODE:zm == ZM_KILL_T2) zm = 0; else zm++;
set_pev(zone[index], ZONEID, zm)
OpenEditMenu(player)
}
case 2: {
// Campertime runter
new ct = pev(zone[index], CAMPERTIME)
ct = (ct > 5) ? ct - 1 : 5
set_pev(zone[index], CAMPERTIME, ct)
OpenEditMenu(player)
}
case 3: {
// Campertime hoch
new ct = pev(zone[index], CAMPERTIME)
ct = (ct < 30) ? ct + 1 : 30
set_pev(zone[index], CAMPERTIME, ct)
OpenEditMenu(player)
}
case 4: {
// Editier-Richtung 鄚dern
direction = (direction < 2) ? direction + 1 : 0
OpenEditMenu(player)
}
case 5: {
// von "mins" / rot etwas abziehen -> schmaler
ZuRotAddieren()
OpenEditMenu(player)
}
case 6: {
// zu "mins" / rot etwas addieren -> breiter
VonRotAbziehen()
OpenEditMenu(player)
}
case 7: {
// von "maxs" / gelb etwas abziehen -> schmaler
VonGelbAbziehen()
OpenEditMenu(player)
}
case 8: {
// zu "maxs" / gelb etwas addierne -> breiter