/*
@author Rafal "DarkGL" Wiecek
@edit Tomek "mr_tnctproo" P.
@site www.darkgl.amxx.pl
*/
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
const maxPlayer = 32;
new bool:g_bPlayerInvisible[ maxPlayer + 1 ],
bool:g_bWaterInvisible[ maxPlayer + 1];
new Array: gWaterEntity;
new bHookVisible = 0;
public plugin_init( )
{
register_plugin( "Invis", "1.0", "DarkGL");
gWaterEntity = ArrayCreate( 1 , 1 );
register_clcmd( "say /invis", "menuInvisDisplay" );
register_clcmd( "say_team /invis" , "menuInvisDisplay" );
register_menucmd( register_menuid( "" ), ( 1<<0 | 1<<1 | 1<<9 ) , "MenuInvis" );
register_forward( FM_AddToFullPack, "fwdAddToFullPack_Pre" );
register_forward( FM_AddToFullPack, "fwdAddToFullPack_Post" , 1 );
register_forward( FM_CheckVisibility,"checkVisibility")
}
public plugin_cfg( )
{
new iEnt = engfunc( EngFunc_FindEntityByString, -1, "classname", "func_water" );
while( iEnt )
{
if( !pev_valid( iEnt ) )
{
}
ArrayPushCell( gWaterEntity , iEnt );
iEnt = engfunc( EngFunc_FindEntityByString, iEnt, "classname", "func_water" );
}
}
public checkVisibility(id,pset)
{
if( !pev_valid( id ) )
{
return FMRES_IGNORED;
}
if( !bHookVisible )
{
return FMRES_IGNORED;
}
bHookVisible = false;
forward_return( FMV_CELL , 0 );
return FMRES_SUPERCEDE;
}
public fwdAddToFullPack_Pre( es_handle, e, ent, host, hostflags, player, pset )
{
if( player )
{
if(is_user_alive(host) && g_bPlayerInvisible[host] && host != ent && is_user_alive(ent) )
{
bHookVisible = true;
}
}
}
public fwdAddToFullPack_Post( es_handle, e, ent, host, hostflags, player, pset )
{
if( is_user_alive( host ) && g_bWaterInvisible[host] && isEntWater( ent ) )
{
set_es( es_handle, ES_Effects, EF_NODRAW );
}
}
public menuInvisDisplay( plr )
{
static menu[ 512 ];
new len = 0;
len += format( menu[len], sizeof menu - len, "\r1. \wGracze: \y%s^n", g_bPlayerInvisible[plr] ? "Niewidoczni" : "Widoczni" );
len += format( menu[len], sizeof menu - len, "\r2. \wWoda: \y%s^n^n", ArraySize( gWaterEntity ) ? ( g_bWaterInvisible[plr] ? "Niewidoczna" : "Widoczna" ) : "Brak wody na mapie" );
len += format( menu[len], sizeof menu - len, "\r0. \wWyjscie" );
show_menu( plr, ( 1<<0 | 1<<1 | 1<<9 ), menu, -1 );
return PLUGIN_HANDLED;
}
public MenuInvis( plr, key, id )
{
switch( key )
{
case 0:
{
if(get_user_team(id) == 1){
g_bPlayerInvisible[plr] = !g_bPlayerInvisible[plr];
}
if(get_user_team(id) == 1){
g_bPlayerInvisible[plr] = !g_bPlayerInvisible[plr];
}
menuInvisDisplay( plr );
}
case 1:
{
if(get_user_team(id) == 1){
g_bWaterInvisible[plr] = !g_bWaterInvisible[plr];
}
if(get_user_team(id) == 1){
g_bWaterInvisible[plr] = !g_bWaterInvisible[plr];
}
menuInvisDisplay( plr );
}
default: show_menu( plr, 0, "" );
}
}
public client_connect( plr )
{
g_bPlayerInvisible[plr] = false;
g_bWaterInvisible[plr] = false;
}
bool: isEntWater( iEnt )
{
for( new iCurrent = 0 ; iCurrent < ArraySize( gWaterEntity ) ; iCurrent++ )
{
if( ArrayGetCell( gWaterEntity , iCurrent ) == iEnt )
{
return true;
}
}
return false;
}