I got the following code that I was making but I got a question, how to do that when a entire team is dead and without more lifes automatically give a win to the enemy team and then go to the next round?
PHP:
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <reapi>
new const NAME[] = "Last team standing"
new const VERSION[] = "1.0"
new g_iLives[33];
new g_iMaxPlayers, bool:g_bRoundEnding;
public plugin_init( )
{
register_plugin( NAME, VERSION );
register_event( "HLTV", "Event_HLTV", "a", "1=0", "2=0" );
register_logevent( "LogEvent_Round_End", 2, "1=Round_End" )
EnableHookChain(RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn_Post", true));
RegisterHookChain(RG_CSGameRules_DeathNotice, "CSGameRules_DeathNotice", .post = true)
g_iMaxPlayers = get_maxplayers( );
}
public displayMessage(id)
{
new const scoreT = get_gamerules_int("CHalfLifeMultiplay", "m_iNumTerroristWins");
new const scoreCT = get_gamerules_int("CHalfLifeMultiplay", "m_iNumCTWins");
if( is_user_connected( id ) )
set_dhudmessage(0, 204, 0, 0.02, 0.2, 0, 0.1, 1.0, 0.1, 0.1)
show_dhudmessage(0, "CT: %d | TT: %d | Lifes: %d/3", scoreCT, scoreT, g_iLives[ id ])
}
public Event_HLTV( )
{
g_bRoundEnding = false
for( new id = 1; id <= g_iMaxPlayers; id++ )
{
if( is_user_alive( id ) )
g_iLives[ id ] = 3;
}
}
public CBasePlayer_Spawn_Post(id)
{
if( is_user_alive( id ) )
remove_task(id)
}
public CSGameRules_DeathNotice(victim, attacker, shouldgib)
{
if(!g_bRoundEnding)
set_task( 1.5, "task_Spawn", victim );
}
public client_disconnected(id)
{
remove_task(id)
}
public LogEvent_Round_End()
{
g_bRoundEnding = true
}
public task_Spawn( id )
{
if( g_iLives[ id ] > 0 )
{
ExecuteHamB( Ham_CS_RoundRespawn, id );
chatcolor( id, "Now you have !g%d!y lifes", g_iLives[ id ]);
g_iLives[ id ]--;
}
else
chatcolor( id, "You wont respawn because you have 0 lifes remaining" );
}
stock chatcolor( 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();
}