Пользователь
- Сообщения
- 23
- Реакции
- 3
Доброго времени суток, есть плагин который убирает с карт воду и игроков, для уменьшение лагов.
Может быть есть подобный реализованный на reapi?
Может быть есть подобный реализованный на reapi?
Код:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <color_print>
#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( "FixFPS", "1.0", "Nagan-Cs");
register_clcmd( "say /fix", "menuInvisDisplay" );
register_clcmd( "say fix", "menuInvisDisplay" );
register_menucmd( register_menuid( "\dFix\rFPS\w Меню^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, "\dFix\rFPS\w Меню^n^n" );
len += format( menu[len], sizeof menu - len, "\r1. %sИгроки^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, "\r2. %sВода^n^n", water );
}
else
len += format( menu[len], sizeof menu - len, "\d2. Вода^n^n" );
len += format( menu[len], sizeof menu - len, "\r0. \wВыход" );
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, "[Deathrun] Все игроки вновь стали видны." );
}
else
{
g_bPlayerInvisible[plr] = true;
fnGreenChat( plr, "[Deathrun] Все звуки и модели убраны." );
}
menuInvisDisplay( plr );
}
case 1:
{
if( g_bWaterFound )
{
if( g_bWaterInvisible[plr] )
{
g_bWaterInvisible[plr] = false;
fnGreenChat( plr, "[Deathrun] Вода вновь видна." );
}
else
{
g_bWaterInvisible[plr] = true;
fnGreenChat( plr, "[Deathrun] Вода убрана." );
}
}
else
fnGreenChat( plr, "[Deathrun] На этой корте нет воды." );
menuInvisDisplay( plr );
}
case 9: show_menu( plr, 0, "" );
}
return PLUGIN_HANDLED;
}
public client_connect( plr )
{
g_bPlayerInvisible[plr] = false;
g_bWaterInvisible[plr] = false;
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;
}