找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 823|回复: 4

[已解决] 求插件代码

[复制链接]

该用户从未签到

发表于 2011-3-12 18:57:31 | 显示全部楼层 |阅读模式
就是屏水 还有队友模型的那个插件的

该用户从未签到

发表于 2011-3-12 19:22:52 | 显示全部楼层
那是simen服务器上的吧,无能为力,等管理员来了再说吧

该用户从未签到

发表于 2011-3-12 19:41:51 | 显示全部楼层
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4. #include <hamsandwich>

  5. #pragma semicolon 1

  6. #define MAX_ENTITYS 900+15*32 // (900+15*SERVER_SLOTS) is the calculation cs uses but it can be bypassed by the "-num_edicts <x>"-parameter

  7. new bool:g_bPlayerInvisible[33];
  8. new bool:g_bWaterInvisible[33];

  9. new bool:g_bWaterEntity[MAX_ENTITYS];
  10. new bool:g_bWaterFound;

  11. new g_iSpectatedId[33];

  12. public plugin_init( )
  13. {
  14. register_plugin( "Invis", "2.0", "SchlumPF" );

  15. register_clcmd( "say /invis", "menuInvisDisplay" );
  16. register_menucmd( register_menuid( "\rInvisibility - SchlumPF^n^n" ), 1023, "menuInvisAction" );

  17. register_forward( FM_AddToFullPack, "fwdAddToFullPack_Post", 1 );
  18. RegisterHam( Ham_Spawn, "player", "hamSpawnPlayer_Post", 1 );

  19. register_event( "SpecHealth2", "eventSpecHealth2", "bd" );
  20. }

  21. public plugin_cfg( )
  22. {
  23. // precache in a boolean variable whether an entity is func_water or not.
  24. // this will save a lot performance since AddToFullPack is called very often.
  25. // i could set the ents iuser variable to avoid using such a huge variable
  26. // and problems with the "-num_edicts" parameter but this is a lot faster
  27. // than retrieving pev_iuser in AddToFullPack. another way would have been
  28. // using a binary system to store the data in less than a huge array but in
  29. // fact a huge array takes a few kb ram which is for me less than a constant
  30. // usage of the cpu since i would need to use a few operators to read the data
  31. // out of the bianry system. all in all a binary storing system is at least a good
  32. // alternative which some iuser variable of the private ent values (pev) would not be.

  33. new ent = -1;
  34. while( ( ent = find_ent_by_class( ent, "func_water" ) ) != 0 )
  35. {
  36. // pev( ent, pev_skin ) == CONTENTS_WATER is also true on func_water entities

  37. if( !g_bWaterFound )
  38. {
  39. g_bWaterFound = true;
  40. }

  41. g_bWaterEntity[ent] = true;
  42. }

  43. // thanks to connor for finding the following two detections
  44. ent = -1;
  45. while( ( ent = find_ent_by_class( ent, "func_illusionary" ) ) != 0 )
  46. {
  47. if( pev( ent, pev_skin ) == CONTENTS_WATER )
  48. {
  49. if( !g_bWaterFound )
  50. {
  51. g_bWaterFound = true;
  52. }

  53. g_bWaterEntity[ent] = true;
  54. }
  55. }

  56. ent = -1;
  57. while( ( ent = find_ent_by_class( ent, "func_conveyor" ) ) != 0 )
  58. {
  59. if( pev( ent, pev_spawnflags ) == 3 )
  60. {
  61. if( !g_bWaterFound )
  62. {
  63. g_bWaterFound = true;
  64. }

  65. g_bWaterEntity[ent] = true;
  66. }
  67. }
  68. }

  69. public fwdAddToFullPack_Post( es_handle, e, ent, host, hostflags, player, pset )
  70. {
  71. if( player && g_bPlayerInvisible[host] && host != ent && ent != g_iSpectatedId[host] )
  72. {
  73. static const Float:corner[8][3] =
  74. {
  75. { -4096.0, -4096.0, -4096.0 },
  76. { -4096.0, -4096.0, 4096.0 },
  77. { -4096.0, 4096.0, -4096.0 },
  78. { -4096.0, 4096.0, 4096.0 },
  79. { 4096.0, -4096.0, -4096.0 },
  80. { 4096.0, -4096.0, 4096.0 },
  81. { 4096.0, 4096.0, -4096.0 },
  82. { 4096.0, 4096.0, 4096.0 }
  83. };

  84. // rounded; distance from the map's center to the corners; sqrt( 4096^2 + 4096^2 + 4096^2 )
  85. static const Float:map_distance = 7094.480108;

  86. static Float:origin[3];
  87. get_es( es_handle, ES_Origin, origin );

  88. static i;
  89. while( get_distance_f( origin, corner[i] ) > map_distance )
  90. {
  91. if( ++i >= sizeof( corner ) )
  92. {
  93. // better to nullify the varibale now then doing it each time before the loop
  94. i = 0;
  95. }
  96. }

  97. set_es( es_handle, ES_Origin, corner[i] );
  98. set_es( es_handle, ES_Effects, get_es( es_handle, ES_Effects ) | EF_NODRAW );
  99. }
  100. else if( g_bWaterInvisible[host] && g_bWaterEntity[ent])
  101. {
  102. set_es( es_handle, ES_Effects, get_es( es_handle, ES_Effects ) | EF_NODRAW );
  103. }
  104. }

  105. public hamSpawnPlayer_Post( plr )
  106. {
  107. g_iSpectatedId[plr] = 0;
  108. }

  109. // thanks to xPaw who told me about this event
  110. public eventSpecHealth2( plr )
  111. {
  112. g_iSpectatedId[plr] = read_data( 2 );
  113. }

  114. public menuInvisDisplay( plr )
  115. {
  116. static menu[256];

  117. new len = formatex( menu, 255, "\rInvisibility - SchlumPF^n^n" );

  118. len += formatex( menu[len], 255 - len, "\r1. \wPlayers: %s^n", g_bPlayerInvisible[plr] ? "invisible" : "visible" );

  119. if( g_bWaterFound )
  120. {
  121. len += formatex( menu[len], 255 - len, "\r2. \wWater: %s^n", g_bWaterInvisible[plr] ? "invisible" : "visible" );
  122. }
  123. //else
  124. //{
  125. // len += formatex( menu[len], 255 - len, "\r2. \wWater: There is no water on this map!^n" );
  126. //}

  127. len += formatex( menu[len], 255 - len, "^n\r0. \wExit" );

  128. show_menu( plr, ( 1<<0 | 1<<1 | 1<<9 ), menu, -1 );

  129. return PLUGIN_HANDLED;
  130. }

  131. public menuInvisAction( plr, key )
  132. {
  133. switch( key )
  134. {
  135. case 0:
  136. {
  137. g_bPlayerInvisible[plr] = !g_bPlayerInvisible[plr];
  138. menuInvisDisplay( plr );
  139. }
  140. case 1:
  141. {
  142. if( g_bWaterFound )
  143. {
  144. g_bWaterInvisible[plr] = !g_bWaterInvisible[plr];
  145. }

  146. menuInvisDisplay( plr );
  147. }
  148. case 9: show_menu( plr, 0, "" );
  149. }
  150. }

  151. public client_connect( plr )
  152. {
  153. g_bPlayerInvisible[plr] = false;
  154. g_bWaterInvisible[plr] = false;
  155. g_iSpectatedId[plr] = 0;
  156. }
复制代码

该用户从未签到

发表于 2011-3-12 19:48:25 | 显示全部楼层
回复 SiMen.K. 的帖子

http://bbs.simen.cn/thread-41481-1-1.html 6楼是我对插件的建议。

可惜我对编程语言了解的并不是很透彻。

该用户从未签到

发表于 2011-3-12 20:13:18 | 显示全部楼层
那栋洗对我的帮助很大!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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