AMX MOD X
Среда, 23.09.2020, 20:26:31



Приветствую Вас Гость | RSS
[ Главная ] [ Помогите перделать плагин - AMX Mod X Форум ] [ Регистрация ] [ Вход ]
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]

Вниманию участников! Данный форум теперь является архивом и вскором времени здесь нельзя будет создавать новых тем! Просьба всем для общения и создания новых тем перейти на наш новый форум: http://amxmodx.su/

  • Страница 1 из 1
  • 1
Модератор форума: slogic, AlMod  
AMX Mod X Форум » Скриптинг » Помощь по скриптингу » Помогите перделать плагин (ключение и выключение кода)
Помогите перделать плагин
SiFonДата: Суббота, 18.07.2009, 12:57:56 | Сообщение # 1
Рядовой
Группа: Пользователи
Сообщений: 1
Репутация: 0
Статус: Не в сети
Всем прив,нужно функцией p_BlockEnd = register_cvar( "reb_enable", "0") вырубить код, см. ниже,чуть ниже весь плагин

public removeit()
{
new fhosr = find_ent_by_class(-1, "func_hostage_rescue")
while(fhosr > g_iMaxPlayers)
{
entity_set_int(fhosr, EV_INT_flags, FL_KILLME)
fhosr = find_ent_by_class(fhosr, "func_hostage_rescue")
}
new doneonce = 0
new fbombt = find_ent_by_class(-1, "func_bomb_target")
while(fbombt > g_iMaxPlayers)
{
entity_set_int(fbombt, EV_INT_flags, FL_KILLME)
doneonce = 1
fbombt = find_ent_by_class(fbombt, "func_bomb_target")
}
if(doneonce == 1)server_cmd("sv_restartround 1")
new ibombt = find_ent_by_class(-1, "info_bomb_target")
while(ibombt > g_iMaxPlayers)
{
entity_set_int(ibombt, EV_INT_flags, FL_KILLME)
ibombt = find_ent_by_class(ibombt, "info_bomb_target")
}
new fescape = find_ent_by_class(-1, "func_escapezone")
while(fescape > g_iMaxPlayers)
{
entity_set_int(fescape, EV_INT_flags, FL_KILLME)
fescape = find_ent_by_class(fescape, "func_escapezone")
}
new fvips = find_ent_by_class(-1, "func_vip_safteyzone")
while(fvips > g_iMaxPlayers)
{
entity_set_int(fvips, EV_INT_flags, FL_KILLME)
fvips = find_ent_by_class(fvips, "func_vip_safteyzone")
}
new fvipst = find_ent_by_class(-1, "func_vip_start")
while(fvipst > g_iMaxPlayers)
{
entity_set_int(fvipst, EV_INT_flags, FL_KILLME)
fvipst = find_ent_by_class(fvipst, "func_vip_start")
}
}

public nohos()
{
new iHos = find_ent_by_class(-1, "hostage_entity")
while(iHos > g_iMaxPlayers)
{
entity_set_int(iHos, EV_INT_flags, FL_KILLME)
iHos = find_ent_by_class(iHos, "hostage_entity")
}
new jHos = find_ent_by_class(-1, "monster_scientist")
while(iHos > g_iMaxPlayers)
{
entity_set_int(jHos, EV_INT_flags, FL_KILLME)
iHos = find_ent_by_class(jHos, "monster_scientist")
}
}

Code

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

// Some constants you may want to change

const BOT_NUM = 2;    // If you, for some reason, want more bots.
// Change this and don't forget to add reb_name3, reb_name4 and so on

// These are just the default botnames, they are only used if the cvar is not set! You don't need to change them!
// You do, however, have to add more to this list if you change BOT_NUM
new const DefaultNames[BOT_NUM][ ] = {
"Have Fun",
"Good Luck"
};

//----------------------------------------------------------------------------------------
// Do not change anything below this line if you don't know exactly what you are doing!
//----------------------------------------------------------------------------------------
new const PLUGIN[]  = "Round Block & No bomb/hostages";
new const VERSION[] = "1.1.070";
new const AUTHOR[]  = "Nextra";

new p_BlockEnd, p_BlockPlrMin, p_BlockPlrMax, p_FakeFull, p_FullKick, p_BlockName[BOT_NUM];

const TASK_BOTS = 666;

new g_BotID[BOT_NUM], bool:g_bFirstRound = true;

new g_iMaxPlayers;

public plugin_init( )
{
register_plugin( PLUGIN, VERSION, AUTHOR );
register_cvar( "reb_version", VERSION, FCVAR_SERVER|FCVAR_SPONLY );

register_logevent( "on_RoundEnd"    , 2, "1=Round_End" );
register_logevent( "on_RoundStart"    , 2, "1=Round_Start" );

register_message( get_user_msgid( "TeamInfo" ), "msg_TeamInfo"  );

p_BlockEnd  = register_cvar( "reb_enable",    "0"),
p_BlockPlrMax    = register_cvar( "reb_plrmax",    "8"),
p_BlockPlrMin    = register_cvar( "reb_plrmin",    "6"),
p_FakeFull  = register_cvar( "reb_fakefull","1"),
p_FullKick  = register_cvar( "reb_fullkick","1");

register_event("RoundTime", "nohos", "bc");
removeit()
nohos()

new szTmp[16];

for( new i = 0; i < BOT_NUM; i++ )
{
formatex( szTmp, charsmax(szTmp), "reb_name%i", i + 1 );

p_BlockName[i] = register_cvar( szTmp, "" );
}

g_iMaxPlayers   = get_maxplayers( );
}

public msg_TeamInfo( )
{
if( is_user_fakebot( get_msg_arg_int( 1 ) ) )
set_msg_arg_string( 2, "SPECTATOR" );
}

public on_RoundEnd( )
BOT_start( );

public on_RoundStart( )
{
if( g_bFirstRound )
{
g_bFirstRound = false;

if( get_pcvar_num( p_FakeFull ) && get_pcvar_num( p_BlockEnd ) )
{
if( !get_playersnum( 1 ) )
set_task( 1.0, "BOT_create", TASK_BOTS );
}
}
else if( BOT_num( ) )
BOT_hide( );
}

public BOT_create( )
{
new BotName[32], BotID, firstNotValid = -1, i;

for( i = 0; i < BOT_NUM; i++ )
{
if( !IsValidPlayer( g_BotID[i] ) )
{
firstNotValid = i;
break;
}
}

if( firstNotValid == -1 )
return;

get_pcvar_string( p_BlockName[firstNotValid], BotName, charsmax(BotName) );
trim( BotName );

if( equali( BotName, "" ) )
copy( BotName, charsmax(BotName), DefaultNames[firstNotValid] );

trim( BotName );

if( equali( BotName, "" ) )
return;

new szName[32], szTmp[32], bool:bContinue = true, bool:bFound, iFound;

copy( szTmp, charsmax(szTmp), BotName );

while( bContinue )
{
for( i = 1; i <= g_iMaxPlayers; i++ )
{
if( is_user_connected( i ) )
{
get_user_name( i, szName, charsmax(szName) );

if( equali( szTmp, szName ) )
{
formatex( szTmp, charsmax(szTmp), "%s(%d)", BotName, ++iFound );

bFound = true;

break;
}
}
}

if( !bFound )
bContinue = false;

bFound = false;
}

if( iFound )
copy( BotName, charsmax(BotName), szTmp );

BotID = engfunc( EngFunc_CreateFakeClient, BotName );

if( !IsValidPlayer( BotID ) )
return;

g_BotID[firstNotValid] = BotID;

new ptr[128];
engfunc( EngFunc_FreeEntPrivateData, BotID );
dllfunc( DLLFunc_ClientConnect, BotID, BotName, "127.0.0.1", ptr );

if( !is_user_connected( BotID ) )
{
g_BotID[firstNotValid] = 0;
return;
}

dllfunc( DLLFunc_ClientPutInServer, BotID );
set_pev( BotID, pev_spawnflags, pev( BotID, pev_spawnflags ) | FL_FAKECLIENT );
set_pev( BotID, pev_flags, pev( BotID, pev_flags ) | FL_FAKECLIENT );
cs_set_user_team( BotID, BOT_num( ) % 2 ? CS_TEAM_T : CS_TEAM_CT );

if( !is_user_alive( BotID ) )
ExecuteHamB( Ham_CS_RoundRespawn, BotID );

if( BOT_num( ) < BOT_NUM )
{
remove_task( TASK_BOTS );
set_task( 0.1, "BOT_start", TASK_BOTS );
}

BOT_hide( firstNotValid );
}

BOT_hide( which = BOT_NUM )
{
new BotID;

switch( which )
{
case BOT_NUM:
{
for( new i = 0; i < BOT_NUM; i++ )
{
BotID = g_BotID[i];

if( IsValidPlayer( BotID ) )
{
set_pev( BotID, pev_effects, pev( BotID, pev_effects ) | EF_NODRAW );
set_pev( BotID, pev_solid, SOLID_NOT );
set_pev( BotID, pev_takedamage, DAMAGE_NO );
set_pev( BotID, pev_origin, Float:{9999.0,9999.0,9999.0} );
}
}
}
default:
{
BotID = g_BotID[which];

if( IsValidPlayer( BotID ) )
{
set_pev( BotID, pev_effects, pev( BotID, pev_effects ) | EF_NODRAW );
set_pev( BotID, pev_solid, SOLID_NOT );
set_pev( BotID, pev_takedamage, DAMAGE_NO );
set_pev( BotID, pev_origin, Float:{9999.0,9999.0,9999.0} );
}
}
}
}

BOT_kick( iAmt = BOT_NUM )
{
if( !BOT_num( ) )
return;

new BotID, iKicked;

for( new i = BOT_NUM - 1; i >= 0; i-- )
{
if( i + 1 > g_iMaxPlayers )
continue;

BotID = g_BotID[i];

if( IsValidPlayer( BotID ) )
{
server_cmd( "kick #%d", get_user_userid( BotID ) );
server_exec( );

if( ++iKicked >= iAmt )
break;
}
}
}

public BOT_start( )
{
new iBotNum = BOT_num( );

if( !get_pcvar_num( p_BlockEnd ) )
{
if( iBotNum )
BOT_kick( );

return;
}

new iPlayers = get_playersnum( 1 );

if( iBotNum )
{
if( iPlayers == g_iMaxPlayers - 1 )
{
if( get_pcvar_num( p_FullKick ) )
return;
}
else if( iPlayers >= g_iMaxPlayers )
{
if( get_pcvar_num( p_FullKick ) )
BOT_kick( 1 );

return;
}
else if( iPlayers - iBotNum == 0 )
{
if( !get_pcvar_num( p_FakeFull ) )
{
BOT_kick( );
return;
}
}
}
else if( !iPlayers )
return;

new iPlayerNum;

for( new i = 1; i <= g_iMaxPlayers; i++ )
{
if( !is_user_connected( i ) || is_user_fakebot( i ) )
continue;

switch( cs_get_user_team( i ) )
{
case CS_TEAM_T, CS_TEAM_CT:    iPlayerNum++;
}
}

if( iBotNum && iPlayerNum >= get_pcvar_num( p_BlockPlrMax ) )
BOT_kick( );
else if( iBotNum < BOT_NUM && iPlayerNum < get_pcvar_num( p_BlockPlrMin ) )
BOT_create( );
}

BOT_num( )
{
new iNum;

for( new i = 0; i < BOT_NUM; i++ )
{
if( IsValidPlayer( g_BotID[i] ) )
iNum++;
}

return iNum;
}

public client_putinserver( id )
set_task( 1.0, "BOT_start", TASK_BOTS );

public client_disconnect( id )
{
for( new i = 0; i < BOT_NUM; i++ )
{
if( is_user_fakebot( id, i ) )
{
g_BotID[i] = 0;

break;
}
}

set_task( 1.0, "BOT_start", TASK_BOTS );
}

bool:IsValidPlayer( const id )
return ( 1 <= id <= g_iMaxPlayers ) ? true : false;

bool:is_user_fakebot( const id, which = BOT_NUM )
{
switch( which )
{
case BOT_NUM:
{
for( new i = 0; i < BOT_NUM; i++ )
{
if( id == g_BotID[i] )
return true;
}
}
default: return ( id == g_BotID[which] ) ? true : false;
}

return false;
}

public removeit()
{
new fhosr = find_ent_by_class(-1, "func_hostage_rescue")
while(fhosr > g_iMaxPlayers)
{
entity_set_int(fhosr, EV_INT_flags, FL_KILLME)
fhosr = find_ent_by_class(fhosr, "func_hostage_rescue")
}
new doneonce = 0
new fbombt = find_ent_by_class(-1, "func_bomb_target")
while(fbombt > g_iMaxPlayers)
{
entity_set_int(fbombt, EV_INT_flags, FL_KILLME)
doneonce = 1
fbombt = find_ent_by_class(fbombt, "func_bomb_target")
}
if(doneonce == 1)server_cmd("sv_restartround 1")
new ibombt = find_ent_by_class(-1, "info_bomb_target")
while(ibombt > g_iMaxPlayers)
{
entity_set_int(ibombt, EV_INT_flags, FL_KILLME)
ibombt = find_ent_by_class(ibombt, "info_bomb_target")
}
new fescape = find_ent_by_class(-1, "func_escapezone")
while(fescape > g_iMaxPlayers)
{
entity_set_int(fescape, EV_INT_flags, FL_KILLME)
fescape = find_ent_by_class(fescape, "func_escapezone")
}
new fvips = find_ent_by_class(-1, "func_vip_safteyzone")
while(fvips > g_iMaxPlayers)
{
entity_set_int(fvips, EV_INT_flags, FL_KILLME)
fvips = find_ent_by_class(fvips, "func_vip_safteyzone")
}
new fvipst = find_ent_by_class(-1, "func_vip_start")
while(fvipst > g_iMaxPlayers)
{
entity_set_int(fvipst, EV_INT_flags, FL_KILLME)
fvipst = find_ent_by_class(fvipst, "func_vip_start")
}
}

public nohos()
{
new iHos = find_ent_by_class(-1, "hostage_entity")
while(iHos > g_iMaxPlayers)
{
entity_set_int(iHos, EV_INT_flags, FL_KILLME)
iHos = find_ent_by_class(iHos, "hostage_entity")
}
new jHos = find_ent_by_class(-1, "monster_scientist")
while(iHos > g_iMaxPlayers)
{
entity_set_int(jHos, EV_INT_flags, FL_KILLME)
iHos = find_ent_by_class(jHos, "monster_scientist")
}
}


Сообщение отредактировал SiFon - Суббота, 18.07.2009, 15:08:12
 
se7hДата: Пятница, 24.07.2009, 17:35:34 | Сообщение # 2
Генерал-майор
Группа: Cупер-модеры
Сообщений: 424
Репутация: 13
Статус: Не в сети
в начале каждой функции делаешь проверку:

Code
if ( get_pcvar_num(p_BlockEnd) )     // если p_BlockEnd > 0
    return       // блокируешь выполнение функции


 
AMX Mod X Форум » Скриптинг » Помощь по скриптингу » Помогите перделать плагин (ключение и выключение кода)
  • Страница 1 из 1
  • 1
Поиск:

AMX Mod X Russian Community © 2006-2020