Senior Member
|
07-20-2018
, 06:22
Entity marker
|
#1
|
Hi guys i have found a plugin which can help me to block some zones on maps and i need this because i want to create new small maps, and now i have one issue when i quit the menu for entity creating , my zone is invisible so i wanted to know if it's possible to create two laserbeams who will show a cross (X) so that players can see what are the forbidden zones
PS. glow can do the job also , showing some sprite etc
here are some ss
Here is the code
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#define PLUGIN "2x2block_beta"
#define VERSION "1.4 beta"
#define AUTHOR "wopox"
#define MAXZONES 100
#define ZONEID pev_iuser1
#define TASK_BASIS_SHOWZONES 1000
/*
* Π*ΡΠΎΡ ΠΏΠ»Π°Π³ΠΈΠ½ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΌΠΎΠ΄ΠΈΡΠΈΠΊΠ°ΡΠΈΠ΅ΠΉ WalkGuard 1.3.2.
* ΠΡΠΈΡΠΈΠ°Π»ΡΠ½Π°Ρ ΡΠ΅ΠΌΠ° ΡΠ°Π·Π±ΠΎΡΠΊΠΈ ΠΏΠ»Π°Π³ΠΈΠ½Π°: http://c-s.net.ua/forum/topic57108s0.html - Π½Π°ΡΠ»ΠΈ Π±Π°Π³? ΠΏΠΎΠΆΠ΅Π»Π΅Π»Π°Π½ΠΈΡ, ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄Π°ΡΠΈΠΈ
* ΠΠ° Π±ΠΎΠ»ΡΡΡΡ ΡΠ°ΡΡΡ ΠΊΠΎΠ΄Π° Π½ΡΠΆΠ½ΠΎ Π±Π»Π°Π³ΠΎΠ΄Π°ΡΠΈΡΡ "mogel", ΠΈΠΌΠ΅Π½Π½ΠΎ Π½Π° ΠΎΡΠ½ΠΎΠ²Π΅ Π΅Π³ΠΎ ΠΏΠ»Π°Π³ΠΈΠ½Π° ΡΠΎΠ·Π΄Π°Π½ ΡΡΠΎΡ ΠΏΠ»Π°Π³ΠΈΠ½.
*/
new zonecolor[3] = { 255, 255, 255 }
new zone_color_active[3] = { 0, 0, 255 }
new zone_color_red[3] = { 255, 0, 0 }
new zone_color_yellow[3] = { 255, 255, 0 }
new setupunits = 10
new direction = 0
new coordinates[3][] = { "TRANSLATE_X_COORD", "TRANSLATE_Y_COORD", "TRANSLATE_Z_COORD" }
new spr_dot
new editor = 0
new zone[MAXZONES]
new maxzones
new index
static g_pPlayersNum
static g_pMessageAboutType
static bool: g_b2x2ModeEnable = true;
new RoundCount = 0
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_dictionary("2x2block.txt")
register_cvar("2x2block", VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED)
server_cmd("2x2block %s", VERSION)
register_menu("MainMenu", -1, "MainMenuAction", 0)
register_menu("EditMenu", -1, "EditMenuAction", 0)
register_menu("KillMenu", -1, "KillMenuAction", 0)
register_clcmd("2x2menu", "Init2x2block", ADMIN_RCON, " - open the 2x2block-Menu")
g_pPlayersNum = register_cvar ("2x2_players","10")
g_pMessageAboutType = register_cvar ("2x2_notifytype","2")
//register_clcmd ("say /2x2","printMessageAbout");
register_logevent("Event_RoundStart", 2, "1=Round_Start")
register_forward(FM_Touch, "fw_touch")
set_task(1.0, "LoadBLC")
}
public plugin_precache() {
precache_model("models/gib_skull.mdl")
spr_dot = precache_model("sprites/dot.spr")
}
public client_disconnect(player) {
if (player == editor) HideAllZones()
}
public Event_RoundStart() {
if (get_playersnum () <= get_pcvar_num (g_pPlayersNum)){
set_task(0.1, "OnBlockAllZone")
g_b2x2ModeEnable = true;
}
if (get_playersnum () > get_pcvar_num (g_pPlayersNum)){
set_task(0.1, "OffBlockAllZone")
g_b2x2ModeEnable = false;
}
set_task(0.1, "printMessageAbout")
}
public printMessageAbout (id) {
if (get_pcvar_num(g_pMessageAboutType) == 1) {
if (g_b2x2ModeEnable) {
client_print (0,print_chat,"[2X2 MODE] %L", id, "MODE_ENABLED");
}
if ((!g_b2x2ModeEnable) && RoundCount == 1) {
client_print (0,print_chat,"[2X2 MODE] %L", id, "MODE_DISABLED");
}
}
if (get_pcvar_num(g_pMessageAboutType) == 2) {
if (g_b2x2ModeEnable) {
set_hudmessage(0, 255, 128, -1.0, -0.9, 1, 1.0, 2.0, 0.2, 0.6)
show_hudmessage(0, "[2X2 MODE] %L", id, "MODE_ENABLED");
}
if ((!g_b2x2ModeEnable) && RoundCount == 1) {
set_hudmessage(0, 255, 128, -1.0, -0.9, 1, 1.0, 2.0, 0.2, 0.6)
show_hudmessage(0, "[2X2 MODE] %L", id, "MODE_DISABLED");
}
}
if (get_pcvar_num(g_pMessageAboutType) == 0) {
return PLUGIN_HANDLED
}
return 1
}
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, "2x2blockzone"))
return FMRES_IGNORED
client_print(player,print_center, "This zone is blocked")
return FMRES_IGNORED
}
// Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ Π·ΠΎΠ½
public CreateZone(Float:position[3], Float:mins[3], Float:maxs[3]) {
new entity = fm_create_entity("info_target")
set_pev(entity, pev_classname, "2x2blockzone")
fm_entity_set_model(entity, "models/gib_skull.mdl")
fm_entity_set_origin(entity, position)
set_pev(entity, pev_movetype, MOVETYPE_FLY)
set_pev(entity,pev_renderfx,kRenderFxGlowShell)
if (editor)
{
set_pev(entity, pev_solid, SOLID_NOT)
} else {
set_pev(entity, pev_solid, SOLID_BBOX)
}
fm_entity_set_size(entity, mins, maxs)
fm_set_entity_visibility(entity, 0)
set_pev(entity, ZONEID)
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); // ZM_NONE
}
public CreateZoneOnPlayer(player) {
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;
}
// ΠΠ°Π³ΡΡΠ·ΠΊΠ° ΠΈ ΡΠΎΠ·ΡΠ°Π½Π΅Π½ΠΈΠ΅ *.blc ΡΠ°ΠΉΠ»ΠΎΠ²
public SaveBLC(player) {
new zonefile[200]
new mapname[50]
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π°
get_configsdir(zonefile, 199)
format(zonefile, 199, "%s/2x2blockMaps", zonefile)
if (!dir_exists(zonefile)) mkdir(zonefile)
// Π‘ΠΎΠ·Π΄Π°ΡΡΡΡ ΡΠ°ΠΉΠ»Ρ Ρ ΠΈΠΌΠ΅Π½Π΅ΠΌ ΠΊΠ°ΡΡΡ
get_mapname(mapname, 49)
format(zonefile, 199, "%s/%s.blc", zonefile, mapname)
delete_file(zonefile)
FindAllZones() // Π΄Π»Ρ "Π±Π΅Π·ΠΎΠΏΠ°ΡΠ½ΠΎΡΡΠΈ"
// Header
write_file(zonefile, "; V1 - 2x2block Zone-File")
write_file(zonefile, ";<position (x/y/z)> <mins (x/y/z)> <maxs (x/y/z)>")
write_file(zonefile, ";")
write_file(zonefile, "")
// Π‘ΠΎΡ
ΡΠ°Π½Π΅Π½ΠΈΠ΅ Π²ΡΠ΅Ρ
Π·ΠΎΠ½
for(new i = 0; i < maxzones; i++)
{
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ
new z = zone[i]
new Float:pos[3]
pev(z, pev_origin, pos)
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ°Π·ΠΌΠ΅ΡΠΎΠ²
new Float:mins[3], Float:maxs[3]
pev(z, pev_mins, mins)
pev(z, pev_maxs, maxs)
// ΠΡΠ²ΠΎΠ΄ Π² ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΠΉ ΡΠΎΡΠΌΠ°Ρ
new output[1000]
// -> ΠΠΎΠ·ΠΈΡΠΈΡ
format(output, 999, "%s %.1f %.1f %.1f", output, pos[0], pos[1], pos[2])
// -> Π*Π°Π·ΠΌΠ΅ΡΡ
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])
// ΠΈ Π·Π°ΠΏΠΈΡΠ°ΡΡ Π² ΡΠ°ΠΉΠ»
write_file(zonefile, output)
}
client_print(player, print_chat, "%L", player, "ZONE_FILE_SAVED", zonefile)
}
public LoadBLC() {
new zonefile[200]
new mapname[50]
new data[20]
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π°
get_configsdir(zonefile, 199)
format(zonefile, 199, "%s/2x2blockMaps", zonefile)
// ΠΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠ°ΠΉΠ» Ρ ΠΈΠΌΠ΅Π½Π΅ΠΌ ΠΊΠ°ΡΡΡ
get_mapname(mapname, 49)
format(zonefile, 199, "%s/%s.blc", zonefile, mapname)
if (!file_exists(zonefile))
{
log_amx("no zone-file found")
return
}
// Π§ΠΈΡΠ°Π΅ΠΌ Π΄Π°Π½Π½ΡΠ΅
new input[1000], line = 0, len
while( (line = read_file(zonefile , line , input , 127 , len) ) != 0 )
{
if (!strlen(input) || (input[0] == ';')) continue; // ΠΠ±ΡΠ°Π±ΠΎΡΠΊΠ° ΠΏΡΡΡΡΡ
ΡΡΡΠΎΠΊ ΠΈ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅Π²
new Float:pos[3], Float:mins[3], Float:maxs[3] // ΠΠΎΠ·ΠΈΡΠΈΡ ΠΈ ΡΠ°Π·ΠΌΠ΅ΡΡ
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎΠ·ΠΈΡΠΈΠΈ
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);
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ Π*Π°Π·ΠΌΠ΅ΡΠΎΠ²
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);
// Π‘ΠΎΠ·Π΄Π°ΡΠΌ Π·ΠΎΠ½Ρ
CreateZone(pos, mins, maxs);
}
FindAllZones()
HideAllZones()
}
// 2x2block-Menu
public FX_Box(Float:sizemin[3], Float:sizemax[3], color[3], life) {
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 ) // ΡΡΠΊΠΎΡΡΡ
write_byte( 0 ) // ΡΠΊΠΎΡΠΎΡΡΡ
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() // Π΄Π»Ρ "Π±Π΅Π·ΠΎΠΏΠ°ΡΠ½ΠΎΡΡΠΈ"
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
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ
new Float:pos[3]
pev(entity, pev_origin, pos)
if (!fm_is_in_viewcone(editor, pos) && (entity != zone[index])) return // ΠΡΠ»ΠΈ Π½Π΅ Π² fov
// "ΠΡΠΎΠ²Π΅ΡΠΊΠ° Π½Π° Π²ΠΈΠ΄ΠΈΠΌΠΎΡΡΡ Π·ΠΎΠ½ Π² fov Π³ΡΠΎΠΊΠ°"
// Π½Π΅ Π²ΠΈΠ΄ΠΈΠΌΡΠ΅ - Π½Π΅ ΠΎΡΡΠΈΡΠΎΠ²ΡΠ²Π°ΡΡΡΡ
new Float:editorpos[3]
pev(editor, pev_origin, editorpos)
new Float:hitpoint[3]
fm_trace_line(-1, editorpos, pos, hitpoint)
if (entity == zone[index]) DrawLine(editorpos[0], editorpos[1], editorpos[2] - 16.0, pos[0], pos[1], pos[2], { 255, 0, 0} )
new Float:dh = vector_distance(editorpos, pos) - vector_distance(editorpos, hitpoint)
if ( (floatabs(dh) > 128.0) && (entity != zone[index])) return
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ
new Float:mins[3], Float:maxs[3]
pev(entity, pev_mins, mins)
pev(entity, pev_maxs, maxs)
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 color[3]
color[0] = (zone[index] == entity) ? zone_color_active[0] : zonecolor[0]
color[1] = (zone[index] == entity) ? zone_color_active[1] : zonecolor[1]
color[2] = (zone[index] == entity) ? zone_color_active[2] : zonecolor[2]
// Π*ΠΈΡΠΎΠ²ΠΊΠ° Π»ΠΈΠ½ΠΈΠΉ Box'ΠΎΠ² (Π·ΠΎΠ½)
// -> Π²ΡΠ΅ 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)
// -> Π²ΡΠ΅ 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)
// -> ΠΎΡΡΠ°Π»ΡΠ½ΡΠ΅ 6 Π»ΠΈΠ½ΠΈΠΉ
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)
if (entity != zone[index]) return
// ΠΠΈΠ½ΠΈΠΈ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ
if (direction == 0) // X-ΠΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ
{
DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], mins[2], zone_color_yellow)
DrawLine(maxs[0], maxs[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_yellow)
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-ΠΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ
{
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_yellow)
DrawLine(maxs[0], maxs[1], mins[2], mins[0], maxs[1], maxs[2], zone_color_yellow)
}
if (direction == 2) // Z-ΠΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ
{
DrawLine(maxs[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2], zone_color_yellow)
DrawLine(maxs[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], zone_color_yellow)
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
for(new i = 0; i < maxzones; i++)
{
set_pev(zone[i], pev_solid, SOLID_BBOX)
remove_task(TASK_BASIS_SHOWZONES + zone[i])
}
}
public FindAllZones() {
new entity = -1
maxzones = 0
while( (entity = fm_find_ent_by_class(entity, "2x2blockzone")) )
{
zone[maxzones] = entity
maxzones++
}
}
public Init2x2block(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, "Open2x2Menu", player)
return PLUGIN_HANDLED
}
public OnBlockAllZone(player) {
RoundCount = 0
editor = 0
HideAllZones()
}
public OffBlockAllZone(player) {
RoundCount++
editor = 0
FindAllZones();
ShowAllZones();
}
public Open2x2Menu(player) {
new menu[1024]
new zm = -1
new menukeys = MENU_KEY_0 + MENU_KEY_4 + MENU_KEY_9
if (fm_is_valid_ent(zone[index]))
{
zm = pev(zone[index], ZONEID)
}
format(menu, 1023, "\d2x2block-Menu - Version %s\w", VERSION)
format(menu, 1023, "%s^n", menu) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
format(menu, 1023, "%L", player, "WGM_ZONE_FOUND", menu, maxzones)
if (zm != -1)
{
menukeys += MENU_KEY_2 + MENU_KEY_3 + MENU_KEY_1
format(menu, 1023, "%s^n", menu) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
format(menu, 1023, "%s^n", menu) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
format(menu, 1023, "%L", player, "WGM_ZONE_EDIT", menu)
format(menu, 1023, "%L", player, "WGM_ZONE_CHANGE", menu)
}
format(menu, 1023, "%s^n", menu) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
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) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
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: {
// Π*Π΅Π΄Π°ΠΊΡΠΎΡ Π·ΠΎΠ½Ρ
if (fm_is_valid_ent(zone[index])) OpenEditMenu(player); else Open2x2Menu(player);
}
case 2: {
// ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ°Ρ Π·ΠΎΠ½Π°
index = (index > 0) ? index - 1 : index;
Open2x2Menu(player)
}
case 3: {
// ΡΠ»Π΅Π΄ΡΡΡΠ°Ρ Π·ΠΎΠ½Π°
index = (index < maxzones - 1) ? index + 1 : index;
Open2x2Menu(player)
}
case 4: {
// ΡΠΎΠ·Π΄Π°ΡΡ Π½ΠΎΠ²ΡΡ Π·ΠΎΠ½Ρ
if (maxzones < MAXZONES - 1) {
CreateZoneOnPlayer(player);
ShowAllZones();
MainMenuAction(player, 0);
} else {
client_print(player, print_chat, "%L", player, "ZONE_FULL")
client_cmd(player, "spk sound/buttons/button10.wav")
set_task(0.5, "Open2x2Menu", player)
}
}
case 6: {
// Π£Π΄Π°Π»ΠΈΡΡ Π·ΠΎΠ½Ρ
OpenKillMenu(player);
}
case 9: {
// Π‘ΠΎΠ·ΡΠ°Π½ΠΈΡΡ Π·ΠΎΠ½Ρ
SaveBLC(player)
Open2x2Menu(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 2x2block-Zone\w")
format(menu, 1023, "%s^n", menu) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
format(menu, 1023, "%s^n", menu) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
if (fm_is_valid_ent(zone[index]))
{
pev(zone[index], ZONEID)
}
format(menu, 1023, "%s^n", menu) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
format(trans, 49, "%L", player, coordinates[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) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
format(menu, 1023, "%s^n", menu) // ΠΡΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ°
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: {
OpenEditMenu(player)
}
case 2: {
OpenEditMenu(player)
}
case 3: {
OpenEditMenu(player)
}
case 4: {
// ΠΠ°ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ (ΠΎΡΡ) ΡΠ΅Π΄Π°ΠΊΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ
direction = (direction < 2) ? direction + 1 : 0
OpenEditMenu(player)
}
case 5: {
// "Π£ΠΆΠ΅"
ZuRotAddieren()
OpenEditMenu(player)
}
case 6: {
// "Π¨ΠΈΡΠ΅"
VonRotAbziehen()
OpenEditMenu(player)
}
case 7: {
// "Π£ΠΆΠ΅"2
VonGelbAbziehen()
OpenEditMenu(player)
}
case 8: {
// "Π¨ΠΈΡΠ΅"2
ZuGelbAddieren()
OpenEditMenu(player)
}
case 9: {
// Π²Π΅Π»ΠΈΡΠΈΠ½Π° ΠΏΡΠΈΡΠΎΡΡΠ°
setupunits = (setupunits < 100) ? setupunits * 10 : 1
OpenEditMenu(player)
}
case 10:{
Open2x2Menu(player)
}
}
}
public VonRotAbziehen() {
new entity = zone[index]
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ
new Float:pos[3]
pev(entity, pev_origin, pos)
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ°Π·ΠΌΠ΅ΡΠΎΠ²
new Float:mins[3], Float:maxs[3]
pev(entity, pev_mins, mins)
pev(entity, pev_maxs, maxs)
mins[direction] -= float(setupunits) / 2.0
maxs[direction] += float(setupunits) / 2.0
pos[direction] -= float(setupunits) / 2.0
set_pev(entity, pev_origin, pos)
fm_entity_set_size(entity, mins, maxs)
}
public ZuRotAddieren() {
new entity = zone[index]
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ
new Float:pos[3]
pev(entity, pev_origin, pos)
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ°Π·ΠΌΠ΅ΡΠΎΠ²
new Float:mins[3], Float:maxs[3]
pev(entity, pev_mins, mins)
pev(entity, pev_maxs, maxs)
if ((floatabs(mins[direction]) + maxs[direction]) < setupunits + 1) return
mins[direction] += float(setupunits) / 2.0
maxs[direction] -= float(setupunits) / 2.0
pos[direction] += float(setupunits) / 2.0
set_pev(entity, pev_origin, pos)
fm_entity_set_size(entity, mins, maxs)
}
public VonGelbAbziehen() {
new entity = zone[index]
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ
new Float:pos[3]
pev(entity, pev_origin, pos)
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ°Π·ΠΌΠ΅ΡΠΎΠ²
new Float:mins[3], Float:maxs[3]
pev(entity, pev_mins, mins)
pev(entity, pev_maxs, maxs)
if ((floatabs(mins[direction]) + maxs[direction]) < setupunits + 1) return
mins[direction] += float(setupunits) / 2.0
maxs[direction] -= float(setupunits) / 2.0
pos[direction] -= float(setupunits) / 2.0
set_pev(entity, pev_origin, pos)
fm_entity_set_size(entity, mins, maxs)
}
public ZuGelbAddieren() {
new entity = zone[index]
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ
new Float:pos[3]
pev(entity, pev_origin, pos)
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ°Π·ΠΌΠ΅ΡΠΎΠ²
new Float:mins[3], Float:maxs[3]
pev(entity, pev_mins, mins)
pev(entity, pev_maxs, maxs)
mins[direction] -= float(setupunits) / 2.0
maxs[direction] += float(setupunits) / 2.0
pos[direction] += float(setupunits) / 2.0
set_pev(entity, pev_origin, pos)
fm_entity_set_size(entity, mins, maxs)
}
public OpenKillMenu(player) {
new menu[1024]
format(menu, 1023, "%L", player, "ZONE_KILL_INIT")
format(menu, 1023, "%L", player, "ZONE_KILL_ASK", menu)
show_menu(player, MENU_KEY_1 + MENU_KEY_0, menu, -1, "KillMenu")
client_cmd(player, "spk sound/buttons/button10.wav")
}
// Π€ΡΠ½ΠΊΡΠΈΡ ΡΠ΄Π°Π»Π΅Π½ΠΈΡ Π·ΠΎΠ½
public KillMenuAction(player, key) {
key = (key == 10) ? 0 : key + 1
switch(key)
{
case 1: {
client_print(player, print_chat, "[WalkGuard] %L", player, "ZONE_KILL_NO")
}
case 10:{
fm_remove_entity(zone[index])
index--;
if (index < 0) index = 0;
client_print(player, print_chat, "[WalkGuard] %L", player, "ZONE_KILL_YES")
FindAllZones()
}
}
Open2x2Menu(player)
}
stock fm_set_kvd(entity, const key[], const value[], const classname[] = "") {
if (classname[0])
set_kvd(0, KV_ClassName, classname)
else {
new class[32]
pev(entity, pev_classname, class, sizeof class - 1)
set_kvd(0, KV_ClassName, class)
}
set_kvd(0, KV_KeyName, key)
set_kvd(0, KV_Value, value)
set_kvd(0, KV_fHandled, 0)
return dllfunc(DLLFunc_KeyValue, entity, 0)
}
stock fm_fake_touch(toucher, touched)
return dllfunc(DLLFunc_Touch, toucher, touched)
stock fm_DispatchSpawn(entity)
return dllfunc(DLLFunc_Spawn, entity)
stock fm_remove_entity(index)
return engfunc(EngFunc_RemoveEntity, index)
stock fm_find_ent_by_class(index, const classname[])
return engfunc(EngFunc_FindEntityByString, index, "classname", classname)
stock fm_is_valid_ent(index)
return pev_valid(index)
stock fm_entity_set_size(index, const Float:mins[3], const Float:maxs[3])
return engfunc(EngFunc_SetSize, index, mins, maxs)
stock fm_entity_set_model(index, const model[])
return engfunc(EngFunc_SetModel, index, model)
stock fm_create_entity(const classname[])
return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname))
stock fm_entity_set_origin(index, const Float:origin[3]) {
new Float:mins[3], Float:maxs[3]
pev(index, pev_mins, mins)
pev(index, pev_maxs, maxs)
engfunc(EngFunc_SetSize, index, mins, maxs)
return engfunc(EngFunc_SetOrigin, index, origin)
}
stock fm_set_entity_visibility(index, visible = 1) {
set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)
return 1
}
stock bool:fm_is_in_viewcone(index, const Float:point[3]) {
new Float:angles[3]
pev(index, pev_angles, angles)
engfunc(EngFunc_MakeVectors, angles)
global_get(glb_v_forward, angles)
angles[2] = 0.0
new Float:origin[3], Float:diff[3], Float:norm[3]
pev(index, pev_origin, origin)
xs_vec_sub(point, origin, diff)
diff[2] = 0.0
xs_vec_normalize(diff, norm)
new Float:dot, Float:fov
dot = xs_vec_dot(norm, angles)
pev(index, pev_fov, fov)
if (dot >= floatcos(fov * M_PI / 360))
return true
return false
}
stock fm_trace_line(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
engfunc(EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent, 0)
new ent = get_tr2(0, TR_pHit)
get_tr2(0, TR_vecEndPos, ret)
return pev_valid(ent) ? ent : 0
}
|
|