找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 843|回复: 6

【已解决】 我想要一個原檔..

[复制链接]

该用户从未签到

发表于 2010-4-11 15:25:03 | 显示全部楼层 |阅读模式
本帖最后由 SiMen.K. 于 2010-5-4 10:02 编辑

invis.sma
就是可以隱藏水面的那一類
不然我玩單機會掉fps

该用户从未签到

发表于 2010-4-11 15:37:39 | 显示全部楼层

  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>

  4. #pragma semicolon 1

  5. new bool:g_bPlayerInvisible[33], bool:g_bWaterInvisible[33];
  6. new bool:g_bWaterEntity[1385], bool:g_bWaterFound;

  7. new g_iSpectatedId[33];

  8. public plugin_init( )
  9. {
  10.         register_plugin( "Invis", "1.2b", "SchlumPF");
  11.        
  12.         register_clcmd( "say /invis", "menuInvisDisplay" );
  13.         register_menucmd( register_menuid( "\rInvisibility - SchlumPF^n^n" ), 1023, "menuInvisAction" );
  14.        
  15.         register_forward( FM_PlayerPreThink, "fwdPlayerPreThink_Pre", 0 );
  16.         register_forward( FM_AddToFullPack, "fwdAddToFullPack_Pre", 0 );
  17.        
  18.         RegisterHam( Ham_Spawn, "player", "hamSpawnPlayer_Post", 1 );
  19. }

  20. public plugin_cfg( )
  21. {
  22.         // find all water entitys to make AddToFullPack use less cpu
  23.         new ent = engfunc( EngFunc_FindEntityByString, -1, "classname", "func_water" );
  24.         while( ent > 0 )
  25.         {
  26.                 if( !g_bWaterFound )
  27.                         g_bWaterFound = true;

  28.                 g_bWaterEntity[ent] = true;
  29.                
  30.                 ent = engfunc( EngFunc_FindEntityByString, ent, "classname", "func_water" );
  31.         }
  32. }

  33. public fwdPlayerPreThink_Pre( plr )
  34. {
  35.         if( !is_user_alive( plr ) )
  36.         {
  37.                 g_iSpectatedId[plr] = pev( plr, pev_iuser2 );
  38.         }
  39. }

  40. public fwdAddToFullPack_Pre( es_handle, e, ent, host, hostflags, player, pset )
  41. {
  42.         if( player )
  43.         {
  44.                 if( g_bPlayerInvisible[host] && host != ent )
  45.                 {
  46.                         if( ent != g_iSpectatedId[host] )
  47.                         {
  48.                                 return FMRES_SUPERCEDE;
  49.                         }
  50.                 }
  51.         }
  52.         else if( g_bWaterInvisible[host] )
  53.         {
  54.                 if( g_bWaterEntity[ent] )
  55.                 {
  56.                         return FMRES_SUPERCEDE;
  57.                 }
  58.         }
  59.        
  60.         return FMRES_IGNORED;
  61. }

  62. public hamSpawnPlayer_Post( plr )
  63.         g_iSpectatedId[plr] = 0;

  64. public menuInvisDisplay( plr )
  65. {
  66.         static menu[2048];
  67.         new keys = ( 1<<0 | 1<<1 | 1<<9 );
  68.        
  69.         static player[3];
  70.         format( player, sizeof player - 1, "%s", g_bPlayerInvisible[plr] ? "\d" : "\w" );
  71.        
  72.         new len = format( menu, sizeof menu - 1, "\rInvisibility - SchlumPF^n^n" );
  73.        
  74.         len += format( menu[len], sizeof menu - len, "\r01. %sPlayers^n", player );

  75.         if( g_bWaterFound )
  76.         {
  77.                 static water[3];
  78.                 format( water, sizeof water - 1, "%s", g_bWaterInvisible[plr] ? "\d" : "\w" );

  79.                 len += format( menu[len], sizeof menu - len, "\r02. %sWater^n^n", water );
  80.         }
  81.         else
  82.                 len += format( menu[len], sizeof menu - len, "\d02. Water^n^n" );

  83.         len += format( menu[len], sizeof menu - len, "\r00. \wExit" );
  84.        
  85.         show_menu( plr, keys, menu, -1 );
  86.                
  87.         return PLUGIN_HANDLED;
  88. }

  89. public menuInvisAction( plr, key )
  90. {
  91.         switch( key )
  92.         {
  93.                 case 0:
  94.                 {
  95.                         if( g_bPlayerInvisible[plr] )
  96.                         {
  97.                                 g_bPlayerInvisible[plr] = false;
  98.                                 fnGreenChat( plr, "[XJ] All players are now visible." );
  99.                         }
  100.                         else
  101.                         {
  102.                                 g_bPlayerInvisible[plr] = true;
  103.                                 fnGreenChat( plr, "[XJ] All players are now invisible." );
  104.                         }
  105.                        
  106.                         menuInvisDisplay( plr );
  107.                 }
  108.                 case 1:
  109.                 {
  110.                         if( g_bWaterFound )
  111.                         {
  112.                                 if( g_bWaterInvisible[plr] )
  113.                                 {
  114.                                         g_bWaterInvisible[plr] = false;
  115.                                         fnGreenChat( plr, "[XJ] Water is now visible." );
  116.                                 }
  117.                                 else
  118.                                 {
  119.                                         g_bWaterInvisible[plr] = true;
  120.                                         fnGreenChat( plr, "[XJ] Water is now invisible." );
  121.                                 }
  122.                         }
  123.                         else
  124.                                 fnGreenChat( plr, "[XJ] There is no water which can become invisible." );
  125.        
  126.                         menuInvisDisplay( plr );
  127.                 }
  128.                 case 9: show_menu( plr, 0, "" );
  129.         }
  130.        
  131.         return PLUGIN_HANDLED;
  132. }

  133. public client_connect( plr )
  134. {
  135.         g_bPlayerInvisible[plr] = false;
  136.         g_bWaterInvisible[plr] = false;
  137.         g_iSpectatedId[plr] = 0;
  138. }


  139. // by fatalis
  140. fnGreenChat( plr, const message[], {Float,Sql,Result,_}:... )
  141. {
  142.         static max_players, svc_saytext;
  143.         if( !max_players )
  144.                 max_players = get_maxplayers( );
  145.         if( !svc_saytext )
  146.                 svc_saytext = get_user_msgid( "SayText" );
  147.        
  148.         static msg[192];
  149.         msg[0] = 0x04;
  150.        
  151.         vformat( msg[1], sizeof msg - 2, message, 3 );
  152.        
  153.         if( plr > 0 && plr <= max_players )
  154.         {
  155.                 message_begin( MSG_ONE, svc_saytext, { 0, 0, 0 }, plr );
  156.                 write_byte( plr );
  157.                 write_string( msg );
  158.                 message_end( );
  159.         }
  160.         else if( plr == 0 )
  161.         {
  162.                 for( new i = 1 ; i <= max_players ; i++ )
  163.                 {
  164.                         if( is_user_connected( i ) )
  165.                         {
  166.                                 message_begin( MSG_ONE, svc_saytext, { 0, 0, 0 }, i );
  167.                                 write_byte( i );
  168.                                 write_string( msg );
  169.                                 message_end( );
  170.                         }
  171.                 }
  172.         }
  173.        
  174.         return 1;
  175. }

复制代码

该用户从未签到

发表于 2010-4-11 16:07:10 | 显示全部楼层
:dizzy::dizzy::dizzy::dizzy::dizzy::dizzy::dizzy:

该用户从未签到

 楼主| 发表于 2010-4-11 16:30:44 | 显示全部楼层
感謝 可以用的.. THX

该用户从未签到

发表于 2010-4-11 17:14:55 | 显示全部楼层
本人已经放弃写插件

该用户从未签到

发表于 2010-4-11 17:20:24 | 显示全部楼层
很迷糊的说

该用户从未签到

发表于 2010-4-11 19:21:12 | 显示全部楼层
看见插件就迷糊
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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