找回密码
 立即注册

QQ登录

只需一步,快速开始

楼主: 不插电

【已解决】 求一个智能测量插件 最好是中文的。

[复制链接]

该用户从未签到

发表于 2010-5-5 17:32:00 | 显示全部楼层
回复 10# 不插电

早不说



  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <xs>
  4. /*
  5.    This edition finally edits is by Pledges . QQ:2099502
  6. */
  7. #pragma semicolon 1
  8. #define TASK_BEAM 45896
  9. new Float:g_vFirstLoc[33][3];
  10. new Float:g_vSecondLoc[33][3];
  11. new bool:g_bReturnFloat[33];
  12. new bool:g_bShowBeams[33];
  13. new bool:g_bDetailedResults[33];
  14. new bool:g_bAutoSetting[33];
  15. new g_iColors[3] = { 255, 85, 0 };
  16. new g_flBeam;
  17. public plugin_init( )
  18. {
  19. register_plugin( "Measure", "3.4", "SchlumPF" );

  20. register_concmd( "measure_color", "cmdChangeColor" );

  21. register_clcmd( "say /measure","cmdMeasure" );
  22. register_clcmd( "say /distance","cmdMeasure" );

  23. register_menucmd( register_menuid( "\r距离测量 - 菜单^n^n" ), 1023, "menuAction" );
  24. }
  25. public plugin_precache( )
  26. {
  27. g_flBeam = precache_model( "sprites/zbeam4.spr" );
  28. }
  29. public cmdMeasure( plr )
  30. {
  31. pev( plr, pev_origin, g_vFirstLoc[plr] );
  32. g_vFirstLoc[plr][2] -= is_user_ducking( plr ) ? 18 : 36;
  33. g_vSecondLoc[plr] = g_vFirstLoc[plr];
  34. if( g_bShowBeams[plr] && !task_exists( plr + TASK_BEAM ) )
  35. {
  36.   set_task( 0.1, "tskBeam", plr + TASK_BEAM, _, _, "ab" );
  37. }

  38. menuDisplay( plr );

  39. //return PLUGIN_HANDLED;
  40. }

  41. public cmdChangeColor( plr )
  42. {
  43. if( !( get_user_flags( plr ) & ADMIN_KICK ) )
  44. {
  45.   client_print( plr, print_console, "* 您还没有进入这个命令" );
  46.   return PLUGIN_HANDLED;
  47. }

  48. if( read_argc( ) != 4 )
  49. {
  50.   client_print( plr, print_console, "用法: measure_color <red> <green> <blue>" );
  51.   return PLUGIN_HANDLED;
  52. }
  53.   
  54. new r_str[4], g_str[4], b_str[4];
  55. read_argv( 1, r_str, 3 );
  56. read_argv( 2, g_str, 3 );
  57. read_argv( 3, b_str, 3 );

  58. g_iColors[0] = clamp( str_to_num( r_str ), 0, 255 );
  59. g_iColors[1] = clamp( str_to_num( g_str ), 0, 255 );
  60. g_iColors[2] = clamp( str_to_num( b_str ), 0, 255 );

  61. client_print( plr, print_console, "measure_color changed to ^"%i %i %i^"", g_iColors[0], g_iColors[1], g_iColors[2] );

  62. return PLUGIN_HANDLED;
  63. }
  64. public menuDisplay( plr )
  65. {
  66. static menu[2048];

  67. new len = format( menu, 2047, "\r距离测量 - 菜单^n^n" );

  68. if( g_bReturnFloat[plr] )
  69. {
  70.   len += format( menu[len], 2047 - len, "\r01. \w设置 #1 \d< %.03f | %.03f | %.03f >^n", g_vFirstLoc[plr][0], g_vFirstLoc[plr][1], g_vFirstLoc[plr][2] );
  71.   len += format( menu[len], 2047 - len, "\r02. \w设置 #2 \d< %.03f | %.03f | %.03f >^n^n", g_vSecondLoc[plr][0], g_vSecondLoc[plr][1], g_vSecondLoc[plr][2] );
  72.   len += format( menu[len], 2047 - len, "\r03. \w自动设置其他参数: \d%s^n^n", g_bAutoSetting[plr] ? "on" : "off" );
  73.   len += format( menu[len], 2047 - len, "\r04. \w详细结果: \d%s^n", g_bDetailedResults[plr] ? "on" : "off" );
  74.   len += format( menu[len], 2047 - len, "\r05. \w返回值: \ddecimal^n^n" );
  75.   len += format( menu[len], 2047 - len, "\r      \w结果:^n" );
  76.   
  77.   if( g_bDetailedResults[plr] )
  78.   {
  79.    len += format( menu[len], 2047 - len, "\r      \wX-距离: \d%f^n", floatabs( g_vFirstLoc[plr][0] - g_vSecondLoc[plr][0] ) );
  80.    len += format( menu[len], 2047 - len, "\r      \wY-距离: \d%f^n", floatabs( g_vFirstLoc[plr][1] - g_vSecondLoc[plr][1] ) );
  81.   }
  82.   
  83.   len += format( menu[len], 2047 - len, "\r      \w高度差: \d%f^n", floatabs( g_vFirstLoc[plr][2] - g_vSecondLoc[plr][2] ) );
  84.   len += format( menu[len], 2047 - len, "\r      \w实际距离: \d%f^n^n", get_distance_f( g_vFirstLoc[plr], g_vSecondLoc[plr] ) );
  85. }
  86. else
  87. {
  88.   len += format( menu[len], 2047 - len, "\r01. \w设置 #1 \d< %i | %i | %i >^n", floatround( g_vFirstLoc[plr][0], floatround_round ), floatround( g_vFirstLoc[plr][1], floatround_round ), floatround( g_vFirstLoc[plr][2], floatround_round ) );
  89.   len += format( menu[len], 2047 - len, "\r02. \w设置 #2 \d< %i | %i | %i >^n^n", floatround( g_vSecondLoc[plr][0], floatround_round ), floatround( g_vSecondLoc[plr][1], floatround_round ), floatround( g_vSecondLoc[plr][2], floatround_round ) );
  90.   len += format( menu[len], 2047 - len, "\r03. \w自动设置其他参数: \d%s^n^n", g_bAutoSetting[plr] ? "on" : "off" );
  91.   len += format( menu[len], 2047 - len, "\r04. \w详细结果: \d%s^n", g_bDetailedResults[plr] ? "on" : "off" );
  92.   len += format( menu[len], 2047 - len, "\r05 \w返回值: \drounded^n^n" );
  93.   len += format( menu[len], 2047 - len, "\r      \w结果:^n" );
  94.   
  95.   if( g_bDetailedResults[plr] )
  96.   {
  97.    len += format( menu[len], 2047 - len, "\r      \wX-距离: \d%i^n", floatround( floatabs( g_vFirstLoc[plr][0] - g_vSecondLoc[plr][0] ), floatround_round ) );
  98.    len += format( menu[len], 2047 - len, "\r      \wY-距离: \d%i^n", floatround( floatabs( g_vFirstLoc[plr][1] - g_vSecondLoc[plr][1] ), floatround_round ) );
  99.   }
  100.   
  101.   len += format( menu[len], 2047 - len, "\r      \w高度差: \d%i^n", floatround( floatabs( g_vFirstLoc[plr][2] - g_vSecondLoc[plr][2] ), floatround_round ) );
  102.   len += format( menu[len], 2047 - len, "\r      \w实际距离: \d%i^n^n", floatround( get_distance_f( g_vFirstLoc[plr], g_vSecondLoc[plr] ), floatround_round ) );
  103.   
  104. }

  105. len += format( menu[len], 2047 - len, "\r06. \w显示功能: \d%s^n^n", g_bShowBeams[plr] ? "on" : "off" );
  106. len += format( menu[len], 2047 - len, "\r00. \w退出" );

  107. show_menu( plr, ( 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<9 ), menu, -1 );
  108. }
  109. public menuAction( plr, key )
  110. {
  111. switch( key )
  112. {
  113.   case 0:
  114.   {
  115.    fm_get_aim_origin( plr, g_vFirstLoc[plr] );
  116.    
  117.    if( g_bAutoSetting[plr] )
  118.    {
  119.     get_tr2( 0, TR_vecPlaneNormal, g_vSecondLoc[plr] );
  120.    
  121.     xs_vec_mul_scalar( g_vSecondLoc[plr], 9999.0, g_vSecondLoc[plr] );
  122.     xs_vec_add( g_vFirstLoc[plr], g_vSecondLoc[plr], g_vSecondLoc[plr] );
  123.     fm_trace_line( plr, g_vFirstLoc[plr], g_vSecondLoc[plr], g_vSecondLoc[plr] );
  124.    }
  125.    menuDisplay( plr );
  126.   }
  127.   case 1:
  128.   {
  129.    fm_get_aim_origin( plr, g_vSecondLoc[plr] );
  130.    if( g_bAutoSetting[plr] )
  131.    {
  132.     get_tr2( 0, TR_vecPlaneNormal, g_vFirstLoc[plr] );
  133.     xs_vec_mul_scalar( g_vFirstLoc[plr], 9999.0, g_vFirstLoc[plr] );
  134.     xs_vec_add( g_vFirstLoc[plr], g_vSecondLoc[plr], g_vFirstLoc[plr] );
  135.     fm_trace_line( plr, g_vSecondLoc[plr], g_vFirstLoc[plr], g_vFirstLoc[plr] );
  136.    }
  137.    menuDisplay( plr );
  138.   }
  139.   case 2:
  140.   {
  141.    g_bAutoSetting[plr] = !g_bAutoSetting[plr];
  142.    menuDisplay( plr );
  143.   }
  144.   case 3:
  145.   {
  146.    g_bDetailedResults[plr] = !g_bDetailedResults[plr];
  147.    menuDisplay( plr );
  148.   }
  149.   case 4:
  150.   {
  151.    g_bReturnFloat[plr] = !g_bReturnFloat[plr];
  152.    menuDisplay( plr );
  153.   }
  154.   case 5:
  155.   {
  156.    g_bShowBeams[plr] = !g_bShowBeams[plr];
  157.    
  158.    if( !g_bShowBeams[plr] && task_exists( plr + TASK_BEAM ) )
  159.    {
  160.     remove_task( plr + TASK_BEAM );
  161.    }
  162.    else
  163.    {
  164.     set_task( 0.1, "tskBeam", plr + TASK_BEAM, _, _, "ab" );
  165.    }
  166.    menuDisplay( plr );
  167.   }
  168.   case 9:
  169.   {
  170.    remove_task( plr + TASK_BEAM );
  171.    show_menu( plr, 0, "" );
  172.   }
  173. }
  174. }
  175. public tskBeam( plr )
  176. {
  177. plr -= TASK_BEAM;

  178. draw_beam( plr, g_vFirstLoc[plr], g_vSecondLoc[plr], g_iColors[0], g_iColors[1], g_iColors[2] );

  179. if( floatabs( g_vFirstLoc[plr][2] - g_vSecondLoc[plr][2] ) >= 2 )
  180. {
  181.   static Float:temp[3];
  182.   temp[0] = g_vSecondLoc[plr][0];
  183.   temp[1] = g_vSecondLoc[plr][1];
  184.   temp[2] = g_vFirstLoc[plr][2];
  185.   
  186.   draw_beam( plr, g_vFirstLoc[plr], temp, g_iColors[0], g_iColors[1], g_iColors[2] );
  187.   draw_beam( plr, temp, g_vSecondLoc[plr], g_iColors[0], g_iColors[1], g_iColors[2] );
  188. }
  189. }
  190. public draw_beam( plr, Float:aorigin[3], Float:borigin[3], r, g, b )
  191. {
  192. message_begin( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, { 0.0, 0.0, 0.0 }, plr );
  193. write_byte( TE_BEAMPOINTS );
  194. engfunc( EngFunc_WriteCoord, aorigin[0] );
  195. engfunc( EngFunc_WriteCoord, aorigin[1] );
  196. engfunc( EngFunc_WriteCoord, aorigin[2] );
  197. engfunc( EngFunc_WriteCoord, borigin[0] );
  198. engfunc( EngFunc_WriteCoord, borigin[1] );
  199. engfunc( EngFunc_WriteCoord, borigin[2] );
  200. write_short( g_flBeam );
  201. write_byte( 0 );
  202. write_byte( 0 );
  203. write_byte( 2 );
  204. write_byte( 20 );
  205. write_byte( 0 );
  206. write_byte( r );
  207. write_byte( g );
  208. write_byte( b );
  209. write_byte( 150 );
  210. write_byte( 0 );
  211. message_end( );
  212. }
  213. public client_connect( plr )
  214. {
  215. g_bShowBeams[plr] = true;
  216. g_bReturnFloat[plr] = true;
  217. g_bDetailedResults[plr] = false;
  218. g_bAutoSetting[plr] = false;
  219. }
  220. is_user_ducking( plr )
  221. {
  222. if( !pev_valid( plr )  )
  223. {
  224.   return 0;
  225. }

  226. new Float:abs_min[3], Float:abs_max[3];
  227. pev( plr, pev_absmin, abs_min );
  228. pev( plr, pev_absmax, abs_max );

  229. abs_min[2] += 64.0;

  230. if( abs_min[2] < abs_max[2] )
  231. {
  232.   return 0;
  233. }

  234. return 1;
  235. }
  236. fm_get_aim_origin( plr, Float:origin[3] )
  237. {
  238. new Float:start[3], Float:view_ofs[3];
  239. pev( plr, pev_origin, start );
  240. pev( plr, pev_view_ofs, view_ofs );
  241. xs_vec_add( start, view_ofs, start );
  242. new Float:dest[3];
  243. pev( plr, pev_v_angle, dest );
  244. engfunc( EngFunc_MakeVectors, dest);
  245. global_get( glb_v_forward, dest );
  246. xs_vec_mul_scalar( dest, 9999.0, dest );
  247. xs_vec_add( start, dest, dest );
  248. engfunc( EngFunc_TraceLine, start, dest, 0, plr, 0 );
  249. get_tr2( 0, TR_vecEndPos, origin );
  250. return 1;
  251. }
  252. fm_trace_line( ignoreent, const Float:start[3], const Float:end[3], Float:ret[3] )
  253. {
  254. engfunc( EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent, 0 );

  255. new ent = get_tr2( 0, TR_pHit );
  256. get_tr2( 0, TR_vecEndPos, ret );

  257. return pev_valid( ent ) ? ent : 0;
  258. }

复制代码

该用户从未签到

 楼主| 发表于 2010-5-5 19:57:21 | 显示全部楼层
回复 11# SiMen.K.


      好就这个
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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