AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Stock to detect when a team dies (https://forums.alliedmods.net/showthread.php?t=324332)

wicho 05-12-2020 22:05

Stock to detect when a team dies
 
Hello everyone, well as the title says does anyone have or could make a stock to detect when all the players of a team die? what i want to do is use the stock in an if to do something, an example:

PHP Code:

if(stock the terrorist team died)
{
         
//do something
}
else if(
stock the CT team died)
{
         
//do something


Thanks in advance...

Bugsy 05-12-2020 22:28

Re: Stock to detect when a team dies
 
You can easily hook when a team wins, if that solves your problem. The below will handle when all players die on a particular team.
PHP Code:


#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

public plugin_init() 
{
    
RegisterHamHam_Killed "player" "HamKilled_Post" true );
}

public 
HamKilled_PostiPlayer )
{
    new 
iPlayers32 ] , iNum CsTeams:csPlayerTeam;
    
    
csPlayerTeam cs_get_user_teamiPlayer );
    
get_playersiPlayers iNum "ae" , ( csPlayerTeam == CS_TEAM_T ) ? "TERRORIST" "CT" );
    
    if ( !
iNum )
    {
        
AllPlayersDeadcsPlayerTeam );
    }
}

public 
AllPlayersDeadCsTeams:csDeadTeam )
{
    
//All players on csDeadTeam are dead
    



wicho 05-12-2020 23:51

Re: Stock to detect when a team dies
 
thanks for your help but I use infinite round (from a module of dias called InfinityGame) so I need a stock that is called in an if to detect when a team is dead and finish the round, that's how I use it but sometimes it doesn't work and bug the round.

PHP Code:

public Check_Gameplay()
{
        if((
Get_PlayerCount(11) <= 0) && !pev_valid(g_TerroristBase)) // All terrorist are dead
        
{
                
Game_Ending(5.00CS_TEAM_CT)
 
                return
        }
        else if((
Get_PlayerCount(12) <= 0) && !pev_valid(g_CTBase)) // All CT are dead
        

                
Game_Ending(5.00CS_TEAM_T)
               
                return
        }
}

stock Get_PlayerCount(AliveTeam)
// Alive: 0 - Dead | 1 - Alive | 2 - Both
// Team: 1 - T | 2 - CT
{
        new 
Flag[4], Flag2[12]
        new 
Players[32], PlayerNum
 
        
if(!Aliveformatex(Flagsizeof(Flag), "%sb"Flag)
        else if(
Alive == 1formatex(Flagsizeof(Flag), "%sa"Flag)
       
        if(
Team == 1)
        {
                
formatex(Flagsizeof(Flag), "%se"Flag)
                
formatex(Flag2sizeof(Flag2), "TERRORIST"Flag)
        } 
        else if(
Team == 2)
        {
                
formatex(Flagsizeof(Flag), "%se"Flag)
                
formatex(Flag2sizeof(Flag2), "CT"Flag)
        }
       
        
get_players(PlayersPlayerNumFlagFlag2)
       
        return 
PlayerNum


I found that stock in a code that is not mine

Bugsy 05-13-2020 00:23

Re: Stock to detect when a team dies
 
Then my above code will work.. It will fire AllPlayersDead() when all players on csDeadTeam team are dead.

wicho 05-15-2020 14:04

Re: Stock to detect when a team dies
 
ok thanks, so that would be correct using your method right?

PHP Code:

public HamKilled_Post(iPlayer)
{
    new 
iPlayers[32], iNumCsTeams:csPlayerTeam
    
         csPlayerTeam 
cs_get_user_team(iPlayer)
         
get_players(iPlayersiNum"ae" ,(csPlayerTeam == CS_TEAM_T) ? "TERRORIST" "CT")
    
         if (!
iNum)
         {
                  
AllPlayersDead(csPlayerTeam)
         }
}

public 
AllPlayersDead(CS_TEAM_T)
{
         if(!
g_GameAvailable || !g_GameStart || g_GameEnd)
        return
    
    if((!
pev_valid(g_TerroristBase)) // All terrorist are dead
    
{
        
Game_Ending(5.00CS_TEAM_CT)

        return
    } 
}

public 
AllPlayersDead(CS_TEAM_CT)
{
         if(!
g_GameAvailable || !g_GameStart || g_GameEnd)
        return
    
    if((!
pev_valid(g_CTBase)) // All CT are dead
    

        
Game_Ending(5.00CS_TEAM_T)
        
        return
    }   



Bugsy 05-15-2020 16:27

Re: Stock to detect when a team dies
 
No, this should do it:
PHP Code:

public HamKilled_Post(iPlayer)
{
    new 
iPlayers[32], iNumCsTeams:csPlayerTeam
    
    csPlayerTeam 
cs_get_user_team(iPlayer)
    
get_players(iPlayersiNum"ae" ,(csPlayerTeam == CS_TEAM_T) ? "TERRORIST" "CT")
    
    if (!
iNum)
    {
        
AllPlayersDead(csPlayerTeam)
    }
}


public 
AllPlayersDeadCsTeams:csDeadTeam )
{
    
//All players on csDeadTeam are dead
    
if(!g_GameAvailable || !g_GameStart || g_GameEnd)
        return;
    
    if ( !
pev_validcsDeadTeam == CS_TEAM_T g_TerroristBase g_CTBase ) )
    {
        
Game_Ending5.0 csDeadTeam == CS_TEAM_CT CS_TEAM_T CS_TEAM_CT );
    }




All times are GMT -4. The time now is 05:59.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.