- 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
- // m黶sen 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()
- }
- }
- }
复制代码 |