/* =================================================
- CHANGELOG:
- 1.0: Creación del mod.
- 1.1: Se corrigieron bugs.
- 1.2: Se corrigieron bugs.
Se agregó cvar para la vida de los tribales.
Se mejoraron algunas funciones.
- 1.3: Se cambió el método para bloquear el c4.
Se bloqueó el comando 'kill'.
Se corrigieron bugs.
- 1.4: Se agregaron bitsums.
Se agregaron cvars para:
- Activar/Desactivar el mod.
- Mínimo de players que se necesita para que funcione el mod.
- Cambiar el tiempo de conteo.
Se corrigieron bugs.
- 1.5: Se corrigieron bugs.
Se mejorarn algunas funciones.
Se agregó:
- Si uno de los tribales se desconecta se elige uno nuevo.
- Si uno de los tribales se suicida, mata al team entero.
Se modificaron los hud's.
- 1.6: Se mejoraron algunos códigos.
================================================= */
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
new const szPlugin[ ][ ] = { "Tribal Mod", "1.6", "Sky^^" };
new const szPrefix[ ] = "^3[ - ]^1";
/* ================================================= */
new g_randomUsers[ 33 ][ 2 ];
new g_userSelected;
new g_hudCount, g_timeCount;
new g_hudTeam, g_hudSelected;
new g_maxPlayers;
new cvar_modEnabled, cvar_minPlayers, cvar_timeCount;
new cvar_healthUsers, cvar_armorUsers;
new g_fwSpawn;
new g_userConnected, g_userAlive;
#define TASK_COUNT 8965
#define TEAM_CT "CT"
#define TEAM_TT "TERRORIST"
#define BitTrue(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) )
#define IsBit(%1,%2) ( %1 & ( 1 << ( %2 & 31 ) ) )
#define BitFalse(%1,%2) ( %1 &= ~ ( 1 << ( %2 & 31 ) ) )
new const REMOVE_OBJETIVES_ENTS[ ][ ] = { "func_bomb_target", "info_bomb_target", "info_vip_start",
"func_vip_safetyzone", "func_escapezone", "hostage_entity",
"monster_scientist", "func_hostage_rescue", "info_hostage_rescue",
"env_fog", "env_rain", "env_snow", "item_longjump", "func_vehicle", "weapon_c4"
};
/* ================================================= */
public plugin_init( ) {
register_plugin( szPlugin[ 0 ], szPlugin[ 1 ], szPlugin[ 2 ] );
cvar_modEnabled = register_cvar( "amx_mod_enable", "1" );
cvar_minPlayers = register_cvar( "amx_minimum_players", "4" );
cvar_timeCount = register_cvar( "amx_time_count", "10" );
cvar_healthUsers = register_cvar( "amx_health_tribals", "200" );
cvar_armorUsers = register_cvar( "amx_armor_tribals", "150" );
register_event( "HLTV", "event__RoundStart", "a", "1=0", "2=0" );
register_logevent( "event__RoundEnd", 2, "1=Round_End" );
register_event( "SendAudio", "event__WinTerrorist", "a", "2&%!MRAD_terwin" );
register_event( "SendAudio", "event__WinPolice", "a", "2&%!MRAD_ctwin" );
RegisterHam( Ham_Spawn, "player", "fw__PlayerSpawn" );
RegisterHam( Ham_Killed, "player", "fw__PlayerKilled", 1 )
unregister_forward( FM_Spawn, g_fwSpawn );
register_message( get_user_msgid( "StatusIcon" ), "message__StatusIcon" );
g_hudCount = CreateHudSyncObj( );
g_hudTeam = CreateHudSyncObj( );
g_hudSelected = CreateHudSyncObj( );
g_maxPlayers = get_maxplayers( );
set_task( 1.0, "plugin_cfg" );
}
public plugin_precache( ) g_fwSpawn = register_forward( FM_Spawn, "fw__Spawn" );
public plugin_cfg( ) {
set_cvar_num( "mp_autoteambalance", 1 );
set_cvar_num( "mp_roundtime", 8 );
}
public client_putinserver( id ) BitTrue( g_userConnected, id );
public client_disconnect( id ) {
BitFalse( g_userConnected, id );
BitFalse( g_userAlive, id );
if( g_randomUsers[ id ][ 0 ] && get__TribalsCT( ) >= 1 ) {
g_randomUsers[ id ][ 0 ] = false;
select__newUsers( 1 );
}
else if( g_randomUsers[ id ][ 1 ] && get__TribalsT( ) >= 1 ) {
g_randomUsers[ id ][ 1 ] = false;
select__newUsers( 2 );
}
}
/* ================================================= */
public event__RoundStart( ) {
if( !get_pcvar_num( cvar_modEnabled ) ) return PLUGIN_HANDLED;
if( get_playersnum( ) < get_pcvar_num( cvar_minPlayers ) ) {
cc( 0, "%s Se necesitan mÃnimo^4 %d players^1 para iniciar el modo.", szPrefix, get_pcvar_num( cvar_minPlayers ) );
return PLUGIN_HANDLED;
}
for( new i = 1; i <= g_maxPlayers; i++ ) {
if( !IsBit( g_userConnected, i ) ) continue;
set_user_rendering( i );
g_randomUsers[ i ][ 0 ] = false;
g_randomUsers[ i ][ 1 ] = false;
}
g_userSelected = false;
remove_task( TASK_COUNT );
g_timeCount = get_pcvar_num( cvar_timeCount );
set_task( 1.0, "start__Count", TASK_COUNT, _, _, "b" );
set_cvar_num( "mp_freezetime", 12 );
return PLUGIN_HANDLED;
}
public event__RoundEnd( ) {
if( !get_pcvar_num( cvar_modEnabled ) ) return;
for( new i = 1; i <= g_maxPlayers; i++ ) {
if( !IsBit( g_userConnected, i ) ) continue;
set_user_rendering( i );
}
}
public event__WinTerrorist( ) {
if( !get_pcvar_num( cvar_modEnabled ) ) return;
set_hudmessage( 255, 0, 0, -1.0, 0.28, 2, 0.02, 2.5, 0.01, 0.1, 10 );
ShowSyncHudMsg( 0, g_hudTeam, "¡ GANARON LOS TERRORISTAS DEBIDO A QUE MURIÓ EL TRIBAL POLICÃA !" );
}
public event__WinPolice( ) {
if( !get_pcvar_num( cvar_modEnabled ) ) return;
set_hudmessage( 0, 0, 255, -1.0, 0.28, 2, 0.02, 2.5, 0.01, 0.1, 10 );
ShowSyncHudMsg( 0, g_hudTeam, "¡ GANARON LOS POLICÃAS DEBIDO A QUE MURIÓ EL TRIBAL TERRORISTA !" );
}
public fw__PlayerSpawn( id ) {
if( !get_pcvar_num( cvar_modEnabled ) ) return;
if( IsBit( g_userConnected, id ) && is_user_alive( id ) )
BitTrue( g_userAlive, id );
}
public fw__PlayerKilled( victim, attacker, shouldgib ) {
if( !get_pcvar_num( cvar_modEnabled ) ) return;
static diedAlone; diedAlone = ( victim == attacker || !IsBit( g_userConnected, attacker ) ) ? 1 : 0
if( diedAlone ) {
if( g_randomUsers[ victim ][ 0 ] ) KillTeam( TEAM_CT );
else if( g_randomUsers[ victim ][ 1 ] ) KillTeam( TEAM_TT );
}
if( g_randomUsers[ victim ][ 0 ] ) KillTeam( TEAM_CT );
else if( g_randomUsers[ victim ][ 1 ] ) KillTeam( TEAM_TT );
}
public client_kill( id ) return PLUGIN_HANDLED;
public fw__Spawn( entity ) {
if( !pev_valid( entity ) ) return FMRES_IGNORED;
new classname[ 32 ];
pev( entity, pev_classname, classname, sizeof classname - 1 );
for( new i = 0; i < sizeof REMOVE_OBJETIVES_ENTS; ++i ) {
if ( equal( classname, REMOVE_OBJETIVES_ENTS[ i ] ) ) {
engfunc( EngFunc_RemoveEntity, entity );
return FMRES_SUPERCEDE;
}
}
return FMRES_IGNORED;
}
public message__StatusIcon( msg_id, msg_dest, id ) {
if( !g_timeCount && get_pcvar_num( cvar_modEnabled ) == 1 ) {
static szIcon[ 8 ];
get_msg_arg_string( 2, szIcon, charsmax( szIcon ) );
if( equal( szIcon, "buyzone" ) && get_msg_arg_int( 1 ) ) {
set_pdata_int( id, 235, get_pdata_int( id, 235 ) & ~(1<<0) );
return PLUGIN_HANDLED;
}
}
return PLUGIN_CONTINUE;
}
/* ================================================= */
public start__Count( ) {
set_hudmessage( random_num( 0, 255 ), random_num( 0, 255 ), random_num( 0, 255 ), -1.0, 0.28, 2, 0.02, 2.0, 0.01, 0.1, 10 );
ShowSyncHudMsg( 0, g_hudCount, "TIEMPO DE PREPARACIÓN: %i^nLUEGO DEL CONTEO SE DESACTIVARà EL BUY^n¡ SUERTE A AMBOS EQUIPOS !", g_timeCount );
g_timeCount--;
if( !g_userSelected ) set_task( 0.3, "start__Mod" );
if( !g_timeCount )
remove_task( TASK_COUNT );
}
public start__Mod( ) {
g_userSelected = true;
new szNameOne[ 32 ], szNameTwo[ 32 ];
new szUsersOne, szUsersTwo;
szUsersOne = choose__Users( "ae", TEAM_CT );
szUsersTwo = choose__Users( "ae", TEAM_TT );
get_user_name( szUsersOne, szNameOne, charsmax( szNameOne ) );
get_user_name( szUsersTwo, szNameTwo, charsmax( szNameTwo ) );
g_randomUsers[ szUsersOne ][ 0 ] = true;
g_randomUsers[ szUsersTwo ][ 1 ] = true;
set_user_health( szUsersOne, get_pcvar_num( cvar_healthUsers ) );
set_user_armor( szUsersOne, get_pcvar_num( cvar_armorUsers ) );
set_rendering( szUsersOne, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 50 );
set_user_health( szUsersTwo, get_pcvar_num( cvar_healthUsers ) );
set_user_armor( szUsersTwo, get_pcvar_num( cvar_armorUsers ) );
set_rendering( szUsersTwo, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 50 );
set_hudmessage( 43, 255, 0, -1.0, -1.0, 2, 0.02, 2.0, 0.01, 0.1, 10 );
ShowSyncHudMsg( 0, g_hudSelected, "TRIBAL TERRORISTA: %s | TRIBAL POLICÃA: %s^n¡ PROTEJAN A SUS TRIBALES O MORIRÃN !", szNameTwo, szNameOne );
}
public select__newUsers( type ) {
if( type == 1 ) {
new szUsersNew = choose__Users( "ae", TEAM_CT );
new szNameNew[ 32 ]; get_user_name( szUsersNew, szNameNew, charsmax( szNameNew ) );
g_randomUsers[ szUsersNew ][ 0 ] = true;
set_user_health( szUsersNew, get_pcvar_num( cvar_healthUsers ) );
set_user_armor( szUsersNew, get_pcvar_num( cvar_armorUsers ) );
set_rendering( szUsersNew, kRenderFxGlowShell, 0, 0, 255, kRenderNormal, 50 );
cc( 0, "%s El Tribal Policia se desconectó,^4 %s^1 es el nuevo Tribal PolicÃa.", szPrefix, szNameNew );
}
if( type == 2 ) {
new szUsersNewT = choose__Users( "ae", TEAM_TT );
new szNameNewT[ 32 ]; get_user_name( szUsersNewT, szNameNewT, charsmax( szNameNewT ) );
g_randomUsers[ szUsersNewT ][ 1 ] = true;
set_user_health( szUsersNewT, get_pcvar_num( cvar_healthUsers ) );
set_user_armor( szUsersNewT, get_pcvar_num( cvar_armorUsers ) );
set_rendering( szUsersNewT, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 50 );
cc( 0, "%s El Tribal Terrorista se desconectó,^4 %s^1 es el nuevo Tribal Terrorista.", szPrefix, szNameNewT );
}
}
/* ================================================= */
stock cc( id, const input[ ], any:... ) {
static szMsg[ 191 ], msgSayText;
if( !msgSayText ) msgSayText = get_user_msgid( "SayText" );
vformat( szMsg, 190, input, 3 );
replace_all( szMsg, 190, "!g", "^4" );
replace_all( szMsg, 190, "!y", "^1" );
replace_all( szMsg, 190, "!team", "^3" );
message_begin( id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgSayText, .player = id );
write_byte( id ? id : 33 );
write_string( szMsg );
message_end( );
}
stock choose__Users( const Flags[ ]="", const Team[ ]="" ) {
static szPlayers[ 32 ], szNum;
get_players( szPlayers, szNum, Flags, Team );
return szPlayers[ random( szNum ) ]
}
KillTeam( const Team[ ] )
{
new Players[ 32 ], Pnum, i;
get_players( Players, Pnum, "ae", Team );
for( i = 0;i < Pnum;i++ ) user_silentkill( Players[ i ] );
}
get__TribalsT( ) {
new i, tt;
for( i = 1; i <= g_maxPlayers; ++i ) {
if( cs_get_user_team( i ) == CS_TEAM_T )
++tt;
}
return tt;
}
get__TribalsCT( ) {
new i, ct;
for( i = 1; i <= g_maxPlayers; ++i ) {
if( cs_get_user_team( i ) == CS_TEAM_CT )
++ct;
}
return ct;
}