Raised This Month: $12 Target: $400
 3% 

Stock to detect when a team dies


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 05-12-2020 , 22:05   Stock to detect when a team dies
Reply With Quote #1

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...
wicho is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-12-2020 , 22:28   Re: Stock to detect when a team dies
Reply With Quote #2

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
    

__________________

Last edited by Bugsy; 05-12-2020 at 22:45.
Bugsy is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 05-12-2020 , 23:51   Re: Stock to detect when a team dies
Reply With Quote #3

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

Last edited by wicho; 05-12-2020 at 23:52.
wicho is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-13-2020 , 00:23   Re: Stock to detect when a team dies
Reply With Quote #4

Then my above code will work.. It will fire AllPlayersDead() when all players on csDeadTeam team are dead.
__________________
Bugsy is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 05-15-2020 , 14:04   Re: Stock to detect when a team dies
Reply With Quote #5

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
    }   


Last edited by wicho; 05-15-2020 at 14:42.
wicho is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-15-2020 , 16:27   Re: Stock to detect when a team dies
Reply With Quote #6

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 );
    }

__________________

Last edited by Bugsy; 05-15-2020 at 16:28.
Bugsy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:42.


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