找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1439|回复: 16

【已解决】 插件不能共存问题

[复制链接]

该用户从未签到

发表于 2010-6-16 19:07:45 | 显示全部楼层 |阅读模式
本帖最后由 SiMen.K. 于 2010-6-16 20:25 编辑

在XJ把一个能显示JUMPOFF的amxx下过来..运行起来可以了.....又有个新问题

我原先的每一次加速信息跟这个不能同时显示的...
要么只显示JUMPOFF数据,要么只有加速性息数据
求解

该用户从未签到

发表于 2010-6-16 19:13:17 | 显示全部楼层
性息?什么性息?

该用户从未签到

发表于 2010-6-16 19:19:06 | 显示全部楼层
性息...
楼下请保持队形..

该用户从未签到

 楼主| 发表于 2010-6-16 20:02:04 | 显示全部楼层
尽爱找茬....恨死你们了

讲讲正经的

该用户从未签到

发表于 2010-6-16 20:06:27 | 显示全部楼层
把源码发上来

该用户从未签到

 楼主| 发表于 2010-6-16 20:10:41 | 显示全部楼层
回复 5# SiMen.K.


   
看看吧.....我是没辙了

该用户从未签到

 楼主| 发表于 2010-6-16 20:13:28 | 显示全部楼层
本帖最后由 SiMen.K. 于 2010-6-16 20:21 编辑
  1. * SETTINGS
  2. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  3. #define MIN_BLOCK 210  // minimum block for which stats appear
  4. #define MAX_BLOCK 280  // maximum block for which stats appear
  5. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6. * DO NOT MODIFY BELOW HERE
  7. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  8. #define FL_ONGROUND2  ( FL_ONGROUND | FL_PARTIALGROUND | FL_INWATER | FL_CONVEYOR | FL_FLOAT )
  9. #define HLBSP_EXTRA  0.03125  // hlbsp adds an aditional hull around entites with this size, unfortunately players cannot land on it
  10. new bool:edgeDistanceEnabled[33];
  11. new bool:resetJump[33];
  12. new sv_gravity;
  13. new cvarHudColor;
  14. new cvarHudColorFail;
  15. new cvarHudCoords;
  16. new cvarHudHoldtime;
  17. new cvarHudChannel;
  18. public plugin_init( )
  19. {
  20. register_plugin( "Edge Distances", "0.23", "SchlumPF" );
  21. register_forward( FM_PlayerPreThink, "FM_PlayerPreThink_Pre", 0 );

  22. register_clcmd( "say /ed", "Cmd_EdgeDistance" );
  23. register_clcmd( "say /edge", "Cmd_EdgeDistance" );
  24. register_clcmd( "say /edgedistance", "Cmd_EdgeDistance" );

  25. cvarHudColor = register_cvar( "ed_hud_color", "0 255 0" );
  26. cvarHudColorFail = register_cvar( "ed_hud_failcolor", "255 0 127" );
  27. cvarHudCoords = register_cvar( "ed_hud_coords", "-1.0 -0.875" );
  28. cvarHudHoldtime = register_cvar( "ed_hud_holdtime", "1.6" );
  29. cvarHudChannel = register_cvar( "ed_hud_channel", "4" );

  30. register_touch( "func_train", "player", "Fwd_ResetJump" );
  31. register_touch( "func_door", "player", "Fwd_ResetJump" );
  32. register_touch( "func_door_rotating", "player", "Fwd_ResetJump" );
  33. register_touch( "func_conveyor", "player", "Fwd_ResetJump" );
  34. register_touch( "func_rotating", "player", "Fwd_ResetJump" );
  35. register_touch( "trigger_push", "player", "Fwd_ResetJump" );
  36. register_touch( "trigger_teleport", "player", "Fwd_ResetJump" );

  37. sv_gravity = get_cvar_pointer( "sv_gravity" );
  38. }
  39. public plugin_cfg( )
  40. {
  41. new const commands[][] =
  42. {
  43.   "tele", "tp", "gocheck", "gc",
  44.   "stuck", "unstuck",
  45.   "start", "reset", "spawn", "restart"
  46. };

  47. new const prefixes[][] =
  48. {
  49.   "", ".", "/"
  50. };

  51. new cmd[32];
  52. for( new s; s < 2; s++ )
  53. {
  54.   for( new i; i < sizeof( commands ); i++ )
  55.   {
  56.    for( new j; j < sizeof( prefixes ); j++ )
  57.    {
  58.     formatex( cmd, 31, "%s%s%s", (s == 0) ? "" : "say ", prefixes[j], commands );
  59.     register_clcmd( cmd, "Cmd_ResetJump" );
  60.    }
  61.   }
  62. }

  63. register_clcmd( "+hook", "Cmd_ResetJump" );
  64. register_clcmd( "-hook", "Cmd_ResetJump" );
  65. register_clcmd( "+rope", "Cmd_ResetJump" );
  66. register_clcmd( "-rope", "Cmd_ResetJump" );
  67. }
  68. public ResetJump( plr )
  69. {
  70. resetJump[plr] = true;
  71. }
  72. public Fwd_ResetJump( ent, plr )
  73. {
  74. ResetJump( plr );
  75. }
  76. public Cmd_ResetJump( plr )
  77. {
  78. ResetJump( plr );
  79. }
  80. public Cmd_EdgeDistance( plr )
  81. {
  82. edgeDistanceEnabled[plr] = !edgeDistanceEnabled[plr];

  83. static saytext;

  84. if( !saytext )
  85. {
  86.   saytext = get_user_msgid( "SayText" );
  87. }

  88. static msg[64];
  89. formatex( msg, 63, "^x04[ED]^x01 Edge Distances %s be shown now.", edgeDistanceEnabled[plr] ? "will" : "won't" );

  90. message_begin( MSG_ONE_UNRELIABLE, saytext, { 0, 0, 0 }, plr );
  91. write_byte( plr );
  92. write_string( msg );
  93. message_end( );

  94. return PLUGIN_HANDLED;
  95. }
  96. public client_connect( plr )
  97. {
  98. edgeDistanceEnabled[plr] = true;
  99. }
  100. public FM_PlayerPreThink_Pre( plr )
  101. {
  102. static bool:inAir[33], bool:firstFrame[33], bool:failStats[33];
  103. static Float:jumpoff_footheight[33];
  104. static Float:jumpoff_origin[33][3], Float:fail_origin[33][3];
  105. static Float:frame_origin[33][2][3], Float:frame_velocity[33][2][3];

  106. static Floatrigin[3];

  107. if( !edgeDistanceEnabled[plr] )
  108. {
  109.   return FMRES_IGNORED;
  110. }

  111. if( resetJump[plr] || pev( plr, pev_movetype ) == MOVETYPE_FLY )
  112. {
  113.   resetJump[plr] = false;
  114.   inAir[plr] = false;
  115. }

  116. static button;
  117. button = pev( plr, pev_button );

  118. static oldButtons;
  119. oldButtons = pev( plr, pev_oldbuttons );

  120. static flags;
  121. flags = pev( plr, pev_flags );

  122. if( inAir[plr] )
  123. {
  124.   if( flags & FL_ONGROUND2 && !failStats[plr] )
  125.   {
  126.    pev( plr, pev_origin, origin );
  127.   
  128.    static Float:mins[3];
  129.    pev( plr, pev_mins, mins );
  130.    
  131.    if( jumpoff_footheight[plr] == origin[2] + mins[2] )
  132.    {
  133.     static Float:gravity;
  134.     gravity = get_pcvar_float( sv_gravity ) * pev( plr, pev_gravity );
  135.    
  136.     static Float:temp;
  137.     temp = floatdiv( -floatsqroot( frame_velocity[plr][0][2] * frame_velocity[plr][0][2] + ( 2 * gravity * ( frame_origin[plr][0][2] - origin[2] + 0.1 ) ) ) - frame_velocity[plr][1][2], -gravity );
  138.    
  139.     static Float:landing_origin[3];
  140.     if( frame_origin[plr][1][0] < origin[0] ) landing_origin[0] = frame_origin[plr][1][0] + temp * floatabs( frame_velocity[plr][1][0] );
  141.     else      landing_origin[0] = frame_origin[plr][1][0] - temp * floatabs( frame_velocity[plr][1][0] );
  142.    
  143.     if( frame_origin[plr][1][1] < origin[1] ) landing_origin[1] = frame_origin[plr][1][1] + temp * floatabs( frame_velocity[plr][1][1] );
  144.     else      landing_origin[1] = frame_origin[plr][1][1] - temp * floatabs( frame_velocity[plr][1][1] );
  145.    
  146.     static Float:distance_1;
  147.     distance_1 = floatsqroot( floatpower( origin[0] - jumpoff_origin[plr][0], 2.0 ) + floatpower( origin[1] - jumpoff_origin[plr][1], 2.0 ) ) + 32.0;
  148.    
  149.     static Float:distance_2;
  150.     distance_2 = floatsqroot( floatpower( landing_origin[0] - jumpoff_origin[plr][0], 2.0 ) + floatpower( landing_origin[1] - jumpoff_origin[plr][1], 2.0 ) ) + 32.0;
  151.    
  152.     if( distance_1 > distance_2 )  CalculateDistances( plr, jumpoff_origin[plr], landing_origin, jumpoff_footheight[plr], flags, distance_2 );
  153.     else     CalculateDistances( plr, jumpoff_origin[plr], origin, jumpoff_footheight[plr], flags, distance_1 );
  154.    }
  155.    
  156.    resetJump[plr] = true;
  157.   }
  158.   else if( failStats[plr] )
  159.   {
  160.    resetJump[plr] = true;
  161.    failStats[plr] = false;
  162.    CalculateDistances( plr, jumpoff_origin[plr], fail_origin[plr], jumpoff_footheight[plr], flags, -1.0 );
  163.   }
  164.   else
  165.   {
  166.    pev( plr, pev_origin, origin );
  167.   
  168.    failStats[plr] = ( ( origin[2] + 18 ) < jumpoff_origin[plr][2] );
  169.    
  170.    if( ( is_user_ducking( plr ) ? ( origin[2] + 18 ) : origin[2] ) >= jumpoff_origin[plr][2] )
  171.    {
  172.     static Float:temp;
  173.     temp = ( jumpoff_origin[plr][2] - frame_origin[plr][1][2] ) / ( origin[2] - frame_origin[plr][1][2] );
  174.     fail_origin[plr][0] = temp * ( origin[0] - frame_origin[plr][1][0] ) + frame_origin[plr][1][0];
  175.     fail_origin[plr][1] = temp * ( origin[1] - frame_origin[plr][1][1] ) + frame_origin[plr][1][1];
  176.     fail_origin[plr][2] = jumpoff_footheight[plr];
  177.    }
  178.    
  179.    if( firstFrame[plr] )
  180.    {
  181.     firstFrame[plr] = false;
  182.    
  183.     xs_vec_copy( origin, frame_origin[plr][0] );
  184.     pev( plr, pev_velocity, frame_velocity[plr][0] );
  185.    }
  186.    else
  187.    {
  188.     xs_vec_copy( origin, frame_origin[plr][1] );
  189.     pev( plr, pev_velocity, frame_velocity[plr][1] );
  190.    }
  191.   }
  192. }

  193. if( button & IN_JUMP && !( oldButtons & IN_JUMP ) )
  194. {
  195.   inAir[plr] = true;
  196.   firstFrame[plr] = true;
  197.   
  198.   if( flags & FL_ONGROUND2 )
  199.   {
  200.    pev( plr, pev_origin, jumpoff_origin[plr] );
  201.    
  202.    static Float:mins[3];
  203.    pev( plr, pev_mins, mins );
  204.    
  205.    jumpoff_footheight[plr] = jumpoff_origin[plr][2] + mins[2];
  206.   }
  207.   else
  208.   {
  209.    static Float:velocity[3];
  210.    pev( plr, pev_velocity, velocity );
  211.    
  212.    if( !velocity[2] )
  213.    {
  214.     pev( plr, pev_origin, origin );
  215.    
  216.     jumpoff_origin[plr][0] = origin[0];
  217.     jumpoff_origin[plr][1] = origin[1];
  218.    }
  219.   }
  220. }

  221. return FMRES_IGNORED;
  222. }
  223. public CalculateDistances( plr, Float:start[3], Float:stop[3], Float:jumpoff_footheight, flags, Float:distance )
  224. {
  225. // use some delay to avoid bugs
  226. static Float:lastCalc[33];

  227. static Float:gametime;
  228. gametime = get_gametime( );

  229. if( gametime - lastCalc[plr] < 0.5 )
  230. {
  231.   return 0;
  232. }

  233. lastCalc[plr] = gametime;

  234. // calculate the center origin of jumpoff and landing and set it to the height of the player's feet
  235. // we need to lower stop[2] so that the hull with which we are tracing can hit the block
  236. static Float:vertex_origin[3];
  237. vertex_origin[0] = ( start[0] + stop[0] ) * 0.5;
  238. vertex_origin[1] = ( start[1] + stop[1] ) * 0.5;
  239. vertex_origin[2] = stop[2] - 1.0;

  240. // check whether it was in free space by which we can find out whether the player jumped over a gap
  241. if( engfunc( EngFunc_PointContents, vertex_origin ) != CONTENTS_EMPTY )
  242. {
  243.   return 0;
  244. }

  245. // set the hull with which we will need to trace for a valid result
  246. static hull;
  247. hull = flags & FL_DUCKING || ( distance < 0 ) ? HULL_HEAD : HULL_HUMAN;

  248. start[2] = vertex_origin[2];
  249. stop[2] = vertex_origin[2];

  250. static block;
  251. static Float:jumpoff_edge;
  252. static Float:landing_edge;

  253. static Float:jumpoff_edge_origin[3];
  254. static Float:landing_edge_origin[3];

  255. static Float:vecPlaneNormal[3];

  256. // do a trace from the center to jumpoff
  257. engfunc( EngFunc_TraceHull, vertex_origin, start, IGNORE_MONSTERS, hull, -1, 0 );
  258. get_tr2( 0, TR_vecPlaneNormal, vecPlaneNormal );

  259. // if vecPlaneNormal is 0.0, the player hit some ramp or something
  260. if( vecPlaneNormal[2] != 0.0 )
  261. {
  262.   return 0;
  263. }

  264. // retrieve the edge origin
  265. get_tr2( 0, TR_vecEndPos, jumpoff_edge_origin );

  266. // calculate the smallest distance from jumpoff to the edge using vecPlaneNormal to see in which direction the player jumped
  267. if( floatabs( vecPlaneNormal[0] ) == 1.0 && !vecPlaneNormal[1] )  jumpoff_edge = floatabs( jumpoff_edge_origin[0] - start[0] ) - HLBSP_EXTRA;
  268. else if( !vecPlaneNormal[0] && floatabs( vecPlaneNormal[1] ) == 1.0 ) jumpoff_edge = floatabs( jumpoff_edge_origin[1] - start[1] ) - HLBSP_EXTRA;
  269. else return 0;

  270. // distance < 0 means the player failed failed the jump
  271. if( distance < 0 )
  272. {
  273.   static Float:end[3];
  274.   
  275.   // extend the coords so the traces can hit the block
  276.   if( floatabs( vecPlaneNormal[0] ) == 1.0 && !vecPlaneNormal[1] )
  277.   {
  278.    end[0] = stop[0] + vecPlaneNormal[0] * 300;
  279.    end[1] = stop[1];
  280.    end[2] = stop[2];
  281.   }
  282.   else if( !vecPlaneNormal[0] && floatabs( vecPlaneNormal[1] ) == 1.0 )
  283.   {
  284.    end[0] = stop[0];
  285.    end[1] = stop[1] + vecPlaneNormal[1] * 300;
  286.    end[2] = stop[2];
  287.   }
  288.   else return 0;
  289.   
  290.   engfunc( EngFunc_TraceHull, vertex_origin, end, IGNORE_MONSTERS, hull, -1, 0 );
  291.   get_tr2( 0, TR_vecPlaneNormal, vecPlaneNormal );

  292.   if( vecPlaneNormal[2] != 0.0 ) return 0;
  293.   get_tr2( 0, TR_vecEndPos, landing_edge_origin );
  294.   
  295.   if( floatabs( vecPlaneNormal[0] ) == 1.0 && !vecPlaneNormal[1] )
  296.   {
  297.    end[0] = landing_edge_origin[0] - vecPlaneNormal[0] * 16.1;
  298.    end[1] = landing_edge_origin[1];
  299.    end[2] = landing_edge_origin[2] + 37.0;
  300.   }
  301.   else if( !vecPlaneNormal[0] && floatabs( vecPlaneNormal[1] ) == 1.0 )
  302.   {
  303.    end[0] = landing_edge_origin[0];
  304.    end[1] = landing_edge_origin[1] - vecPlaneNormal[1] * 16.1;
  305.    end[2] = landing_edge_origin[2] + 37.0;
  306.   }
  307.   else return 0;
  308.   
  309.   vertex_origin[2] += 37.0;

  310.   engfunc( EngFunc_TraceHull, vertex_origin, end, IGNORE_MONSTERS, hull, -1, 0 );
  311.   
  312.   static Float:fraction;
  313.   get_tr2( 0, TR_flFraction, fraction );
  314.   
  315.   // the player jumped against a wall
  316.   if( fraction < 1.0 ) return 0;
  317. }
  318. else
  319. {
  320.   engfunc( EngFunc_TraceHull, vertex_origin, stop, IGNORE_MONSTERS, hull, -1, 0 );
  321.   get_tr2( 0, TR_vecPlaneNormal, vecPlaneNormal );

  322.   if( vecPlaneNormal[2] != 0.0 ) return 0;
  323.   
  324.   get_tr2( 0, TR_vecEndPos, landing_edge_origin );
  325. }

  326. if( floatabs( vecPlaneNormal[0] ) == 1.0 && !vecPlaneNormal[1] )
  327. {
  328.   landing_edge = floatabs( landing_edge_origin[0] - stop[0] ) - HLBSP_EXTRA;
  329.   block = floatround( floatabs( landing_edge_origin[0] - jumpoff_edge_origin[0] ) ) + 32;
  330. }
  331. else if( !vecPlaneNormal[0] && floatabs( vecPlaneNormal[1] ) == 1.0 )
  332. {
  333.   landing_edge = floatabs( landing_edge_origin[1] - stop[1] ) - HLBSP_EXTRA;
  334.   block = floatround( floatabs( landing_edge_origin[1] - jumpoff_edge_origin[1] ) ) + 32;
  335. }
  336. else return 0;

  337. if( MAX_BLOCK < block || block < MIN_BLOCK ) return 0;
  338. static Float:x, Float:y;
  339. GetHudCoords( cvarHudCoords, x, y );
  340. static r, g, b;

  341. if( distance < 0 )
  342. {
  343.   GetHudColor( cvarHudColorFail, r, g, b );
  344.   
  345.   client_print( plr, print_console, "Fail --- Block: %i - Jumpoff: %f", block, jumpoff_edge );
  346.   
  347.   set_hudmessage( r, g, b, x, y, 0, 0.0, get_pcvar_float( cvarHudHoldtime ), 0.1, 0.1, get_pcvar_num( cvarHudChannel ) );
  348.   show_hudmessage( plr, "Block: %i^nJumpoff: %f", block, jumpoff_edge );
  349.   
  350.   return 1;
  351. }

  352. GetHudColor( cvarHudColor, r, g, b );

  353. client_print( plr, print_console, "Gj! --- Block: %i - Jumpoff: %f - Landing: %f", block, jumpoff_edge, landing_edge );

  354. set_hudmessage( r, g, b, x, y, 0, 0.0, get_pcvar_float( cvarHudHoldtime ), 0.0, 0.0, get_pcvar_num( cvarHudChannel ) );
  355. show_hudmessage( plr, "Block: %i^nJumpoff: %f^nLanding: %f", block, jumpoff_edge, landing_edge );

  356. return 1;
  357. }
  358. public GetHudColor( cvar, &r, &g, &b )
  359. {
  360. static color[16], piece[5];
  361. get_pcvar_string( cvar, color, 15 );

  362. strbreak( color, piece, 4, color, 15 );
  363. r = str_to_num( piece );

  364. strbreak( color, piece, 4, color, 15 );
  365. g = str_to_num( piece );
  366. b = str_to_num( color );
  367. }
  368. public GetHudCoords( cvar, &Float:x, &Float:y )
  369. {
  370. static coords[16], piece[10];
  371. get_pcvar_string( cvar, coords, 15 );

  372. strbreak( coords, piece, 9, coords, 15 );
  373. x = str_to_float( piece );
  374. y = str_to_float( coords );
  375. }
  376. stock bool:is_user_ducking( plr )
  377. {
  378. static Float:absmin[3];
  379. pev( plr, pev_absmin, absmin );

  380. static Float:absmax[3];
  381. pev( plr, pev_absmax, absmax );
  382. return !( ( absmin[2] + 64.0 ) < absmax[2] );
  383. }
复制代码

该用户从未签到

 楼主| 发表于 2010-6-16 20:14:09 | 显示全部楼层
中间的那个表情是EY...我也没办法

附件不会发...只能这样了

该用户从未签到

发表于 2010-6-16 20:24:37 | 显示全部楼层
本帖最后由 SiMen.K. 于 2010-6-16 22:01 编辑
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <xs>
  5. #pragma semicolon 1
  6. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7. * SETTINGS
  8. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  9. #define MIN_BLOCK 210  // minimum block for which stats appear
  10. #define MAX_BLOCK 280  // maximum block for which stats appear
  11. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  12. * SETTINGS
  13. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  14. #define MIN_BLOCK 210  // minimum block for which stats appear
  15. #define MAX_BLOCK 280  // maximum block for which stats appear
  16. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  17. * DO NOT MODIFY BELOW HERE
  18. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  19. #define FL_ONGROUND2  ( FL_ONGROUND | FL_PARTIALGROUND | FL_INWATER | FL_CONVEYOR | FL_FLOAT )
  20. #define HLBSP_EXTRA  0.03125  // hlbsp adds an aditional hull around entites with this size, unfortunately players cannot land on it
  21. new bool:edgeDistanceEnabled[33];
  22. new bool:resetJump[33];
  23. new sv_gravity;
  24. new cvarHudColor;
  25. new cvarHudColorFail;
  26. new cvarHudCoords;
  27. new cvarHudHoldtime;
  28. new cvarHudChannel;
  29. public plugin_init( )
  30. {
  31. register_plugin( "Edge Distances", "0.23", "SchlumPF" );
  32. register_forward( FM_PlayerPreThink, "FM_PlayerPreThink_Pre", 0 );
  33. register_clcmd( "say /ed", "Cmd_EdgeDistance" );
  34. register_clcmd( "say /edge", "Cmd_EdgeDistance" );
  35. register_clcmd( "say /edgedistance", "Cmd_EdgeDistance" );
  36. cvarHudColor = register_cvar( "ed_hud_color", "0 255 0" );
  37. cvarHudColorFail = register_cvar( "ed_hud_failcolor", "255 0 127" );
  38. cvarHudCoords = register_cvar( "ed_hud_coords", "-1.0 -0.875" );
  39. cvarHudHoldtime = register_cvar( "ed_hud_holdtime", "1.6" );
  40. cvarHudChannel = register_cvar( "ed_hud_channel", "5" );
  41. register_touch( "func_train", "player", "Fwd_ResetJump" );
  42. register_touch( "func_door", "player", "Fwd_ResetJump" );
  43. register_touch( "func_door_rotating", "player", "Fwd_ResetJump" );
  44. register_touch( "func_conveyor", "player", "Fwd_ResetJump" );
  45. register_touch( "func_rotating", "player", "Fwd_ResetJump" );
  46. register_touch( "trigger_push", "player", "Fwd_ResetJump" );
  47. register_touch( "trigger_teleport", "player", "Fwd_ResetJump" );
  48. sv_gravity = get_cvar_pointer( "sv_gravity" );
  49. }
  50. public plugin_cfg( )
  51. {
  52. new const commands[][] =
  53. {
  54.   "tele", "tp", "gocheck", "gc",
  55.   "stuck", "unstuck",
  56.   "start", "reset", "spawn", "restart"
  57. };
  58. new const prefixes[][] =
  59. {
  60.   "", ".", "/"
  61. };
  62. new cmd[32];
  63. for( new s; s < 2; s++ )
  64. {
  65.   for( new i; i < sizeof( commands ); i++ )
  66.   {
  67.    for( new j; j < sizeof( prefixes ); j++ )
  68.    {
  69.     formatex( cmd, 31, "%s%s%s", (s == 0) ? "" : "say ", prefixes[j], commands );
  70.     register_clcmd( cmd, "Cmd_ResetJump" );
  71.    }
  72.   }
  73. }
  74. register_clcmd( "+hook", "Cmd_ResetJump" );
  75. register_clcmd( "-hook", "Cmd_ResetJump" );
  76. register_clcmd( "+rope", "Cmd_ResetJump" );
  77. register_clcmd( "-rope", "Cmd_ResetJump" );
  78. }
  79. public ResetJump( plr )
  80. {
  81. resetJump[plr] = true;
  82. }
  83. public Fwd_ResetJump( ent, plr )
  84. {
  85. ResetJump( plr );
  86. }
  87. public Cmd_ResetJump( plr )
  88. {
  89. ResetJump( plr );
  90. }
  91. public Cmd_EdgeDistance( plr )
  92. {
  93. edgeDistanceEnabled[plr] = !edgeDistanceEnabled[plr];
  94. static saytext;
  95. if( !saytext )
  96. {
  97.   saytext = get_user_msgid( "SayText" );
  98. }
  99. static msg[64];
  100. formatex( msg, 63, "^x04[ED]^x01 Edge Distances %s be shown now.", edgeDistanceEnabled[plr] ? "will" : "won't" );
  101. message_begin( MSG_ONE_UNRELIABLE, saytext, { 0, 0, 0 }, plr );
  102. write_byte( plr );
  103. write_string( msg );
  104. message_end( );
  105. return PLUGIN_HANDLED;
  106. }
  107. public client_connect( plr )
  108. {
  109. edgeDistanceEnabled[plr] = true;
  110. }
  111. public FM_PlayerPreThink_Pre( plr )
  112. {
  113. static bool:inAir[33], bool:firstFrame[33], bool:failStats[33];
  114. static Float:jumpoff_footheight[33];
  115. static Float:jumpoff_origin[33][3], Float:fail_origin[33][3];
  116. static Float:frame_origin[33][2][3], Float:frame_velocity[33][2][3];
  117. static Floatrigin[3];
  118. if( !edgeDistanceEnabled[plr] )
  119. {
  120.   return FMRES_IGNORED;
  121. }
  122. if( resetJump[plr] || pev( plr, pev_movetype ) == MOVETYPE_FLY )
  123. {
  124.   resetJump[plr] = false;
  125.   inAir[plr] = false;
  126. }
  127. static button;
  128. button = pev( plr, pev_button );
  129. static oldButtons;
  130. oldButtons = pev( plr, pev_oldbuttons );
  131. static flags;
  132. flags = pev( plr, pev_flags );
  133. if( inAir[plr] )
  134. {
  135.   if( flags & FL_ONGROUND2 && !failStats[plr] )
  136.   {
  137.    pev( plr, pev_origin, origin );
  138.   
  139.    static Float:mins[3];
  140.    pev( plr, pev_mins, mins );
  141.    
  142.    if( jumpoff_footheight[plr] == origin[2] + mins[2] )
  143.    {
  144.     static Float:gravity;
  145.     gravity = get_pcvar_float( sv_gravity ) * pev( plr, pev_gravity );
  146.    
  147.     static Float:temp;
  148.     temp = floatdiv( -floatsqroot( frame_velocity[plr][0][2] * frame_velocity[plr][0][2] + ( 2 * gravity * ( frame_origin[plr][0][2] - origin[2] + 0.1 ) ) ) - frame_velocity[plr][1][2], -gravity );
  149.    
  150.     static Float:landing_origin[3];
  151.     if( frame_origin[plr][1][0] < origin[0] ) landing_origin[0] = frame_origin[plr][1][0] + temp * floatabs( frame_velocity[plr][1][0] );
  152.     else      landing_origin[0] = frame_origin[plr][1][0] - temp * floatabs( frame_velocity[plr][1][0] );
  153.    
  154.     if( frame_origin[plr][1][1] < origin[1] ) landing_origin[1] = frame_origin[plr][1][1] + temp * floatabs( frame_velocity[plr][1][1] );
  155.     else      landing_origin[1] = frame_origin[plr][1][1] - temp * floatabs( frame_velocity[plr][1][1] );
  156.    
  157.     static Float:distance_1;
  158.     distance_1 = floatsqroot( floatpower( origin[0] - jumpoff_origin[plr][0], 2.0 ) + floatpower( origin[1] - jumpoff_origin[plr][1], 2.0 ) ) + 32.0;
  159.    
  160.     static Float:distance_2;
  161.     distance_2 = floatsqroot( floatpower( landing_origin[0] - jumpoff_origin[plr][0], 2.0 ) + floatpower( landing_origin[1] - jumpoff_origin[plr][1], 2.0 ) ) + 32.0;
  162.    
  163.     if( distance_1 > distance_2 )  CalculateDistances( plr, jumpoff_origin[plr], landing_origin, jumpoff_footheight[plr], flags, distance_2 );
  164.     else     CalculateDistances( plr, jumpoff_origin[plr], origin, jumpoff_footheight[plr], flags, distance_1 );
  165.    }
  166.    
  167.    resetJump[plr] = true;
  168.   }
  169.   else if( failStats[plr] )
  170.   {
  171.    resetJump[plr] = true;
  172.    failStats[plr] = false;
  173.    CalculateDistances( plr, jumpoff_origin[plr], fail_origin[plr], jumpoff_footheight[plr], flags, -1.0 );
  174.   }
  175.   else
  176.   {
  177.    pev( plr, pev_origin, origin );
  178.   
  179.    failStats[plr] = ( ( origin[2] + 18 ) < jumpoff_origin[plr][2] );
  180.    
  181.    if( ( is_user_ducking( plr ) ? ( origin[2] + 18 ) : origin[2] ) >= jumpoff_origin[plr][2] )
  182.    {
  183.     static Float:temp;
  184.     temp = ( jumpoff_origin[plr][2] - frame_origin[plr][1][2] ) / ( origin[2] - frame_origin[plr][1][2] );
  185.     fail_origin[plr][0] = temp * ( origin[0] - frame_origin[plr][1][0] ) + frame_origin[plr][1][0];
  186.     fail_origin[plr][1] = temp * ( origin[1] - frame_origin[plr][1][1] ) + frame_origin[plr][1][1];
  187.     fail_origin[plr][2] = jumpoff_footheight[plr];
  188.    }
  189.    
  190.    if( firstFrame[plr] )
  191.    {
  192.     firstFrame[plr] = false;
  193.    
  194.     xs_vec_copy( origin, frame_origin[plr][0] );
  195.     pev( plr, pev_velocity, frame_velocity[plr][0] );
  196.    }
  197.    else
  198.    {
  199.     xs_vec_copy( origin, frame_origin[plr][1] );
  200.     pev( plr, pev_velocity, frame_velocity[plr][1] );
  201.    }
  202.   }
  203. }
  204. if( button & IN_JUMP && !( oldButtons & IN_JUMP ) )
  205. {
  206.   inAir[plr] = true;
  207.   firstFrame[plr] = true;
  208.   
  209.   if( flags & FL_ONGROUND2 )
  210.   {
  211.    pev( plr, pev_origin, jumpoff_origin[plr] );
  212.    
  213.    static Float:mins[3];
  214.    pev( plr, pev_mins, mins );
  215.    
  216.    jumpoff_footheight[plr] = jumpoff_origin[plr][2] + mins[2];
  217.   }
  218.   else
  219.   {
  220.    static Float:velocity[3];
  221.    pev( plr, pev_velocity, velocity );
  222.    
  223.    if( !velocity[2] )
  224.    {
  225.     pev( plr, pev_origin, origin );
  226.    
  227.     jumpoff_origin[plr][0] = origin[0];
  228.     jumpoff_origin[plr][1] = origin[1];
  229.    }
  230.   }
  231. }
  232. return FMRES_IGNORED;
  233. }
  234. public CalculateDistances( plr, Float:start[3], Float:stop[3], Float:jumpoff_footheight, flags, Float:distance )
  235. {
  236. // use some delay to avoid bugs
  237. static Float:lastCalc[33];
  238. static Float:gametime;
  239. gametime = get_gametime( );
  240. if( gametime - lastCalc[plr] < 0.5 )
  241. {
  242.   return 0;
  243. }
  244. lastCalc[plr] = gametime;
  245. // calculate the center origin of jumpoff and landing and set it to the height of the player's feet
  246. // we need to lower stop[2] so that the hull with which we are tracing can hit the block
  247. static Float:vertex_origin[3];
  248. vertex_origin[0] = ( start[0] + stop[0] ) * 0.5;
  249. vertex_origin[1] = ( start[1] + stop[1] ) * 0.5;
  250. vertex_origin[2] = stop[2] - 1.0;
  251. // check whether it was in free space by which we can find out whether the player jumped over a gap
  252. if( engfunc( EngFunc_PointContents, vertex_origin ) != CONTENTS_EMPTY )
  253. {
  254.   return 0;
  255. }
  256. // set the hull with which we will need to trace for a valid result
  257. static hull;
  258. hull = flags & FL_DUCKING || ( distance < 0 ) ? HULL_HEAD : HULL_HUMAN;
  259. start[2] = vertex_origin[2];
  260. stop[2] = vertex_origin[2];
  261. static block;
  262. static Float:jumpoff_edge;
  263. static Float:landing_edge;
  264. static Float:jumpoff_edge_origin[3];
  265. static Float:landing_edge_origin[3];
  266. static Float:vecPlaneNormal[3];
  267. // do a trace from the center to jumpoff
  268. engfunc( EngFunc_TraceHull, vertex_origin, start, IGNORE_MONSTERS, hull, -1, 0 );
  269. get_tr2( 0, TR_vecPlaneNormal, vecPlaneNormal );
  270. // if vecPlaneNormal is 0.0, the player hit some ramp or something
  271. if( vecPlaneNormal[2] != 0.0 )
  272. {
  273.   return 0;
  274. }
  275. // retrieve the edge origin
  276. get_tr2( 0, TR_vecEndPos, jumpoff_edge_origin );
  277. // calculate the smallest distance from jumpoff to the edge using vecPlaneNormal to see in which direction the player jumped
  278. if( floatabs( vecPlaneNormal[0] ) == 1.0 && !vecPlaneNormal[1] )  jumpoff_edge = floatabs( jumpoff_edge_origin[0] - start[0] ) - HLBSP_EXTRA;
  279. else if( !vecPlaneNormal[0] && floatabs( vecPlaneNormal[1] ) == 1.0 ) jumpoff_edge = floatabs( jumpoff_edge_origin[1] - start[1] ) - HLBSP_EXTRA;
  280. else return 0;
  281. // distance < 0 means the player failed failed the jump
  282. if( distance < 0 )
  283. {
  284.   static Float:end[3];
  285.   
  286.   // extend the coords so the traces can hit the block
  287.   if( floatabs( vecPlaneNormal[0] ) == 1.0 && !vecPlaneNormal[1] )
  288.   {
  289.    end[0] = stop[0] + vecPlaneNormal[0] * 300;
  290.    end[1] = stop[1];
  291.    end[2] = stop[2];
  292.   }
  293.   else if( !vecPlaneNormal[0] && floatabs( vecPlaneNormal[1] ) == 1.0 )
  294.   {
  295.    end[0] = stop[0];
  296.    end[1] = stop[1] + vecPlaneNormal[1] * 300;
  297.    end[2] = stop[2];
  298.   }
  299.   else return 0;
  300.   
  301.   engfunc( EngFunc_TraceHull, vertex_origin, end, IGNORE_MONSTERS, hull, -1, 0 );
  302.   get_tr2( 0, TR_vecPlaneNormal, vecPlaneNormal );
  303.   if( vecPlaneNormal[2] != 0.0 ) return 0;
  304.   get_tr2( 0, TR_vecEndPos, landing_edge_origin );
  305.   
  306.   if( floatabs( vecPlaneNormal[0] ) == 1.0 && !vecPlaneNormal[1] )
  307.   {
  308.    end[0] = landing_edge_origin[0] - vecPlaneNormal[0] * 16.1;
  309.    end[1] = landing_edge_origin[1];
  310.    end[2] = landing_edge_origin[2] + 37.0;
  311.   }
  312.   else if( !vecPlaneNormal[0] && floatabs( vecPlaneNormal[1] ) == 1.0 )
  313.   {
  314.    end[0] = landing_edge_origin[0];
  315.    end[1] = landing_edge_origin[1] - vecPlaneNormal[1] * 16.1;
  316.    end[2] = landing_edge_origin[2] + 37.0;
  317.   }
  318.   else return 0;
  319.   
  320.   vertex_origin[2] += 37.0;
  321.   engfunc( EngFunc_TraceHull, vertex_origin, end, IGNORE_MONSTERS, hull, -1, 0 );
  322.   
  323.   static Float:fraction;
  324.   get_tr2( 0, TR_flFraction, fraction );
  325.   
  326.   // the player jumped against a wall
  327.   if( fraction < 1.0 ) return 0;
  328. }
  329. else
  330. {
  331.   engfunc( EngFunc_TraceHull, vertex_origin, stop, IGNORE_MONSTERS, hull, -1, 0 );
  332.   get_tr2( 0, TR_vecPlaneNormal, vecPlaneNormal );
  333.   if( vecPlaneNormal[2] != 0.0 ) return 0;
  334.   
  335.   get_tr2( 0, TR_vecEndPos, landing_edge_origin );
  336. }
  337. if( floatabs( vecPlaneNormal[0] ) == 1.0 && !vecPlaneNormal[1] )
  338. {
  339.   landing_edge = floatabs( landing_edge_origin[0] - stop[0] ) - HLBSP_EXTRA;
  340.   block = floatround( floatabs( landing_edge_origin[0] - jumpoff_edge_origin[0] ) ) + 32;
  341. }
  342. else if( !vecPlaneNormal[0] && floatabs( vecPlaneNormal[1] ) == 1.0 )
  343. {
  344.   landing_edge = floatabs( landing_edge_origin[1] - stop[1] ) - HLBSP_EXTRA;
  345.   block = floatround( floatabs( landing_edge_origin[1] - jumpoff_edge_origin[1] ) ) + 32;
  346. }
  347. else return 0;
  348. if( MAX_BLOCK < block || block < MIN_BLOCK ) return 0;
  349. static Float:x, Float:y;
  350. GetHudCoords( cvarHudCoords, x, y );
  351. static r, g, b;
  352. if( distance < 0 )
  353. {
  354.   GetHudColor( cvarHudColorFail, r, g, b );
  355.   
  356.   client_print( plr, print_console, "Fail --- Block: %i - Jumpoff: %f", block, jumpoff_edge );
  357.   
  358.   set_hudmessage( r, g, b, x, y, 0, 0.0, get_pcvar_float( cvarHudHoldtime ), 0.1, 0.1, get_pcvar_num( cvarHudChannel ) );
  359.   show_hudmessage( plr, "Block: %i^nJumpoff: %f", block, jumpoff_edge );
  360.   
  361.   return 1;
  362. }
  363. GetHudColor( cvarHudColor, r, g, b );
  364. client_print( plr, print_console, "Gj! --- Block: %i - Jumpoff: %f - Landing: %f", block, jumpoff_edge, landing_edge );
  365. set_hudmessage( r, g, b, x, y, 0, 0.0, get_pcvar_float( cvarHudHoldtime ), 0.0, 0.0, get_pcvar_num( cvarHudChannel ) );
  366. show_hudmessage( plr, "Block: %i^nJumpoff: %f^nLanding: %f", block, jumpoff_edge, landing_edge );
  367. return 1;
  368. }
  369. public GetHudColor( cvar, &r, &g, &b )
  370. {
  371. static color[16], piece[5];
  372. get_pcvar_string( cvar, color, 15 );
  373. strbreak( color, piece, 4, color, 15 );
  374. r = str_to_num( piece );
  375. strbreak( color, piece, 4, color, 15 );
  376. g = str_to_num( piece );
  377. b = str_to_num( color );
  378. }
  379. public GetHudCoords( cvar, &Float:x, &Float:y )
  380. {
  381. static coords[16], piece[10];
  382. get_pcvar_string( cvar, coords, 15 );
  383. strbreak( coords, piece, 9, coords, 15 );
  384. x = str_to_float( piece );
  385. y = str_to_float( coords );
  386. }
  387. stock bool:is_user_ducking( plr )
  388. {
  389. static Float:absmin[3];
  390. pev( plr, pev_absmin, absmin );
  391. static Float:absmax[3];
  392. pev( plr, pev_absmax, absmax );
  393. return !( ( absmin[2] + 64.0 ) < absmax[2] );
  394. }
复制代码



给交给你个艰巨的任务  看看我改了那些代码

该用户从未签到

 楼主| 发表于 2010-6-16 20:31:22 | 显示全部楼层
回复 9# SiMen.K.


    我可以不找你改的吗?
可以直接复制过来吗?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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