HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <xs>
  5.  
  6. #define PLUGIN "WalkGuard"
  7. #define VERSION "1.3.2"
  8. #define AUTHOR "mogel"
  9.  
  10.  
  11. enum ZONEMODE {
  12. ZM_NOTHING,
  13. ZM_CAMPING,
  14. ZM_CAMPING_T1, // Terrorista
  15. ZM_CAMPING_T2, // Terror elharito
  16. ZM_BLOCK_ALL,
  17. ZM_KILL,
  18. ZM_KILL_T1,
  19. ZM_KILL_T2
  20. }
  21.  
  22. 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" }
  23. new zonename[ZONEMODE][] = { "wgz_none", "wgz_camper", "wgz_camper_t1", "wgz_camper_t2", "wgz_block_all", "wgz_kill", "wgz_kill_t1", "wgz_kill_t2" }
  24. new solidtyp[ZONEMODE] = { SOLID_NOT, SOLID_TRIGGER, SOLID_TRIGGER, SOLID_TRIGGER, SOLID_BBOX, SOLID_TRIGGER, SOLID_TRIGGER, SOLID_TRIGGER }
  25. new zonecolor[ZONEMODE][3] = {
  26. { 255, 0, 255 },
  27. { 0, 255, 0 },
  28. { 0, 255, 128 },
  29. { 128, 255, 0 },
  30. { 255, 255, 255 },
  31. { 255, 0, 0 },
  32. { 255, 0, 128 },
  33. { 255, 128, 0 }
  34. }
  35.  
  36. #define ZONEID pev_iuser1
  37. #define CAMPERTIME pev_iuser2
  38.  
  39. new zone_color_aktiv[3] = { 0, 0, 255 }
  40. new zone_color_red[3] = { 255, 0, 0 }
  41. new zone_color_green[3] = { 255, 255, 0 }
  42.  
  43.  
  44. #define MAXZONES 100
  45. new zone[MAXZONES]
  46. new maxzones
  47. new index
  48.  
  49.  
  50. new setupunits = 10
  51. new direction = 0
  52. new koordinaten[3][] = { "TRANSLATE_X_KOORD", "TRANSLATE_Y_KOORD", "TRANSLATE_Z_KOORD" }
  53.  
  54. new spr_dot
  55.  
  56. new editor = 0
  57.  
  58. new camperzone[33]
  59. new Float:campertime[33]
  60. new Float:camping[33]
  61.  
  62. #define TASK_BASIS_CAMPER 2000
  63. #define TASK_BASIS_SHOWZONES 1000
  64.  
  65. new pcv_damage
  66. new pcv_botdamage
  67. new pcv_immunity
  68. new pcv_direction
  69. new pcv_botdirection
  70. new pcv_damageicon
  71.  
  72.  
  73. new slap_direction
  74. new slap_botdirection
  75. new slap_damage
  76. new slap_botdamage
  77. new admin_immunity
  78. new icon_damage
  79.  
  80. enum ROUNDSTATUS {
  81. RS_UNDEFINED,
  82. RS_RUNNING,
  83. RS_FREEZETIME,
  84. RS_END,
  85. }
  86.  
  87. new ROUNDSTATUS:roundstatus = RS_UNDEFINED
  88.  
  89. public plugin_init() {
  90. register_plugin(PLUGIN, VERSION, AUTHOR)
  91.  
  92. register_cvar("WalkGuard", VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED)
  93. server_cmd("WalkGuard %s", VERSION)
  94.  
  95. pcv_damage = register_cvar("wg_damage", "10")
  96. pcv_botdamage = register_cvar("wg_botdamage", "0")
  97. pcv_immunity = register_cvar("wg_immunity", "0")
  98. pcv_direction = register_cvar("wg_direction", "1")
  99. pcv_botdirection = register_cvar("wg_botdirection", "1")
  100. pcv_damageicon = register_cvar("wg_damageicon", "262144")
  101.  
  102. register_menu("MainMenu", -1, "MainMenuAction", 0)
  103. register_menu("EditMenu", -1, "EditMenuAction", 0)
  104. register_menu("KillMenu", -1, "KillMenuAction", 0)
  105.  
  106.  
  107. register_clcmd("walkguardmenu", "InitWalkGuard", ADMIN_RCON, " - Megnyitja a walkguard menüt")
  108.  
  109. register_dictionary("walkguard.txt")
  110.  
  111. register_event("HLTV", "Event_FreezeTime", "a", "1=0", "2=0")
  112. register_logevent("Event_RoundStart", 2, "1=Round_Start")
  113. register_logevent("Event_RoundEnd", 2, "1=Round_End")
  114.  
  115. register_forward(FM_Touch, "fw_touch")
  116.  
  117. set_task(1.0, "LoadWGZ")
  118. }
  119.  
  120. public plugin_precache() {
  121. precache_model("models/gib_skull.mdl")
  122. spr_dot = precache_model("sprites/dot.spr")
  123. }
  124.  
  125. public client_disconnect(player) {
  126. if (player == editor) HideAllZones()
  127. }
  128.  
  129. public Event_FreezeTime() {
  130. roundstatus = RS_FREEZETIME
  131. }
  132.  
  133. public Event_RoundStart() {
  134. roundstatus = RS_RUNNING
  135.  
  136. slap_damage = get_pcvar_num(pcv_damage)
  137. slap_direction = get_pcvar_num(pcv_direction)
  138. slap_botdamage = get_pcvar_num(pcv_botdamage)
  139. slap_botdirection = get_pcvar_num(pcv_botdirection)
  140. admin_immunity = get_pcvar_num(pcv_immunity)
  141. icon_damage = get_pcvar_num(pcv_damageicon)
  142. }
  143.  
  144. public Event_RoundEnd() {
  145. roundstatus = RS_END
  146. }
  147. public fw_touch(zone, player) {
  148. if (editor) return FMRES_IGNORED
  149.  
  150. if (!pev_valid(zone) || !is_user_connected(player))
  151. return FMRES_IGNORED
  152.  
  153. static classname[33]
  154. pev(player, pev_classname, classname, 32)
  155. if (!equal(classname, "player"))
  156. return FMRES_IGNORED
  157.  
  158. pev(zone, pev_classname, classname, 32)
  159. if (!equal(classname, "walkguardzone"))
  160. return FMRES_IGNORED
  161.  
  162. if (roundstatus == RS_RUNNING)
  163. ZoneTouch(player, zone)
  164.  
  165. return FMRES_IGNORED
  166. }
  167.  
  168. public ZoneTouch(player, zone) {
  169.  
  170. new zm = pev(zone, ZONEID)
  171. new userteam = get_user_team(player)
  172.  
  173. if (admin_immunity && (get_user_flags(player) & ADMIN_IMMUNITY)) return
  174.  
  175. if ( (ZONEMODE:zm == ZM_KILL) || ((ZONEMODE:zm == ZM_KILL_T1) && (userteam == 1)) || ((ZONEMODE:zm == ZM_KILL_T2) && (userteam == 2)) )
  176. set_task(0.1, "ZoneModeKill", player)
  177.  
  178.  
  179. if ( (ZONEMODE:zm == ZM_CAMPING) || ((ZONEMODE:zm == ZM_CAMPING_T1) && (userteam == 1)) || ((ZONEMODE:zm == ZM_CAMPING_T2) && (userteam == 2)) ) {
  180. if (!camping[player]) {
  181. client_print(player, print_center, "%L", player, "WALKGUARD_CAMPING_INIT")
  182. camperzone[player] = zone
  183. campertime[player] = get_gametime()
  184. camping[player] = get_gametime()
  185. set_task(0.5, "ZoneModeCamper", TASK_BASIS_CAMPER + player, _, _, "b")
  186. } else {
  187.  
  188. camping[player] = get_gametime()
  189. }
  190. }
  191. }
  192.  
  193. public ZoneModeKill(player) {
  194. if (!is_user_connected(player) || !is_user_alive(player)) return
  195. user_silentkill(player)
  196. for(new i = 0; i < 5; i++) client_print(player, print_chat, "[WalkGuard] %L", player, "WALKGUARD_KILL_MESSAGE")
  197. client_cmd(player,"speak ambience/thunder_clap.wav")
  198. }
  199.  
  200. public ZoneModeCamper(player) {
  201. player -= TASK_BASIS_CAMPER
  202.  
  203. if (!is_user_connected(player))
  204. {
  205. remove_task(TASK_BASIS_CAMPER + player)
  206. return
  207. }
  208.  
  209. new Float:gametime = get_gametime();
  210. if ((gametime - camping[player]) > 0.5)
  211. {
  212. campertime[player] = 0.0
  213. camping[player] = 0.0
  214. remove_task(TASK_BASIS_CAMPER + player)
  215. return
  216. }
  217.  
  218. new ct = pev(camperzone[player], CAMPERTIME)
  219. new left = ct - floatround( gametime - campertime[player])
  220. if (left < 1)
  221. {
  222. client_print(player, print_center, "%L", player, "WALKGUARD_CAMPING_DAMG")
  223. if (is_user_bot(player))
  224. {
  225. if (slap_botdirection) RandomDirection(player)
  226. fm_fakedamage(player, "camping", float(slap_botdamage), 0)
  227. } else
  228. {
  229. if (slap_direction) RandomDirection(player)
  230. fm_fakedamage(player, "camping", float(slap_damage), icon_damage)
  231. }
  232. } else
  233. {
  234. client_print(player, print_center, "%L", player, "WALKGUARD_CAMPING_TIME", left)
  235. }
  236. }
  237.  
  238. public RandomDirection(player) {
  239. new Float:velocity[3]
  240. velocity[0] = random_float(-256.0, 256.0)
  241. velocity[1] = random_float(-256.0, 256.0)
  242. velocity[2] = random_float(-256.0, 256.0)
  243. set_pev(player, pev_velocity, velocity)
  244. }
  245.  
  246. public CreateZone(Float:position[3], Float:mins[3], Float:maxs[3], zm, campertime) {
  247. new entity = fm_create_entity("info_target")
  248. set_pev(entity, pev_classname, "walkguardzone")
  249. fm_entity_set_model(entity, "models/gib_skull.mdl")
  250. fm_entity_set_origin(entity, position)
  251.  
  252. set_pev(entity, pev_movetype, MOVETYPE_FLY)
  253. new id = pev(entity, ZONEID)
  254. if (editor)
  255. {
  256. set_pev(entity, pev_solid, SOLID_NOT)
  257. } else
  258. {
  259. set_pev(entity, pev_solid, solidtyp[ZONEMODE:id])
  260. }
  261.  
  262. fm_entity_set_size(entity, mins, maxs)
  263.  
  264. fm_set_entity_visibility(entity, 0)
  265.  
  266. set_pev(entity, ZONEID, zm)
  267. set_pev(entity, CAMPERTIME, campertime)
  268.  
  269.  
  270. return entity
  271. }
  272.  
  273. public CreateNewZone(Float:position[3]) {
  274. new Float:mins[3] = { -32.0, -32.0, -32.0 }
  275. new Float:maxs[3] = { 32.0, 32.0, 32.0 }
  276. return CreateZone(position, mins, maxs, 0, 10);
  277. }
  278.  
  279. public CreateZoneOnPlayer(player) {
  280. new Float:position[3]
  281. pev(player, pev_origin, position)
  282.  
  283. new entity = CreateNewZone(position)
  284. FindAllZones()
  285.  
  286. for(new i = 0; i < maxzones; i++) if (zone[i] == entity) index = i;
  287. }
  288.  
  289. public SaveWGZ(player) {
  290. new zonefile[200]
  291. new mapname[50]
  292.  
  293. get_configsdir(zonefile, 199)
  294. format(zonefile, 199, "%s/walkguard", zonefile)
  295. if (!dir_exists(zonefile)) mkdir(zonefile)
  296.  
  297. get_mapname(mapname, 49)
  298. format(zonefile, 199, "%s/%s.wgz", zonefile, mapname)
  299. delete_file(zonefile)
  300.  
  301. FindAllZones()
  302.  
  303. write_file(zonefile, "; V1 - WalkGuard Zone-File")
  304. write_file(zonefile, "; <zonename> <position (x/y/z)> <mins (x/y/z)> <maxs (x/y/z)> [<parameter>] ")
  305. write_file(zonefile, ";")
  306. write_file(zonefile, ";")
  307. write_file(zonefile, "; parameter")
  308. write_file(zonefile, ";")
  309. write_file(zonefile, "; - wgz_camper <time>")
  310. write_file(zonefile, "; - wgz_camper_t1 <time>")
  311. write_file(zonefile, "; - wgz_camper_t2 <time>")
  312. write_file(zonefile, "; - wgz_camper_t3 <time>")
  313. write_file(zonefile, "; - wgz_camper_t4 <time>")
  314. write_file(zonefile, ";")
  315. write_file(zonefile, "")
  316.  
  317. for(new i = 0; i < maxzones; i++)
  318. {
  319. new z = zone[i]
  320.  
  321. new zm = pev(z, ZONEID)
  322.  
  323. new Float:pos[3]
  324. pev(z, pev_origin, pos)
  325.  
  326. new Float:mins[3], Float:maxs[3]
  327. pev(z, pev_mins, mins)
  328. pev(z, pev_maxs, maxs)
  329.  
  330. new output[1000]
  331. format(output, 999, "%s", zonename[ZONEMODE:zm])
  332. format(output, 999, "%s %.1f %.1f %.1f", output, pos[0], pos[1], pos[2])
  333. format(output, 999, "%s %.0f %.0f %.0f", output, mins[0], mins[1], mins[2])
  334. format(output, 999, "%s %.0f %.0f %.0f", output, maxs[0], maxs[1], maxs[2])
  335.  
  336. if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
  337. {
  338. new ct = pev(z, CAMPERTIME)
  339. format(output, 999, "%s %i", output, ct)
  340. }
  341.  
  342. write_file(zonefile, output)
  343. }
  344.  
  345. client_print(player, print_chat, "%L", player, "ZONE_FILE_SAVED", zonefile)
  346. }
  347.  
  348. public LoadWGZ() {
  349. new zonefile[200]
  350. new mapname[50]
  351.  
  352.  
  353. get_configsdir(zonefile, 199)
  354. format(zonefile, 199, "%s/walkguard", zonefile)
  355.  
  356. get_mapname(mapname, 49)
  357. format(zonefile, 199, "%s/%s.wgz", zonefile, mapname)
  358.  
  359. if (!file_exists(zonefile))
  360. {
  361. log_amx("Nem letezik a zona fajl")
  362. return
  363. }
  364.  
  365.  
  366. new input[1000], line = 0, len
  367.  
  368. while( (line = read_file(zonefile , line , input , 127 , len) ) != 0 )
  369. {
  370. if (!strlen(input) || (input[0] == ';')) continue;
  371.  
  372. new data[20], zm = 0, ct
  373. new Float:mins[3], Float:maxs[3], Float:pos[3]
  374.  
  375.  
  376. strbreak(input, data, 20, input, 999)
  377. zm = -1
  378. for(new i = 0; ZONEMODE:i < ZONEMODE; ZONEMODE:i++)
  379. {
  380. if (equal(data, "wgz_camper_te")) format(data, 19, "wgz_camper_t1")
  381. if (equal(data, "wgz_camper_ct")) format(data, 19, "wgz_camper_t2")
  382. if (equal(data, zonename[ZONEMODE:i])) zm = i;
  383. }
  384.  
  385. if (zm == -1)
  386. {
  387. log_amx("Ismeretlen zona -> '%s'", data)
  388. continue;
  389. }
  390. strbreak(input, data, 20, input, 999); pos[0] = str_to_float(data);
  391. strbreak(input, data, 20, input, 999); pos[1] = str_to_float(data);
  392. strbreak(input, data, 20, input, 999); pos[2] = str_to_float(data);
  393.  
  394. strbreak(input, data, 20, input, 999); mins[0] = str_to_float(data);
  395. strbreak(input, data, 20, input, 999); mins[1] = str_to_float(data);
  396. strbreak(input, data, 20, input, 999); mins[2] = str_to_float(data);
  397. strbreak(input, data, 20, input, 999); maxs[0] = str_to_float(data);
  398. strbreak(input, data, 20, input, 999); maxs[1] = str_to_float(data);
  399. strbreak(input, data, 20, input, 999); maxs[2] = str_to_float(data);
  400.  
  401. if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
  402. {
  403.  
  404. strbreak(input, data, 20, input, 999)
  405. ct = str_to_num(data)
  406. }
  407.  
  408.  
  409. CreateZone(pos, mins, maxs, zm, ct);
  410. }
  411.  
  412. FindAllZones()
  413. HideAllZones()
  414. }
  415.  
  416. public FX_Box(Float:sizemin[3], Float:sizemax[3], color[3], life) {
  417.  
  418. message_begin(MSG_ALL, SVC_TEMPENTITY);
  419.  
  420. write_byte(31);
  421.  
  422. write_coord( floatround( sizemin[0] ) );
  423. write_coord( floatround( sizemin[1] ) );
  424. write_coord( floatround( sizemin[2] ) );
  425.  
  426. write_coord( floatround( sizemax[0] ) );
  427. write_coord( floatround( sizemax[1] ) );
  428. write_coord( floatround( sizemax[2] ) );
  429.  
  430. write_short(life)
  431.  
  432. write_byte(color[0])
  433. write_byte(color[1])
  434. write_byte(color[2])
  435.  
  436. message_end();
  437. }
  438.  
  439. public FX_Line(start[3], stop[3], color[3], brightness) {
  440. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, editor)
  441.  
  442. write_byte( TE_BEAMPOINTS )
  443.  
  444. write_coord(start[0])
  445. write_coord(start[1])
  446. write_coord(start[2])
  447.  
  448. write_coord(stop[0])
  449. write_coord(stop[1])
  450. write_coord(stop[2])
  451.  
  452. write_short( spr_dot )
  453.  
  454. write_byte( 1 )
  455. write_byte( 1 )
  456. write_byte( 4 )
  457. write_byte( 5 )
  458. write_byte( 0 )
  459.  
  460. write_byte( color[0] )
  461. write_byte( color[1] )
  462. write_byte( color[2] )
  463.  
  464. write_byte( brightness )
  465. write_byte( 0 )
  466.  
  467. message_end()
  468. }
  469.  
  470. public DrawLine(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, color[3]) {
  471. new start[3]
  472. new stop[3]
  473.  
  474. start[0] = floatround( x1 )
  475. start[1] = floatround( y1 )
  476. start[2] = floatround( z1 )
  477.  
  478. stop[0] = floatround( x2 )
  479. stop[1] = floatround( y2 )
  480. stop[2] = floatround( z2 )
  481.  
  482. FX_Line(start, stop, color, 200)
  483. }
  484.  
  485. public ShowAllZones() {
  486. FindAllZones()
  487.  
  488. for(new i = 0; i < maxzones; i++)
  489. {
  490. new z = zone[i]
  491. remove_task(TASK_BASIS_SHOWZONES + z)
  492. set_pev(z, pev_solid, SOLID_NOT)
  493. set_task(0.2, "ShowZoneBox", TASK_BASIS_SHOWZONES + z, _, _, "b")
  494. }
  495. }
  496.  
  497. public ShowZoneBox(entity) {
  498. entity -= TASK_BASIS_SHOWZONES
  499. if ((!fm_is_valid_ent(entity)) || !editor) return
  500.  
  501. new Float:pos[3]
  502. pev(entity, pev_origin, pos)
  503. if (!fm_is_in_viewcone(editor, pos) && (entity != zone[index])) return
  504.  
  505.  
  506. new Float:editorpos[3]
  507. pev(editor, pev_origin, editorpos)
  508. new Float:hitpoint[3]
  509. fm_trace_line(-1, editorpos, pos, hitpoint)
  510.  
  511. if (entity == zone[index]) DrawLine(editorpos[0], editorpos[1], editorpos[2] - 16.0, pos[0], pos[1], pos[2], { 255, 0, 0} )
  512.  
  513. new Float:dh = vector_distance(editorpos, pos) - vector_distance(editorpos, hitpoint)
  514. if ( (floatabs(dh) > 128.0) && (entity != zone[index])) return
  515.  
  516. new Float:mins[3], Float:maxs[3]
  517. pev(entity, pev_mins, mins)
  518. pev(entity, pev_maxs, maxs)
  519.  
  520. mins[0] += pos[0]
  521. mins[1] += pos[1]
  522. mins[2] += pos[2]
  523. maxs[0] += pos[0]
  524. maxs[1] += pos[1]
  525. maxs[2] += pos[2]
  526.  
  527. new id = pev(entity, ZONEID)
  528.  
  529. new color[3]
  530. color[0] = (zone[index] == entity) ? zone_color_aktiv[0] : zonecolor[ZONEMODE:id][0]
  531. color[1] = (zone[index] == entity) ? zone_color_aktiv[1] : zonecolor[ZONEMODE:id][1]
  532. color[2] = (zone[index] == entity) ? zone_color_aktiv[2] : zonecolor[ZONEMODE:id][2]
  533.  
  534. DrawLine(maxs[0], maxs[1], maxs[2], mins[0], maxs[1], maxs[2], color)
  535. DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], maxs[2], color)
  536. DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], maxs[1], mins[2], color)
  537.  
  538. DrawLine(mins[0], mins[1], mins[2], maxs[0], mins[1], mins[2], color)
  539. DrawLine(mins[0], mins[1], mins[2], mins[0], maxs[1], mins[2], color)
  540. DrawLine(mins[0], mins[1], mins[2], mins[0], mins[1], maxs[2], color)
  541.  
  542. DrawLine(mins[0], maxs[1], maxs[2], mins[0], maxs[1], mins[2], color)
  543. DrawLine(mins[0], maxs[1], mins[2], maxs[0], maxs[1], mins[2], color)
  544. DrawLine(maxs[0], maxs[1], mins[2], maxs[0], mins[1], mins[2], color)
  545. DrawLine(maxs[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], color)
  546. DrawLine(maxs[0], mins[1], maxs[2], mins[0], mins[1], maxs[2], color)
  547. DrawLine(mins[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], color)
  548.  
  549. if (entity != zone[index]) return
  550.  
  551.  
  552. if (direction == 0)
  553. {
  554. DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], mins[2], zone_color_green)
  555. DrawLine(maxs[0], maxs[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_green)
  556.  
  557. DrawLine(mins[0], maxs[1], maxs[2], mins[0], mins[1], mins[2], zone_color_red)
  558. DrawLine(mins[0], maxs[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red)
  559. }
  560. if (direction == 1)
  561. {
  562. DrawLine(mins[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_red)
  563. DrawLine(maxs[0], mins[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red)
  564.  
  565. DrawLine(mins[0], maxs[1], mins[2], maxs[0], maxs[1], maxs[2], zone_color_green)
  566. DrawLine(maxs[0], maxs[1], mins[2], mins[0], maxs[1], maxs[2], zone_color_green)
  567. }
  568. if (direction == 2)
  569. {
  570. DrawLine(maxs[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2], zone_color_green)
  571. DrawLine(maxs[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], zone_color_green)
  572.  
  573. DrawLine(maxs[0], maxs[1], mins[2], mins[0], mins[1], mins[2], zone_color_red)
  574. DrawLine(maxs[0], mins[1], mins[2], mins[0], maxs[1], mins[2], zone_color_red)
  575. }
  576. }
  577.  
  578. public HideAllZones() {
  579. editor = 0
  580. for(new i = 0; i < maxzones; i++)
  581. {
  582. new id = pev(zone[i], ZONEID)
  583. set_pev(zone[i], pev_solid, solidtyp[ZONEMODE:id])
  584. remove_task(TASK_BASIS_SHOWZONES + zone[i])
  585. }
  586. }
  587.  
  588. public FindAllZones() {
  589. new entity = -1
  590. maxzones = 0
  591. while( (entity = fm_find_ent_by_class(entity, "walkguardzone")) )
  592. {
  593. zone[maxzones] = entity
  594. maxzones++
  595. }
  596. }
  597.  
  598. public InitWalkGuard(player) {
  599. new name[33], steam[33]
  600. get_user_name(player, name, 32)
  601. get_user_authid(player, steam, 32)
  602.  
  603. if (!(get_user_flags(player) & ADMIN_RCON))
  604. {
  605. log_amx("nincs joga: '%s' <%s>", name, steam)
  606. return PLUGIN_HANDLED
  607. }
  608.  
  609. editor = player
  610. FindAllZones();
  611. ShowAllZones();
  612.  
  613. set_task(0.1, "OpenWalkGuardMenu", player)
  614.  
  615. return PLUGIN_HANDLED
  616. }
  617.  
  618. public OpenWalkGuardMenu(player) {
  619. new trans[70]
  620. new menu[1024]
  621. new zm = -1
  622. new ct
  623. new menukeys = MENU_KEY_0 + MENU_KEY_4 + MENU_KEY_9
  624.  
  625. if (fm_is_valid_ent(zone[index]))
  626. {
  627. zm = pev(zone[index], ZONEID)
  628. ct = pev(zone[index], CAMPERTIME)
  629. }
  630.  
  631. format(menu, 1023, "\dWalkGuard-Menu - Verzio %s\w", VERSION)
  632. format(menu, 1023, "%s^n", menu)
  633. format(menu, 1023, "%s^n", menu)
  634. format(menu, 1023, "%L", player, "WGM_ZONE_FOUND", menu, maxzones)
  635.  
  636. if (zm != -1)
  637. {
  638. format(trans, 69, "%L", player, zonemode[ZONEMODE:zm])
  639. if (ZONEMODE:zm == ZM_CAMPING)
  640. {
  641. format(menu, 1023, "%L", player, "WGM_ZONE_CURRENT_CAMP", menu, index + 1, trans, ct)
  642. } else
  643. {
  644. format(menu, 1023, "%L", player, "WGM_ZONE_CURRENT_NONE", menu, index + 1, trans)
  645. }
  646.  
  647. menukeys += MENU_KEY_2 + MENU_KEY_3 + MENU_KEY_1
  648. format(menu, 1023, "%s^n", menu)
  649. format(menu, 1023, "%s^n", menu)
  650. format(menu, 1023, "%L", player, "WGM_ZONE_EDIT", menu)
  651. format(menu, 1023, "%L", player, "WGM_ZONE_CHANGE", menu)
  652. }
  653.  
  654. format(menu, 1023, "%s^n", menu)
  655. format(menu, 1023, "%L" ,player, "WGM_ZONE_CREATE", menu)
  656.  
  657. if (zm != -1)
  658. {
  659. menukeys += MENU_KEY_6
  660. format(menu, 1023, "%L", player, "WGM_ZONE_DELETE", menu)
  661. }
  662. format(menu, 1023, "%L", player, "WGM_ZONE_SAVE", menu)
  663.  
  664. format(menu, 1023, "%s^n", menu)
  665. format(menu, 1023, "%L" ,player, "WGM_ZONE_EXIT", menu)
  666.  
  667. show_menu(player, menukeys, menu, -1, "MainMenu")
  668. client_cmd(player, "spk sound/buttons/blip1.wav")
  669. }
  670.  
  671. public MainMenuAction(player, key) {
  672. key = (key == 10) ? 0 : key + 1
  673. switch(key)
  674. {
  675. case 1: {
  676. if (fm_is_valid_ent(zone[index])) OpenEditMenu(player); else OpenWalkGuardMenu(player);
  677. }
  678. case 2: {
  679. index = (index > 0) ? index - 1 : index;
  680. OpenWalkGuardMenu(player)
  681. }
  682. case 3: {
  683. index = (index < maxzones - 1) ? index + 1 : index;
  684. OpenWalkGuardMenu(player)
  685. }
  686. case 4: {
  687.  
  688. if (maxzones < MAXZONES - 1)
  689. {
  690. CreateZoneOnPlayer(player);
  691. ShowAllZones();
  692. MainMenuAction(player, 0);
  693. } else
  694. {
  695. client_print(player, print_chat, "%L", player, "ZONE_FULL")
  696. client_cmd(player, "spk sound/buttons/button10.wav")
  697. set_task(0.5, "OpenWalkGuardMenu", player)
  698. }
  699. }
  700. case 6: {
  701. OpenKillMenu(player);
  702. }
  703. case 9: {
  704. SaveWGZ(player)
  705. OpenWalkGuardMenu(player)
  706. }
  707. case 10:{
  708. editor = 0
  709. HideAllZones()
  710. }
  711. }
  712. }
  713.  
  714. public OpenEditMenu(player) {
  715. new trans[70]
  716.  
  717. new menu[1024]
  718. 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
  719.  
  720. format(menu, 1023, "\dWalkGuard-Zona szerkesztes\w")
  721. format(menu, 1023, "%s^n", menu)
  722. format(menu, 1023, "%s^n", menu)
  723.  
  724. new zm = -1
  725. new ct
  726. if (fm_is_valid_ent(zone[index]))
  727. {
  728. zm = pev(zone[index], ZONEID)
  729. ct = pev(zone[index], CAMPERTIME)
  730. }
  731.  
  732. if (zm != -1)
  733. {
  734. format(trans, 69, "%L", player, zonemode[ZONEMODE:zm])
  735. if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
  736. {
  737. format(menu, 1023, "%L", player, "WGE_ZONE_CURRENT_CAMP", menu, trans, ct)
  738. format(menu, 1023, "%L", player, "WGE_ZONE_CURRENT_CHANGE", menu)
  739. menukeys += MENU_KEY_2 + MENU_KEY_3
  740. } else
  741. {
  742. format(menu, 1023, "%L", player, "WGE_ZONE_CURRENT_NONE", menu, trans)
  743. format(menu, 1023, "%s^n", menu)
  744. }
  745. }
  746.  
  747. format(menu, 1023, "%s^n", menu)
  748.  
  749. format(trans, 49, "%L", player, koordinaten[direction])
  750. format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_INIT", menu, trans)
  751. format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_MINS", menu)
  752. format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_MAXS", menu)
  753. format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_STEP", menu, setupunits)
  754. format(menu, 1023, "%s^n", menu)
  755. format(menu, 1023, "%s^n", menu)
  756. format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_QUIT", menu)
  757.  
  758. show_menu(player, menukeys, menu, -1, "EditMenu")
  759. client_cmd(player, "spk sound/buttons/blip1.wav")
  760. }
  761.  
  762. public EditMenuAction(player, key) {
  763. key = (key == 10) ? 0 : key + 1
  764. switch(key)
  765. {
  766. case 1: {
  767. new zm = -1
  768. zm = pev(zone[index], ZONEID)
  769. if (ZONEMODE:zm == ZM_KILL_T2) zm = 0; else zm++;
  770. set_pev(zone[index], ZONEID, zm)
  771. OpenEditMenu(player)
  772. }
  773. case 2: {
  774. new ct = pev(zone[index], CAMPERTIME)
  775. ct = (ct > 5) ? ct - 1 : 5
  776. set_pev(zone[index], CAMPERTIME, ct)
  777. OpenEditMenu(player)
  778. }
  779. case 3: {
  780. new ct = pev(zone[index], CAMPERTIME)
  781. ct = (ct < 30) ? ct + 1 : 30
  782. set_pev(zone[index], CAMPERTIME, ct)
  783. OpenEditMenu(player)
  784. }
  785. case 4: {
  786. direction = (direction < 2) ? direction + 1 : 0
  787. OpenEditMenu(player)
  788. }
  789. case 5: {
  790. ZuRotAddieren()
  791. OpenEditMenu(player)
  792. }
  793. case 6: {
  794. VonRotAbziehen()
  795. OpenEditMenu(player)
  796. }
  797. case 7: {
  798. VonGelbAbziehen()
  799. OpenEditMenu(player)
  800. }
  801. case 8: {
  802. ZuGelbAddieren()
  803. OpenEditMenu(player)
  804. }
  805. case 9: {
  806. setupunits = (setupunits < 100) ? setupunits * 10 : 1
  807. OpenEditMenu(player)
  808. }
  809. case 10:{
  810. OpenWalkGuardMenu(player)
  811. }
  812. }
  813. }
  814.  
  815. public VonRotAbziehen() {
  816. new entity = zone[index]
  817.  
  818. new Float:pos[3]
  819. pev(entity, pev_origin, pos)
  820.  
  821. new Float:mins[3], Float:maxs[3]
  822. pev(entity, pev_mins, mins)
  823. pev(entity, pev_maxs, maxs)
  824.  
  825.  
  826. mins[direction] -= float(setupunits) / 2.0
  827. maxs[direction] += float(setupunits) / 2.0
  828. pos[direction] -= float(setupunits) / 2.0
  829.  
  830. set_pev(entity, pev_origin, pos)
  831. fm_entity_set_size(entity, mins, maxs)
  832. }
  833.  
  834. public ZuRotAddieren() {
  835. new entity = zone[index]
  836.  
  837. new Float:pos[3]
  838. pev(entity, pev_origin, pos)
  839.  
  840. new Float:mins[3], Float:maxs[3]
  841. pev(entity, pev_mins, mins)
  842. pev(entity, pev_maxs, maxs)
  843.  
  844. if ((floatabs(mins[direction]) + maxs[direction]) < setupunits + 1) return
  845.  
  846. mins[direction] += float(setupunits) / 2.0
  847. maxs[direction] -= float(setupunits) / 2.0
  848. pos[direction] += float(setupunits) / 2.0
  849.  
  850. set_pev(entity, pev_origin, pos)
  851. fm_entity_set_size(entity, mins, maxs)
  852. }
  853.  
  854. public VonGelbAbziehen() {
  855. new entity = zone[index]
  856.  
  857. new Float:pos[3]
  858. pev(entity, pev_origin, pos)
  859.  
  860. new Float:mins[3], Float:maxs[3]
  861. pev(entity, pev_mins, mins)
  862. pev(entity, pev_maxs, maxs)
  863.  
  864. if ((floatabs(mins[direction]) + maxs[direction]) < setupunits + 1) return
  865.  
  866. mins[direction] += float(setupunits) / 2.0
  867. maxs[direction] -= float(setupunits) / 2.0
  868. pos[direction] -= float(setupunits) / 2.0
  869.  
  870. set_pev(entity, pev_origin, pos)
  871. fm_entity_set_size(entity, mins, maxs)
  872. }
  873.  
  874. public ZuGelbAddieren() {
  875. new entity = zone[index]
  876.  
  877. new Float:pos[3]
  878. pev(entity, pev_origin, pos)
  879.  
  880. new Float:mins[3], Float:maxs[3]
  881. pev(entity, pev_mins, mins)
  882. pev(entity, pev_maxs, maxs)
  883.  
  884.  
  885. mins[direction] -= float(setupunits) / 2.0
  886. maxs[direction] += float(setupunits) / 2.0
  887. pos[direction] += float(setupunits) / 2.0
  888.  
  889. set_pev(entity, pev_origin, pos)
  890. fm_entity_set_size(entity, mins, maxs)
  891. }
  892.  
  893. public OpenKillMenu(player) {
  894. new menu[1024]
  895.  
  896. format(menu, 1023, "%L", player, "ZONE_KILL_INIT")
  897. format(menu, 1023, "%L", player, "ZONE_KILL_ASK", menu)
  898.  
  899. show_menu(player, MENU_KEY_1 + MENU_KEY_0, menu, -1, "KillMenu")
  900.  
  901. client_cmd(player, "spk sound/buttons/button10.wav")
  902. }
  903.  
  904. public KillMenuAction(player, key) {
  905. key = (key == 10) ? 0 : key + 1
  906. switch(key)
  907. {
  908. case 1: {
  909. client_print(player, print_chat, "[WalkGuard] %L", player, "ZONE_KILL_NO")
  910. }
  911. case 10:{
  912. fm_remove_entity(zone[index])
  913. index--;
  914. if (index < 0) index = 0;
  915. client_print(player, print_chat, "[WalkGuard] %L", player, "ZONE_KILL_YES")
  916. FindAllZones()
  917. }
  918. }
  919. OpenWalkGuardMenu(player)
  920. }
  921.  
  922. stock fm_set_kvd(entity, const key[], const value[], const classname[] = "") {
  923. if (classname[0])
  924. set_kvd(0, KV_ClassName, classname)
  925. else {
  926. new class[32]
  927. pev(entity, pev_classname, class, sizeof class - 1)
  928. set_kvd(0, KV_ClassName, class)
  929. }
  930.  
  931. set_kvd(0, KV_KeyName, key)
  932. set_kvd(0, KV_Value, value)
  933. set_kvd(0, KV_fHandled, 0)
  934.  
  935. return dllfunc(DLLFunc_KeyValue, entity, 0)
  936. }
  937.  
  938. stock fm_fake_touch(toucher, touched)
  939. return dllfunc(DLLFunc_Touch, toucher, touched)
  940.  
  941. stock fm_DispatchSpawn(entity)
  942. return dllfunc(DLLFunc_Spawn, entity)
  943.  
  944. stock fm_remove_entity(index)
  945. return engfunc(EngFunc_RemoveEntity, index)
  946.  
  947. stock fm_find_ent_by_class(index, const classname[])
  948. return engfunc(EngFunc_FindEntityByString, index, "classname", classname)
  949.  
  950. stock fm_is_valid_ent(index)
  951. return pev_valid(index)
  952.  
  953. stock fm_entity_set_size(index, const Float:mins[3], const Float:maxs[3])
  954. return engfunc(EngFunc_SetSize, index, mins, maxs)
  955.  
  956. stock fm_entity_set_model(index, const model[])
  957. return engfunc(EngFunc_SetModel, index, model)
  958.  
  959. stock fm_create_entity(const classname[])
  960. return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname))
  961.  
  962. stock fm_fakedamage(victim, const classname[], Float:takedmgdamage, damagetype) {
  963. new class[] = "trigger_hurt"
  964. new entity = fm_create_entity(class)
  965. if (!entity)
  966. return 0
  967.  
  968. new value[16]
  969. float_to_str(takedmgdamage * 2, value, sizeof value - 1)
  970. fm_set_kvd(entity, "dmg", value, class)
  971.  
  972. num_to_str(damagetype, value, sizeof value - 1)
  973. fm_set_kvd(entity, "damagetype", value, class)
  974.  
  975. fm_set_kvd(entity, "origin", "8192 8192 8192", class)
  976. fm_DispatchSpawn(entity)
  977.  
  978. set_pev(entity, pev_classname, classname)
  979. fm_fake_touch(entity, victim)
  980. fm_remove_entity(entity)
  981.  
  982. return 1
  983. }
  984.  
  985. stock fm_entity_set_origin(index, const Float:origin[3]) {
  986. new Float:mins[3], Float:maxs[3]
  987. pev(index, pev_mins, mins)
  988. pev(index, pev_maxs, maxs)
  989. engfunc(EngFunc_SetSize, index, mins, maxs)
  990.  
  991. return engfunc(EngFunc_SetOrigin, index, origin)
  992. }
  993.  
  994. stock fm_set_entity_visibility(index, visible = 1) {
  995. set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)
  996.  
  997. return 1
  998. }
  999.  
  1000. stock bool:fm_is_in_viewcone(index, const Float:point[3]) {
  1001. new Float:angles[3]
  1002. pev(index, pev_angles, angles)
  1003. engfunc(EngFunc_MakeVectors, angles)
  1004. global_get(glb_v_forward, angles)
  1005. angles[2] = 0.0
  1006.  
  1007. new Float:origin[3], Float:diff[3], Float:norm[3]
  1008. pev(index, pev_origin, origin)
  1009. xs_vec_sub(point, origin, diff)
  1010. diff[2] = 0.0
  1011. xs_vec_normalize(diff, norm)
  1012.  
  1013. new Float:dot, Float:fov
  1014. dot = xs_vec_dot(norm, angles)
  1015. pev(index, pev_fov, fov)
  1016. if (dot >= floatcos(fov * M_PI / 360))
  1017. return true
  1018.  
  1019. return false
  1020. }
  1021.  
  1022. stock fm_trace_line(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
  1023. engfunc(EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent, 0)
  1024.  
  1025. new ent = get_tr2(0, TR_pHit)
  1026. get_tr2(0, TR_vecEndPos, ret)
  1027.  
  1028. return pev_valid(ent) ? ent : 0
  1029. }