Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <fakemeta>
- #include <hamsandwich>
- #pragma semicolon 1
- new bool:g_bPlayerInvisible[33], bool:g_bWaterInvisible[33];
- new bool:g_bWaterEntity[1385], bool:g_bWaterFound;
- new g_iSpectatedId[33];
- public plugin_init( )
- {
- register_plugin( "Invis", "1.3", "SchlumPF");
- register_clcmd( "say /invis", "menuInvisDisplay" );
- register_menucmd( register_menuid( "\rInvisibility - SchlumPF^n^n" ), 1023, "menuInvisAction" );
- register_forward( FM_PlayerPreThink, "fwdPlayerPreThink_Pre", 0 );
- register_forward( FM_AddToFullPack, "fwdAddToFullPack_Post", 1 );
- RegisterHam( Ham_Spawn, "player", "hamSpawnPlayer_Post", 1 );
- }
- public plugin_cfg( )
- {
- // find all water entitys to make AddToFullPack use less cpu
- new ent = engfunc( EngFunc_FindEntityByString, -1, "classname", "func_water" );
- while( ent > 0 )
- {
- if( !g_bWaterFound )
- g_bWaterFound = true;
- g_bWaterEntity[ent] = true;
- ent = engfunc( EngFunc_FindEntityByString, ent, "classname", "func_water" );
- }
- }
- public fwdPlayerPreThink_Pre( plr )
- {
- if( !is_user_alive( plr ) )
- {
- g_iSpectatedId[plr] = pev( plr, pev_iuser2 );
- }
- }
- public fwdAddToFullPack_Post( es_handle, e, ent, host, hostflags, player, pset )
- {
- if( player )
- {
- if( g_bPlayerInvisible[host] && host != ent )
- {
- if( ent != g_iSpectatedId[host] && get_user_team(ent) == 2)
- {
- set_es( es_handle, ES_Origin, { 999999999.0, 999999999.0, 999999999.0 } );
- set_es( es_handle, ES_RenderMode, kRenderTransAlpha );
- set_es( es_handle, ES_RenderAmt, 0 );
- return FMRES_SUPERCEDE;
- }
- }
- }
- else if( g_bWaterInvisible[host] )
- {
- if( g_bWaterEntity[ent] )
- {
- set_es( es_handle, ES_Effects, EF_NODRAW );
- return FMRES_SUPERCEDE;
- }
- }
- return FMRES_IGNORED;
- }
- public hamSpawnPlayer_Post( plr )
- g_iSpectatedId[plr] = 0;
- public menuInvisDisplay( plr )
- {
- static menu[2048];
- new keys = ( 1<<0 | 1<<1 | 1<<9 );
- static player[3];
- format( player, sizeof player - 1, "%s", g_bPlayerInvisible[plr] ? "\d" : "\w" );
- new len = format( menu, sizeof menu - 1, "\rInvisibility - SchlumPF^n^n" );
- len += format( menu[len], sizeof menu - len, "\r01. %sPlayers \r[DISABLED]^n", player );
- if( g_bWaterFound )
- {
- static water[3];
- format( water, sizeof water - 1, "%s", g_bWaterInvisible[plr] ? "\d" : "\w" );
- len += format( menu[len], sizeof menu - len, "\r02. %sWater^n^n", water );
- }
- else
- len += format( menu[len], sizeof menu - len, "\d02. Water^n^n" );
- len += format( menu[len], sizeof menu - len, "\r00. \wExit" );
- show_menu( plr, keys, menu, -1 );
- return PLUGIN_HANDLED;
- }
- public menuInvisAction( plr, key )
- {
- switch( key )
- {
- case 0:
- {
- /*if( g_bPlayerInvisible[plr] )
- {
- g_bPlayerInvisible[plr] = false;
- fnGreenChat( plr, "[XJ] All players are now visible." );
- }
- else
- {
- g_bPlayerInvisible[plr] = true;
- fnGreenChat( plr, "[XJ] All players are now invisible." );
- }
- menuInvisDisplay( plr );*/
- }
- case 1:
- {
- if( g_bWaterFound )
- {
- if( g_bWaterInvisible[plr] )
- {
- g_bWaterInvisible[plr] = false;
- fnGreenChat( plr, "[XJ] Water is now visible." );
- }
- else
- {
- g_bWaterInvisible[plr] = true;
- fnGreenChat( plr, "[XJ] Water is now invisible." );
- }
- }
- else
- fnGreenChat( plr, "[XJ] There is no water which can become invisible." );
- menuInvisDisplay( plr );
- }
- case 9: show_menu( plr, 0, "" );
- }
- return PLUGIN_HANDLED;
- }
- public client_connect( plr )
- {
- g_bPlayerInvisible[plr] = false;
- g_bWaterInvisible[plr] = true;
- g_iSpectatedId[plr] = 0;
- }
- // by fatalis
- fnGreenChat( plr, const message[], {Float,Sql,Result,_}:... )
- {
- static max_players, svc_saytext;
- if( !max_players )
- max_players = get_maxplayers( );
- if( !svc_saytext )
- svc_saytext = get_user_msgid( "SayText" );
- static msg[192];
- msg[0] = 0x04;
- vformat( msg[1], sizeof msg - 2, message, 3 );
- if( plr > 0 && plr <= max_players )
- {
- message_begin( MSG_ONE, svc_saytext, { 0, 0, 0 }, plr );
- write_byte( plr );
- write_string( msg );
- message_end( );
- }
- else if( plr == 0 )
- {
- for( new i = 1 ; i <= max_players ; i++ )
- {
- if( is_user_connected( i ) )
- {
- message_begin( MSG_ONE, svc_saytext, { 0, 0, 0 }, i );
- write_byte( i );
- write_string( msg );
- message_end( );
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement