搜索
查看: 2809|回复: 6

插件1.5下不能读取配置的参数

[复制链接]
发表于 2009-1-7 00:50:31 | 显示全部楼层 |阅读模式 来自 浙江温州
是个限制区域的插件但是没解决1.5下保存后重新换图读取原来配置,高手帮看下那段代码出了问题,现在下附件要收费我就把代码拆分成几段。
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <xs>

  5. #define PLUGIN "WalkGuard"
  6. #define VERSION "1.3.2"
  7. #define AUTHOR "mogel"

  8. /*
  9. *        fakemeta-version by djmd378
  10. */

  11. enum ZONEMODE {
  12.         ZM_NOTHING,
  13.         ZM_CAMPING,
  14.         ZM_CAMPING_T1,        // Team 1 -> e.g. Terrorist
  15.         ZM_CAMPING_T2,        // Team 2 -> e.g. Counter-Terroris
  16.         ZM_BLOCK_ALL,
  17.         ZM_KILL,
  18.         ZM_KILL_T1,        // DoD-Unterst黷zung
  19.         ZM_KILL_T2
  20. }

  21. 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" }
  22. new zonename[ZONEMODE][] = { "wgz_none", "wgz_camper", "wgz_camper_t1", "wgz_camper_t2", "wgz_block_all", "wgz_kill", "wgz_kill_t1", "wgz_kill_t2" }
  23. new solidtyp[ZONEMODE] = { SOLID_NOT, SOLID_TRIGGER, SOLID_TRIGGER, SOLID_TRIGGER, SOLID_BBOX, SOLID_TRIGGER, SOLID_TRIGGER, SOLID_TRIGGER }
  24. new zonecolor[ZONEMODE][3] = {
  25.         { 255, 0, 255 },                // nichts
  26.         { 0, 255, 0 },                // Camperzone
  27.         { 0, 255, 128 },                // Camperzone T1
  28.         { 128, 255, 0 },                // Camperzone T2
  29.         { 255, 255, 255 },        // alle Blockieren
  30.         { 255, 0, 0 },        // Kill
  31.         { 255, 0, 128 },        // Kill - T1
  32.         { 255, 128, 0 }        // Kill - T2
  33. }

  34. #define ZONEID pev_iuser1
  35. #define CAMPERTIME pev_iuser2

  36. new zone_color_aktiv[3] = { 0, 0, 255 }
  37. new zone_color_red[3] = { 255, 0, 0 }
  38. new zone_color_green[3] = { 255, 255, 0 }

  39. // alle Zonen
  40. #define MAXZONES 100
  41. new zone[MAXZONES]
  42. new maxzones                // soviele existieren
  43. new index                // die aktuelle Zone

  44. // Editier-Funktionen
  45. new setupunits = 10        // 膎derungen an der Gr鲞e um diese Einheiten
  46. new direction = 0        // 0 -> X-Koorinaten / 1 -> Y-Koords / 2 -> Z-Koords
  47. new koordinaten[3][] = { "TRANSLATE_X_KOORD", "TRANSLATE_Y_KOORD", "TRANSLATE_Z_KOORD" }

  48. new spr_dot                // ben鰐igt f黵 die Lininen

  49. new editor = 0                // dieser Spieler ist gerade am erstellen .. Men?verkraftet nur einen Editor

  50. new camperzone[33]                // letzte Meldung der CamperZone
  51. new Float:campertime[33]        // der erste Zeitpunkt des eintreffens in die Zone
  52. new Float:camping[33]                // der letzte Zeitpunkt des campens

  53. #define TASK_BASIS_CAMPER 2000
  54. #define TASK_BASIS_SHOWZONES 1000

  55. new pcv_damage
  56. new pcv_botdamage
  57. new pcv_immunity
  58. new pcv_direction
  59. new pcv_botdirection
  60. new pcv_damageicon

  61. // less CPU
  62. new slap_direction
  63. new slap_botdirection
  64. new slap_damage
  65. new slap_botdamage
  66. new admin_immunity
  67. new icon_damage                // Damage-Icon

  68. enum ROUNDSTATUS {
  69.         RS_UNDEFINED,
  70.         RS_RUNNING,
  71.         RS_FREEZETIME,
  72.         RS_END,
  73. }

  74. new ROUNDSTATUS:roundstatus = RS_UNDEFINED

  75. public plugin_init() {
  76.         register_plugin(PLUGIN, VERSION, AUTHOR)

  77.         register_cvar("WalkGuard", VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED)
  78.         server_cmd("WalkGuard %s", VERSION)

  79.         pcv_damage = register_cvar("wg_damage", "10")
  80.         pcv_botdamage = register_cvar("wg_botdamage", "0")        // Bot's sind einfach nur dumm ... und k鰊nen nicht lesen
  81.         pcv_immunity = register_cvar("wg_immunity", "0")                // Admins mit Immunit鋞 brauchen nicht
  82.         pcv_direction = register_cvar("wg_direction", "1")        // zuf鋖lige Richtung beim Slap
  83.         pcv_botdirection = register_cvar("wg_botdirection", "1") // dito f黵 Bots
  84.         pcv_damageicon = register_cvar("wg_damageicon", "262144") // eigentlich ein Pfeil

  85.         register_menu("MainMenu", -1, "MainMenuAction", 0)
  86.         register_menu("EditMenu", -1, "EditMenuAction", 0)
  87.         register_menu("KillMenu", -1, "KillMenuAction", 0)

  88.         // Menu
  89.         register_clcmd("walkguardmenu", "InitWalkGuard", ADMIN_RCON, " - open the WalkGuard-Menu")

  90.         // Sprache
  91.         register_dictionary("walkguard.txt")

  92.         // Einstelleungen der Variablen laden
  93.         register_event("HLTV", "Event_FreezeTime", "a", "1=0", "2=0")
  94.         register_logevent("Event_RoundStart", 2, "1=Round_Start")
  95.         register_logevent("Event_RoundEnd", 2, "1=Round_End")

  96.         register_forward(FM_Touch, "fw_touch")

  97.         // Zonen nachladen
  98.         set_task(1.0, "LoadWGZ")
  99. }

  100. public plugin_precache() {
  101.         precache_model("models/gib_skull.mdl")
  102.         spr_dot = precache_model("sprites/dot.spr")
  103. }

  104. public client_disconnect(player) {
  105.         // aus irgend welchen Gr黱den ist der Spieler einfach wech........
  106.         if (player == editor) HideAllZones()
  107. }

  108. public Event_FreezeTime() {
  109.         roundstatus = RS_FREEZETIME
  110. }

  111. public Event_RoundStart() {
  112.         roundstatus = RS_RUNNING
  113.        
  114.         // CPU schonen und die Variablen am Anfang gleich merken
  115.         slap_damage = get_pcvar_num(pcv_damage)
  116.         slap_direction = get_pcvar_num(pcv_direction)
  117.         slap_botdamage = get_pcvar_num(pcv_botdamage)
  118.         slap_botdirection = get_pcvar_num(pcv_botdirection)
  119.         admin_immunity = get_pcvar_num(pcv_immunity)
  120.         icon_damage = get_pcvar_num(pcv_damageicon)
  121. }

  122. public Event_RoundEnd() {
  123.         roundstatus = RS_END
  124. }

  125. // -----------------------------------------------------------------------------------------
  126. //
  127. //        WalkGuard-Action
  128. //
  129. //                -> hier ist alles was passiert
  130. //
  131. // -----------------------------------------------------------------------------------------
  132. public fw_touch(zone, player) {
  133.         if (editor) return FMRES_IGNORED

  134.         if (!pev_valid(zone) || !is_user_connected(player))
  135.                 return FMRES_IGNORED

  136.         static classname[33]
  137.         pev(player, pev_classname, classname, 32)
  138.         if (!equal(classname, "player"))
  139.                 return FMRES_IGNORED
  140.        
  141.         pev(zone, pev_classname, classname, 32)
  142.         if (!equal(classname, "walkguardzone"))
  143.                 return FMRES_IGNORED
  144.        
  145.         if (roundstatus == RS_RUNNING)
  146.                 ZoneTouch(player, zone)
  147.        
  148.         return FMRES_IGNORED
  149. }

  150. public ZoneTouch(player, zone) {

  151.         new zm = pev(zone, ZONEID)
  152.         new userteam = get_user_team(player)
  153.        
  154.         // Admin mit Immunity brauchen nicht
  155.         if (admin_immunity && (get_user_flags(player) & ADMIN_IMMUNITY)) return
  156.        
  157.         // Kill Bill
  158.         if ( (ZONEMODE:zm == ZM_KILL) || ((ZONEMODE:zm == ZM_KILL_T1) && (userteam == 1)) || ((ZONEMODE:zm == ZM_KILL_T2) && (userteam == 2)) )
  159.                 set_task(0.1, "ZoneModeKill", player)
  160.        
  161.         // Camping
  162.         if ( (ZONEMODE:zm == ZM_CAMPING) || ((ZONEMODE:zm == ZM_CAMPING_T1) && (userteam == 1)) || ((ZONEMODE:zm == ZM_CAMPING_T2) && (userteam == 2)) ) {
  163.                 if (!camping[player]) {
  164.                         client_print(player, print_center, "%L", player, "WALKGUARD_CAMPING_INIT")
  165.                         // Gratulation ... Du wirst beobachtet
  166.                         camperzone[player] = zone
  167.                         campertime[player] = get_gametime()
  168.                         camping[player] = get_gametime()
  169.                         set_task(0.5, "ZoneModeCamper", TASK_BASIS_CAMPER + player, _, _, "b")
  170.                 } else {
  171.                         // immer fleissig mitz鋒len
  172.                         camping[player] = get_gametime()
  173.                 }
  174.         }
  175. }

  176. public ZoneModeKill(player) {
  177.         if (!is_user_connected(player) || !is_user_alive(player)) return
  178.         user_silentkill(player)
  179.         for(new i = 0; i < 5; i++) client_print(player, print_chat, "[WalkGuard] %L", player, "WALKGUARD_KILL_MESSAGE")
  180.         client_cmd(player,"speak ambience/thunder_clap.wav")
  181. }

  182. public ZoneModeCamper(player) {
  183.         player -= TASK_BASIS_CAMPER

  184.         if (!is_user_connected(player))
  185.         {
  186.                 // so ein Feigling ... hat sich einfach verdr點kt ^^
  187.                 remove_task(TASK_BASIS_CAMPER + player)
  188.                 return
  189.         }
  190.        
  191.         new Float:gametime = get_gametime();
  192.         if ((gametime - camping[player]) > 0.5)
  193.         {
  194.                 // *juhu* ... wieder frei
  195.                 campertime[player] = 0.0
  196.                 camping[player] = 0.0
  197.                 remove_task(TASK_BASIS_CAMPER + player)
  198.                 return
  199.         }

  200.         new ct = pev(camperzone[player], CAMPERTIME)
  201.         new left = ct - floatround( gametime - campertime[player])
  202.         if (left < 1)
  203.         {
  204.                 client_print(player, print_center, "%L", player, "WALKGUARD_CAMPING_DAMG")
  205.                 if (is_user_bot(player))
  206.                 {
  207.                         if (slap_botdirection) RandomDirection(player)
  208.                         fm_fakedamage(player, "camping", float(slap_botdamage), 0)
  209.                 } else
  210.                 {
  211.                         if (slap_direction) RandomDirection(player)
  212.                         fm_fakedamage(player, "camping", float(slap_damage), icon_damage)
  213.                 }
  214.         } else
  215.         {
  216.                 client_print(player, print_center, "%L", player, "WALKGUARD_CAMPING_TIME", left)
  217.         }
  218. }

  219. public RandomDirection(player) {
  220.         new Float:velocity[3]
  221.         velocity[0] = random_float(-256.0, 256.0)
  222.         velocity[1] = random_float(-256.0, 256.0)
  223.         velocity[2] = random_float(-256.0, 256.0)
  224.         set_pev(player, pev_velocity, velocity)
  225. }

  226. // -----------------------------------------------------------------------------------------
  227. //
  228. //        Zonenerstellung
  229. //
  230. // -----------------------------------------------------------------------------------------
  231. public CreateZone(Float:position[3], Float:mins[3], Float:maxs[3], zm, campertime) {
  232.         new entity = fm_create_entity("info_target")
  233.         set_pev(entity, pev_classname, "walkguardzone")
  234.         fm_entity_set_model(entity, "models/gib_skull.mdl")
  235.         fm_entity_set_origin(entity, position)

  236.         set_pev(entity, pev_movetype, MOVETYPE_FLY)
  237.         new id = pev(entity, ZONEID)
  238.         if (editor)
  239.         {
  240.                 set_pev(entity, pev_solid, SOLID_NOT)
  241.         } else
  242.         {
  243.                 set_pev(entity, pev_solid, solidtyp[ZONEMODE:id])
  244.         }
  245.        
  246.         fm_entity_set_size(entity, mins, maxs)
  247.        
  248.         fm_set_entity_visibility(entity, 0)
  249.        
  250.         set_pev(entity, ZONEID, zm)
  251.         set_pev(entity, CAMPERTIME, campertime)
  252.        
  253.         //log_amx("create zone '%s' with campertime %i seconds", zonename[ZONEMODE:zm], campertime)
  254.        
  255.         return entity
  256. }

  257. public CreateNewZone(Float:position[3]) {
  258.         new Float:mins[3] = { -32.0, -32.0, -32.0 }
  259.         new Float:maxs[3] = { 32.0, 32.0, 32.0 }
  260.         return CreateZone(position, mins, maxs, 0, 10);        // ZM_NONE
  261. }

  262. public CreateZoneOnPlayer(player) {
  263.         // Position und erzeugen
  264.         new Float:position[3]
  265.         pev(player, pev_origin, position)
  266.        
  267.         new entity = CreateNewZone(position)
  268.         FindAllZones()
  269.        
  270.         for(new i = 0; i < maxzones; i++) if (zone[i] == entity) index = i;
  271. }
复制代码
 楼主| 发表于 2009-1-7 00:52:39 | 显示全部楼层 来自 浙江温州
  1. // -----------------------------------------------------------------------------------------
  2. //
  3. //        Load & Save der WGZ
  4. //
  5. // -----------------------------------------------------------------------------------------
  6. public SaveWGZ(player) {
  7.         new zonefile[200]
  8.         new mapname[50]

  9.         // Verzeichnis holen
  10.         get_configsdir(zonefile, 199)
  11.         format(zonefile, 199, "%s/walkguard", zonefile)
  12.         if (!dir_exists(zonefile)) mkdir(zonefile)
  13.        
  14.         // Namen 黚er Map erstellen
  15.         get_mapname(mapname, 49)
  16.         format(zonefile, 199, "%s/%s.wgz", zonefile, mapname)
  17.         delete_file(zonefile)        // pauschal
  18.        
  19.         FindAllZones()        // zur Sicherheit
  20.        
  21.         // Header
  22.         write_file(zonefile, "; V1 - WalkGuard Zone-File")
  23.         write_file(zonefile, "; <zonename> <position (x/y/z)> <mins (x/y/z)> <maxs (x/y/z)> [<parameter>] ")
  24.         write_file(zonefile, ";")
  25.         write_file(zonefile, ";")
  26.         write_file(zonefile, "; parameter")
  27.         write_file(zonefile, ";")
  28.         write_file(zonefile, ";   - wgz_camper    <time>")
  29.         write_file(zonefile, ";   - wgz_camper_t1 <time>")
  30.         write_file(zonefile, ";   - wgz_camper_t2 <time>")
  31.         write_file(zonefile, ";   - wgz_camper_t3 <time>")
  32.         write_file(zonefile, ";   - wgz_camper_t4 <time>")
  33.         write_file(zonefile, ";")
  34.         write_file(zonefile, "")
  35.        
  36.         // alle Zonen speichern
  37.         for(new i = 0; i < maxzones; i++)
  38.         {
  39.                 new z = zone[i]        // das Entity
  40.                
  41.                 // diverse Daten der Zone
  42.                 new zm = pev(z, ZONEID)
  43.                
  44.                 // Koordinaten holen
  45.                 new Float:pos[3]
  46.                 pev(z, pev_origin, pos)
  47.                
  48.                 // Dimensionen holen
  49.                 new Float:mins[3], Float:maxs[3]
  50.                 pev(z, pev_mins, mins)
  51.                 pev(z, pev_maxs, maxs)
  52.                
  53.                 // Ausgabe formatieren
  54.                 //  -> Type und CamperTime
  55.                 new output[1000]
  56.                 format(output, 999, "%s", zonename[ZONEMODE:zm])
  57.                 //  -> Position
  58.                 format(output, 999, "%s %.1f %.1f %.1f", output, pos[0], pos[1], pos[2])
  59.                 //  -> Dimensionen
  60.                 format(output, 999, "%s %.0f %.0f %.0f", output, mins[0], mins[1], mins[2])
  61.                 format(output, 999, "%s %.0f %.0f %.0f", output, maxs[0], maxs[1], maxs[2])
  62.                
  63.                 // diverse Parameter
  64.                 if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
  65.                 {
  66.                         new ct = pev(z, CAMPERTIME)
  67.                         format(output, 999, "%s %i", output, ct)
  68.                 }
  69.                
  70.                 // und schreiben
  71.                 write_file(zonefile, output)
  72.         }
  73.        
  74.         client_print(player, print_chat, "%L", player, "ZONE_FILE_SAVED", zonefile)
  75. }

  76. public LoadWGZ() {
  77.         new zonefile[200]
  78.         new mapname[50]

  79.         // Verzeichnis holen
  80.         get_configsdir(zonefile, 199)
  81.         format(zonefile, 199, "%s/walkguard", zonefile)
  82.        
  83.         // Namen 黚er Map erstellen
  84.         get_mapname(mapname, 49)
  85.         format(zonefile, 199, "%s/walkguard/%s.wgz", zonefile, mapname)
  86.        
  87.         if (!file_exists(zonefile))
  88.         {
  89.                 log_amx("no zone-file found")
  90.                 return
  91.         }
  92.        
  93.         // einlesen der Daten
  94.         new input[1000], line = 0, len
  95.        
  96.         while( (line = read_file(zonefile , line , input , 127 , len) ) != 0 )
  97.         {
  98.                 if (!strlen(input)  || (input[0] == ';')) continue;        // Kommentar oder Leerzeile

  99.                 new data[20], zm = 0, ct                // "abgebrochenen" Daten - ZoneMode - CamperTime
  100.                 new Float:mins[3], Float:maxs[3], Float:pos[3]        // Gr鲞e & Position

  101.                 // Zone abrufen
  102.                 strbreak(input, data, 20, input, 999)
  103.                 zm = -1
  104.                 for(new i = 0; ZONEMODE:i < ZONEMODE; ZONEMODE:i++)
  105.                 {
  106.                         // 膎derungen von CS:CZ zu allen Mods
  107.                         if (equal(data, "wgz_camper_te")) format(data, 19, "wgz_camper_t1")
  108.                         if (equal(data, "wgz_camper_ct")) format(data, 19, "wgz_camper_t2")
  109.                         if (equal(data, zonename[ZONEMODE:i])) zm = i;
  110.                 }
  111.                
  112.                 if (zm == -1)
  113.                 {
  114.                         log_amx("undefined zone -> '%s' ... dropped", data)
  115.                         continue;
  116.                 }
  117.                
  118.                 // Position holen
  119.                 strbreak(input, data, 20, input, 999);        pos[0] = str_to_float(data);
  120.                 strbreak(input, data, 20, input, 999);        pos[1] = str_to_float(data);
  121.                 strbreak(input, data, 20, input, 999);        pos[2] = str_to_float(data);
  122.                
  123.                 // Dimensionen
  124.                 strbreak(input, data, 20, input, 999);        mins[0] = str_to_float(data);
  125.                 strbreak(input, data, 20, input, 999);        mins[1] = str_to_float(data);
  126.                 strbreak(input, data, 20, input, 999);        mins[2] = str_to_float(data);
  127.                 strbreak(input, data, 20, input, 999);        maxs[0] = str_to_float(data);
  128.                 strbreak(input, data, 20, input, 999);        maxs[1] = str_to_float(data);
  129.                 strbreak(input, data, 20, input, 999);        maxs[2] = str_to_float(data);

  130.                 if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
  131.                 {
  132.                         // Campertime wird immer mitgeliefert
  133.                         strbreak(input, data, 20, input, 999)
  134.                         ct = str_to_num(data)
  135.                 }

  136.                 // und nun noch erstellen
  137.                 CreateZone(pos, mins, maxs, zm, ct);
  138.         }
  139.        
  140.         FindAllZones()
  141.         HideAllZones()
  142. }

  143. // -----------------------------------------------------------------------------------------
  144. //
  145. //        WalkGuard-Menu
  146. //
  147. // -----------------------------------------------------------------------------------------
  148. public FX_Box(Float:sizemin[3], Float:sizemax[3], color[3], life) {
  149.         // FX
  150.         message_begin(MSG_ALL, SVC_TEMPENTITY);

  151.         write_byte(31);
  152.        
  153.         write_coord( floatround( sizemin[0] ) ); // x
  154.         write_coord( floatround( sizemin[1] ) ); // y
  155.         write_coord( floatround( sizemin[2] ) ); // z
  156.        
  157.         write_coord( floatround( sizemax[0] ) ); // x
  158.         write_coord( floatround( sizemax[1] ) ); // y
  159.         write_coord( floatround( sizemax[2] ) ); // z

  160.         write_short(life)        // Life
  161.        
  162.         write_byte(color[0])        // Color R / G / B
  163.         write_byte(color[1])
  164.         write_byte(color[2])
  165.        
  166.         message_end();
  167. }

  168. public FX_Line(start[3], stop[3], color[3], brightness) {
  169.         message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, editor)
  170.        
  171.         write_byte( TE_BEAMPOINTS )
  172.        
  173.         write_coord(start[0])
  174.         write_coord(start[1])
  175.         write_coord(start[2])
  176.        
  177.         write_coord(stop[0])
  178.         write_coord(stop[1])
  179.         write_coord(stop[2])
  180.        
  181.         write_short( spr_dot )
  182.        
  183.         write_byte( 1 )        // framestart
  184.         write_byte( 1 )        // framerate
  185.         write_byte( 4 )        // life in 0.1's
  186.         write_byte( 5 )        // width
  187.         write_byte( 0 )         // noise
  188.        
  189.         write_byte( color[0] )   // r, g, b
  190.         write_byte( color[1] )   // r, g, b
  191.         write_byte( color[2] )   // r, g, b
  192.        
  193.         write_byte( brightness )          // brightness
  194.         write_byte( 0 )           // speed
  195.        
  196.         message_end()
  197. }

  198. public DrawLine(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, color[3]) {
  199.         new start[3]
  200.         new stop[3]
  201.        
  202.         start[0] = floatround( x1 )
  203.         start[1] = floatround( y1 )
  204.         start[2] = floatround( z1 )
  205.        
  206.         stop[0] = floatround( x2 )
  207.         stop[1] = floatround( y2 )
  208.         stop[2] = floatround( z2 )

  209.         FX_Line(start, stop, color, 200)
  210. }

  211. public ShowAllZones() {
  212.         FindAllZones()        // zur Sicherheit alle suchen
  213.        
  214.         for(new i = 0; i < maxzones; i++)
  215.         {
  216.                 new z = zone[i]
  217.                 remove_task(TASK_BASIS_SHOWZONES + z)
  218.                 set_pev(z, pev_solid, SOLID_NOT)
  219.                 set_task(0.2, "ShowZoneBox", TASK_BASIS_SHOWZONES + z, _, _, "b")
  220.         }
  221. }
复制代码
回复

使用道具 举报

 楼主| 发表于 2009-1-7 00:53:08 | 显示全部楼层 来自 浙江温州
  1. public ShowZoneBox(entity) {
  2.         entity -= TASK_BASIS_SHOWZONES
  3.         if ((!fm_is_valid_ent(entity)) || !editor) return

  4.         // Koordinaten holen
  5.         new Float:pos[3]
  6.         pev(entity, pev_origin, pos)
  7.         if (!fm_is_in_viewcone(editor, pos) && (entity != zone[index])) return                // sieht der Editor eh nicht

  8.         // jetzt vom Editor zur Zone testen... Zonen hinter der Wand aber im ViewCone
  9.         // m黶sen nicht gezeichnet werden
  10.         new Float:editorpos[3]
  11.         pev(editor, pev_origin, editorpos)
  12.         new Float:hitpoint[3]        // da ist der Treffer
  13.         fm_trace_line(-1, editorpos, pos, hitpoint)

  14.         // Linie zur Zone zeichnen ... dann wird sie schneller gefunden
  15.         if (entity == zone[index]) DrawLine(editorpos[0], editorpos[1], editorpos[2] - 16.0, pos[0], pos[1], pos[2], { 255, 0, 0} )

  16.         // Distanz zum Treffer ... ist Wert gr鲞er dann war da etwas
  17.         new Float:dh = vector_distance(editorpos, pos) - vector_distance(editorpos, hitpoint)
  18.         if ( (floatabs(dh) > 128.0) && (entity != zone[index])) return                        // hinter einer Wand

  19.         // -+*+-   die Zone muss gezeichnet werden   -+*+-

  20.         // Dimensionen holen
  21.         new Float:mins[3], Float:maxs[3]
  22.         pev(entity, pev_mins, mins)
  23.         pev(entity, pev_maxs, maxs)

  24.         // Gr鲞e in Absolut umrechnen
  25.         mins[0] += pos[0]
  26.         mins[1] += pos[1]
  27.         mins[2] += pos[2]
  28.         maxs[0] += pos[0]
  29.         maxs[1] += pos[1]
  30.         maxs[2] += pos[2]
  31.        
  32.         new id = pev(entity, ZONEID)
  33.        
  34.         new color[3]
  35.         color[0] = (zone[index] == entity) ? zone_color_aktiv[0] : zonecolor[ZONEMODE:id][0]
  36.         color[1] = (zone[index] == entity) ? zone_color_aktiv[1] : zonecolor[ZONEMODE:id][1]
  37.         color[2] = (zone[index] == entity) ? zone_color_aktiv[2] : zonecolor[ZONEMODE:id][2]
  38.        
  39.         // einzelnen Linien der Box zeichnen
  40.         //  -> alle Linien beginnen bei maxs
  41.         DrawLine(maxs[0], maxs[1], maxs[2], mins[0], maxs[1], maxs[2], color)
  42.         DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], maxs[2], color)
  43.         DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], maxs[1], mins[2], color)
  44.         //  -> alle Linien beginnen bei mins
  45.         DrawLine(mins[0], mins[1], mins[2], maxs[0], mins[1], mins[2], color)
  46.         DrawLine(mins[0], mins[1], mins[2], mins[0], maxs[1], mins[2], color)
  47.         DrawLine(mins[0], mins[1], mins[2], mins[0], mins[1], maxs[2], color)
  48.         //  -> die restlichen 6 Lininen
  49.         DrawLine(mins[0], maxs[1], maxs[2], mins[0], maxs[1], mins[2], color)
  50.         DrawLine(mins[0], maxs[1], mins[2], maxs[0], maxs[1], mins[2], color)
  51.         DrawLine(maxs[0], maxs[1], mins[2], maxs[0], mins[1], mins[2], color)
  52.         DrawLine(maxs[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], color)
  53.         DrawLine(maxs[0], mins[1], maxs[2], mins[0], mins[1], maxs[2], color)
  54.         DrawLine(mins[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], color)

  55.         // der Rest wird nur gezeichnet wenn es sich um ide aktuelle Box handelt
  56.         if (entity != zone[index]) return
  57.        
  58.         // jetzt noch die Koordinaten-Linien
  59.         if (direction == 0)        // X-Koordinaten
  60.         {
  61.                 DrawLine(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], mins[2], zone_color_green)
  62.                 DrawLine(maxs[0], maxs[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_green)
  63.                
  64.                 DrawLine(mins[0], maxs[1], maxs[2], mins[0], mins[1], mins[2], zone_color_red)
  65.                 DrawLine(mins[0], maxs[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red)
  66.         }
  67.         if (direction == 1)        // Y-Koordinaten
  68.         {
  69.                 DrawLine(mins[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_red)
  70.                 DrawLine(maxs[0], mins[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red)

  71.                 DrawLine(mins[0], maxs[1], mins[2], maxs[0], maxs[1], maxs[2], zone_color_green)
  72.                 DrawLine(maxs[0], maxs[1], mins[2], mins[0], maxs[1], maxs[2], zone_color_green)
  73.         }       
  74.         if (direction == 2)        // Z-Koordinaten
  75.         {
  76.                 DrawLine(maxs[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2], zone_color_green)
  77.                 DrawLine(maxs[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], zone_color_green)

  78.                 DrawLine(maxs[0], maxs[1], mins[2], mins[0], mins[1], mins[2], zone_color_red)
  79.                 DrawLine(maxs[0], mins[1], mins[2], mins[0], maxs[1], mins[2], zone_color_red)
  80.         }
  81. }

  82. public HideAllZones() {
  83.         editor = 0        // Men?f黵 den n鋍hsten wieder frei geben ... ufnktionalit鋞 aktivieren
  84.         for(new i = 0; i < maxzones; i++)
  85.         {
  86.                 new id = pev(zone[i], ZONEID)
  87.                 set_pev(zone[i], pev_solid, solidtyp[ZONEMODE:id])
  88.                 remove_task(TASK_BASIS_SHOWZONES + zone[i])
  89.         }
  90. }

  91. public FindAllZones() {
  92.         new entity = -1
  93.         maxzones = 0
  94.         while( (entity = fm_find_ent_by_class(entity, "walkguardzone")) )
  95.         {
  96.                 zone[maxzones] = entity
  97.                 maxzones++
  98.         }
  99. }

  100. public InitWalkGuard(player) {
  101.         new name[33], steam[33]
  102.         get_user_name(player, name, 32)
  103.         get_user_authid(player, steam, 32)
  104.        
  105.         if (!(get_user_flags(player) & ADMIN_RCON))
  106.         {
  107.                 log_amx("no access-rights for '%s' <%s>", name, steam)
  108.                 return PLUGIN_HANDLED
  109.         }
  110.        
  111.         editor = player
  112.         FindAllZones();
  113.         ShowAllZones();
  114.        
  115.         set_task(0.1, "OpenWalkGuardMenu", player)

  116.         return PLUGIN_HANDLED
  117. }

  118. public OpenWalkGuardMenu(player) {
  119.         new trans[70]
  120.         new menu[1024]
  121.         new zm = -1
  122.         new ct
  123.         new menukeys = MENU_KEY_0 + MENU_KEY_4 + MENU_KEY_9
  124.        
  125.         if (fm_is_valid_ent(zone[index]))
  126.         {
  127.                 zm = pev(zone[index], ZONEID)
  128.                 ct = pev(zone[index], CAMPERTIME)
  129.         }
  130.        
  131.         format(menu, 1023, "\dWalkGuard-Menu - Version %s\w", VERSION)
  132.         format(menu, 1023, "%s^n", menu)                // Leerzeile
  133.         format(menu, 1023, "%s^n", menu)                // Leerzeile
  134.         format(menu, 1023, "%L", player, "WGM_ZONE_FOUND", menu, maxzones)
  135.        
  136.         if (zm != -1)
  137.         {
  138.                 format(trans, 69, "%L", player, zonemode[ZONEMODE:zm])
  139.                 if (ZONEMODE:zm == ZM_CAMPING)
  140.                 {
  141.                         format(menu, 1023, "%L", player, "WGM_ZONE_CURRENT_CAMP", menu, index + 1, trans, ct)
  142.                 } else
  143.                 {
  144.                         format(menu, 1023, "%L", player, "WGM_ZONE_CURRENT_NONE", menu, index + 1, trans)
  145.                 }

  146.                 menukeys += MENU_KEY_2 + MENU_KEY_3 + MENU_KEY_1
  147.                 format(menu, 1023, "%s^n", menu)                // Leerzeile
  148.                 format(menu, 1023, "%s^n", menu)                // Leerzeile
  149.                 format(menu, 1023, "%L", player, "WGM_ZONE_EDIT", menu)
  150.                 format(menu, 1023, "%L", player, "WGM_ZONE_CHANGE", menu)
  151.         }
  152.        
  153.         format(menu, 1023, "%s^n", menu)                // Leerzeile
  154.         format(menu, 1023, "%L" ,player, "WGM_ZONE_CREATE", menu)
  155.        
  156.         if (zm != -1)
  157.         {
  158.                 menukeys += MENU_KEY_6
  159.                 format(menu, 1023, "%L", player, "WGM_ZONE_DELETE", menu)
  160.         }
  161.         format(menu, 1023, "%L", player, "WGM_ZONE_SAVE", menu)
  162.                
  163.         format(menu, 1023, "%s^n", menu)                // Leerzeile
  164.         format(menu, 1023, "%L" ,player, "WGM_ZONE_EXIT", menu)
  165.        
  166.         show_menu(player, menukeys, menu, -1, "MainMenu")
  167.         client_cmd(player, "spk sound/buttons/blip1.wav")
  168. }

  169. public MainMenuAction(player, key) {
  170.         key = (key == 10) ? 0 : key + 1
  171.         switch(key)
  172.         {
  173.                 case 1: {
  174.                                 // Zone editieren
  175.                                 if (fm_is_valid_ent(zone[index])) OpenEditMenu(player); else OpenWalkGuardMenu(player);
  176.                         }
  177.                 case 2: {
  178.                                 // vorherige Zone
  179.                                 index = (index > 0) ? index - 1 : index;
  180.                                 OpenWalkGuardMenu(player)
  181.                         }
  182.                 case 3: {
  183.                                 // n鋍hste Zone
  184.                                 index = (index < maxzones - 1) ? index + 1 : index;
  185.                                 OpenWalkGuardMenu(player)
  186.                         }
  187.                 case 4:        {
  188.                                 // neue Zone 黚er dem Spieler
  189.                                 if (maxzones < MAXZONES - 1)
  190.                                 {
  191.                                         CreateZoneOnPlayer(player);
  192.                                         ShowAllZones();
  193.                                         MainMenuAction(player, 0);        // selber aufrufen
  194.                                 } else
  195.                                 {
  196.                                         client_print(player, print_chat, "%L", player, "ZONE_FULL")
  197.                                         client_cmd(player, "spk sound/buttons/button10.wav")
  198.                                         set_task(0.5, "OpenWalkGuardMenu", player)
  199.                                 }
  200.                         }
  201.                 case 6: {
  202.                                 // aktuelle Zone l鰏chen
  203.                                 OpenKillMenu(player);
  204.                         }
  205.                 case 9: {
  206.                                 // Zonen speichern
  207.                                 SaveWGZ(player)
  208.                                 OpenWalkGuardMenu(player)
  209.                         }
  210.                 case 10:{
  211.                                 editor = 0
  212.                                 HideAllZones()
  213.                         }
  214.         }
  215. }
复制代码
回复

使用道具 举报

 楼主| 发表于 2009-1-7 00:53:30 | 显示全部楼层 来自 浙江温州
  1. public OpenEditMenu(player) {
  2.         new trans[70]
  3.        
  4.         new menu[1024]
  5.         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
  6.        
  7.         format(menu, 1023, "\dEdit WalkGuard-Zone\w")
  8.         format(menu, 1023, "%s^n", menu)                // Leerzeile
  9.         format(menu, 1023, "%s^n", menu)                // Leerzeile

  10.         new zm = -1
  11.         new ct
  12.         if (fm_is_valid_ent(zone[index]))
  13.         {
  14.                 zm = pev(zone[index], ZONEID)
  15.                 ct = pev(zone[index], CAMPERTIME)
  16.         }
  17.        
  18.         if (zm != -1)
  19.         {
  20.                 format(trans, 69, "%L", player, zonemode[ZONEMODE:zm])
  21.                 if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
  22.                 {
  23.                         format(menu, 1023, "%L", player, "WGE_ZONE_CURRENT_CAMP", menu, trans, ct)
  24.                         format(menu, 1023, "%L", player, "WGE_ZONE_CURRENT_CHANGE", menu)
  25.                         menukeys += MENU_KEY_2 + MENU_KEY_3
  26.                 } else
  27.                 {
  28.                         format(menu, 1023, "%L", player, "WGE_ZONE_CURRENT_NONE", menu, trans)
  29.                         format(menu, 1023, "%s^n", menu)                // Leerzeile
  30.                 }
  31.         }
  32.        
  33.         format(menu, 1023, "%s^n", menu)                // Leerzeile
  34.        
  35.         format(trans, 49, "%L", player, koordinaten[direction])
  36.         format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_INIT", menu, trans)
  37.         format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_MINS", menu)
  38.         format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_MAXS", menu)
  39.         format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_STEP", menu, setupunits)
  40.         format(menu, 1023, "%s^n", menu)                // Leerzeile
  41.         format(menu, 1023, "%s^n", menu)                // Leerzeile
  42.         format(menu, 1023, "%L", player, "WGE_ZONE_SIZE_QUIT", menu)
  43.        
  44.         show_menu(player, menukeys, menu, -1, "EditMenu")
  45.         client_cmd(player, "spk sound/buttons/blip1.wav")
  46. }

  47. public EditMenuAction(player, key) {
  48.         key = (key == 10) ? 0 : key + 1
  49.         switch(key)
  50.         {
  51.                 case 1: {
  52.                                 // n鋍hster ZoneMode
  53.                                 new zm = -1
  54.                                 zm = pev(zone[index], ZONEID)
  55.                                 if (ZONEMODE:zm == ZM_KILL_T2) zm = 0; else zm++;
  56.                                 set_pev(zone[index], ZONEID, zm)
  57.                                 OpenEditMenu(player)
  58.                         }
  59.                 case 2: {
  60.                                 // Campertime runter
  61.                                 new ct = pev(zone[index], CAMPERTIME)
  62.                                 ct = (ct > 5) ? ct - 1 : 5
  63.                                 set_pev(zone[index], CAMPERTIME, ct)
  64.                                 OpenEditMenu(player)
  65.                         }
  66.                 case 3: {
  67.                                 // Campertime hoch
  68.                                 new ct = pev(zone[index], CAMPERTIME)
  69.                                 ct = (ct < 30) ? ct + 1 : 30
  70.                                 set_pev(zone[index], CAMPERTIME, ct)
  71.                                 OpenEditMenu(player)
  72.                         }
  73.                 case 4: {
  74.                                 // Editier-Richtung 鋘dern
  75.                                 direction = (direction < 2) ? direction + 1 : 0
  76.                                 OpenEditMenu(player)
  77.                         }
  78.                 case 5: {
  79.                                 // von "mins" / rot etwas abziehen -> schmaler
  80.                                 ZuRotAddieren()
  81.                                 OpenEditMenu(player)
  82.                         }
  83.                 case 6: {
  84.                                 // zu "mins" / rot etwas addieren -> breiter
  85.                                 VonRotAbziehen()
  86.                                 OpenEditMenu(player)
  87.                         }
  88.                 case 7: {
  89.                                 // von "maxs" / gelb etwas abziehen -> schmaler
  90.                                 VonGelbAbziehen()
  91.                                 OpenEditMenu(player)
  92.                         }
  93.                 case 8: {
  94.                                 // zu "maxs" / gelb etwas addierne -> breiter
  95.                                 ZuGelbAddieren()
  96.                                 OpenEditMenu(player)
  97.                         }
  98.                 case 9: {
  99.                                 // Schreitweite 鋘dern
  100.                                 setupunits = (setupunits < 100) ? setupunits * 10 : 1
  101.                                 OpenEditMenu(player)
  102.                         }
  103.                 case 10:{
  104.                                 OpenWalkGuardMenu(player)
  105.                         }
  106.         }
  107. }

  108. public VonRotAbziehen() {
  109.         new entity = zone[index]
  110.        
  111.         // Koordinaten holen
  112.         new Float:pos[3]
  113.         pev(entity, pev_origin, pos)

  114.         // Dimensionen holen
  115.         new Float:mins[3], Float:maxs[3]
  116.         pev(entity, pev_mins, mins)
  117.         pev(entity, pev_maxs, maxs)

  118.         // k鰊nte Probleme geben -> zu klein
  119.         //if ((floatabs(mins[direction]) + maxs[direction]) < setupunits + 1) return
  120.        
  121.         mins[direction] -= float(setupunits) / 2.0
  122.         maxs[direction] += float(setupunits) / 2.0
  123.         pos[direction] -= float(setupunits) / 2.0
  124.        
  125.         set_pev(entity, pev_origin, pos)
  126.         fm_entity_set_size(entity, mins, maxs)
  127. }

  128. public ZuRotAddieren() {
  129.         new entity = zone[index]
  130.        
  131.         // Koordinaten holen
  132.         new Float:pos[3]
  133.         pev(entity, pev_origin, pos)

  134.         // Dimensionen holen
  135.         new Float:mins[3], Float:maxs[3]
  136.         pev(entity, pev_mins, mins)
  137.         pev(entity, pev_maxs, maxs)

  138.         // k鰊nte Probleme geben -> zu klein
  139.         if ((floatabs(mins[direction]) + maxs[direction]) < setupunits + 1) return

  140.         mins[direction] += float(setupunits) / 2.0
  141.         maxs[direction] -= float(setupunits) / 2.0
  142.         pos[direction] += float(setupunits) / 2.0
  143.        
  144.         set_pev(entity, pev_origin, pos)
  145.         fm_entity_set_size(entity, mins, maxs)
  146. }

  147. public VonGelbAbziehen() {
  148.         new entity = zone[index]
  149.        
  150.         // Koordinaten holen
  151.         new Float:pos[3]
  152.         pev(entity, pev_origin, pos)

  153.         // Dimensionen holen
  154.         new Float:mins[3], Float:maxs[3]
  155.         pev(entity, pev_mins, mins)
  156.         pev(entity, pev_maxs, maxs)

  157.         // k鰊nte Probleme geben -> zu klein
  158.         if ((floatabs(mins[direction]) + maxs[direction]) < setupunits + 1) return

  159.         mins[direction] += float(setupunits) / 2.0
  160.         maxs[direction] -= float(setupunits) / 2.0
  161.         pos[direction] -= float(setupunits) / 2.0
  162.        
  163.         set_pev(entity, pev_origin, pos)
  164.         fm_entity_set_size(entity, mins, maxs)
  165. }

  166. public ZuGelbAddieren() {
  167.         new entity = zone[index]
  168.        
  169.         // Koordinaten holen
  170.         new Float:pos[3]
  171.         pev(entity, pev_origin, pos)

  172.         // Dimensionen holen
  173.         new Float:mins[3], Float:maxs[3]
  174.         pev(entity, pev_mins, mins)
  175.         pev(entity, pev_maxs, maxs)

  176.         // k鰊nte Probleme geben -> zu klein
  177.         //if ((floatabs(mins[direction]) + maxs[direction]) < setupunits + 1) return

  178.         mins[direction] -= float(setupunits) / 2.0
  179.         maxs[direction] += float(setupunits) / 2.0
  180.         pos[direction] += float(setupunits) / 2.0
  181.        
  182.         set_pev(entity, pev_origin, pos)
  183.         fm_entity_set_size(entity, mins, maxs)
  184. }

  185. public OpenKillMenu(player) {
  186.         new menu[1024]
  187.        
  188.         format(menu, 1023, "%L", player, "ZONE_KILL_INIT")
  189.         format(menu, 1023, "%L", player, "ZONE_KILL_ASK", menu) // ja - nein - vieleicht
  190.        
  191.         show_menu(player, MENU_KEY_1 + MENU_KEY_0, menu, -1, "KillMenu")
  192.        
  193.         client_cmd(player, "spk sound/buttons/button10.wav")
  194. }

  195. public KillMenuAction(player, key) {
  196.         key = (key == 10) ? 0 : key + 1
  197.         switch(key)
  198.         {
  199.                 case 1: {
  200.                                 client_print(player, print_chat, "[WalkGuard] %L", player, "ZONE_KILL_NO")
  201.                         }
  202.                 case 10:{
  203.                                 fm_remove_entity(zone[index])
  204.                                 index--;
  205.                                 if (index < 0) index = 0;
  206.                                 client_print(player, print_chat, "[WalkGuard] %L", player, "ZONE_KILL_YES")
  207.                                 FindAllZones()
  208.                         }
  209.         }
  210.         OpenWalkGuardMenu(player)
  211. }

  212. stock fm_set_kvd(entity, const key[], const value[], const classname[] = "") {
  213.         if (classname[0])
  214.                 set_kvd(0, KV_ClassName, classname)
  215.         else {
  216.                 new class[32]
  217.                 pev(entity, pev_classname, class, sizeof class - 1)
  218.                 set_kvd(0, KV_ClassName, class)
  219.         }

  220.         set_kvd(0, KV_KeyName, key)
  221.         set_kvd(0, KV_Value, value)
  222.         set_kvd(0, KV_fHandled, 0)

  223.         return dllfunc(DLLFunc_KeyValue, entity, 0)
  224. }

  225. stock fm_fake_touch(toucher, touched)
  226.         return dllfunc(DLLFunc_Touch, toucher, touched)

  227. stock fm_DispatchSpawn(entity)
  228.         return dllfunc(DLLFunc_Spawn, entity)

  229. stock fm_remove_entity(index)
  230.         return engfunc(EngFunc_RemoveEntity, index)

  231. stock fm_find_ent_by_class(index, const classname[])
  232.         return engfunc(EngFunc_FindEntityByString, index, "classname", classname)

  233. stock fm_is_valid_ent(index)
  234.         return pev_valid(index)

  235. stock fm_entity_set_size(index, const Float:mins[3], const Float:maxs[3])
  236.         return engfunc(EngFunc_SetSize, index, mins, maxs)

  237. stock fm_entity_set_model(index, const model[])
  238.         return engfunc(EngFunc_SetModel, index, model)

  239. stock fm_create_entity(const classname[])
  240.         return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname))

  241. stock fm_fakedamage(victim, const classname[], Float:takedmgdamage, damagetype) {
  242.         new class[] = "trigger_hurt"
  243.         new entity = fm_create_entity(class)
  244.         if (!entity)
  245.                 return 0

  246.         new value[16]
  247.         float_to_str(takedmgdamage * 2, value, sizeof value - 1)
  248.         fm_set_kvd(entity, "dmg", value, class)

  249.         num_to_str(damagetype, value, sizeof value - 1)
  250.         fm_set_kvd(entity, "damagetype", value, class)

  251.         fm_set_kvd(entity, "origin", "8192 8192 8192", class)
  252.         fm_DispatchSpawn(entity)

  253.         set_pev(entity, pev_classname, classname)
  254.         fm_fake_touch(entity, victim)
  255.         fm_remove_entity(entity)

  256.         return 1
  257. }

  258. stock fm_entity_set_origin(index, const Float:origin[3]) {
  259.         new Float:mins[3], Float:maxs[3]
  260.         pev(index, pev_mins, mins)
  261.         pev(index, pev_maxs, maxs)
  262.         engfunc(EngFunc_SetSize, index, mins, maxs)

  263.         return engfunc(EngFunc_SetOrigin, index, origin)
  264. }

  265. stock fm_set_entity_visibility(index, visible = 1) {
  266.         set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW)

  267.         return 1
  268. }

  269. stock bool:fm_is_in_viewcone(index, const Float:point[3]) {
  270.         new Float:angles[3]
  271.         pev(index, pev_angles, angles)
  272.         engfunc(EngFunc_MakeVectors, angles)
  273.         global_get(glb_v_forward, angles)
  274.         angles[2] = 0.0

  275.         new Float:origin[3], Float:diff[3], Float:norm[3]
  276.         pev(index, pev_origin, origin)
  277.         xs_vec_sub(point, origin, diff)
  278.         diff[2] = 0.0
  279.         xs_vec_normalize(diff, norm)

  280.         new Float:dot, Float:fov
  281.         dot = xs_vec_dot(norm, angles)
  282.         pev(index, pev_fov, fov)
  283.         if (dot >= floatcos(fov * M_PI / 360))
  284.                 return true

  285.         return false
  286. }

  287. stock fm_trace_line(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
  288.         engfunc(EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent, 0)

  289.         new ent = get_tr2(0, TR_pHit)
  290.         get_tr2(0, TR_vecEndPos, ret)

  291.         return pev_valid(ent) ? ent : 0
  292. }
复制代码
回复

使用道具 举报

发表于 2009-1-7 11:17:15 | 显示全部楼层 来自 广东惠州
本帖最后由 zwfgdlc 于 2009-1-7 11:27 编辑

因为CS1.5里没有"HLTV"这个事件.试下这个.

BTW:真想骂人.上传个SMA文件也不可以.下载个附件也要扣点.连个PHP标签也不支持.

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
回复

使用道具 举报

 楼主| 发表于 2009-1-7 11:28:26 | 显示全部楼层 来自 浙江温州
哈,谢谢楼上的了,我明白了,我试下可以不如果还不行我就把jim那段1.5替换HLTV的代码修改上去。
回复

使用道具 举报

发表于 2009-1-7 11:54:25 | 显示全部楼层 来自 北京海淀
如果不是非要强调新一局的开始,其实用Round_Start就行了,区别就在于round start是在freeze time结束会的新一局开始,也就是玩家可以行动。毕竟我提供的那种方法效率不够高(基于字符串比较,而且那个函数本身被调用的很频繁)
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表