AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved Team Balancer by High Frags (https://forums.alliedmods.net/showthread.php?t=341107)

iclassdon 12-30-2022 18:04

Team Balancer by High Frags
 
Could someone help me adjust this team balancer, so it transfers the player with the highest frags instead of the lowest frags?

PHP Code:

#include < amxmodx >
#include < cstrike >

// This is a random number to define INVALID_PLAYER
#define INVALID_PLAYER -1

// Check whether server is running CSDM
new boolg_bCsdmEnabledg_iCsdmConVarPointer;

// Console variable to set check frequency in seconds
new g_iConVarCheckFrequency;

// Console variable to set maximum difference between terrorists and counter-terrorists
new g_iConVarTerroristsDifference;

// Console variable to set maximum difference between counter-terrorists and terrorists
new g_iConVarCTerroristsDifference;

// Console variable to set immune admin flag
new g_iConVarAdminFlag;

// Variable to store admin flag
new g_iFlag;

public 
plugin_init( )
{
    
register_plugin"Team Balancer by Low Frags""4.0""Hattrick" );

    
g_iConVarCheckFrequency register_cvar"team_balancer_frequency""10" );
    
g_iConVarTerroristsDifference register_cvar"team_balancer_te_difference""1" );
    
g_iConVarCTerroristsDifference register_cvar"team_balancer_ct_difference""1" );
    
g_iConVarAdminFlag register_cvar"team_balancer_admin_flag""" );

    
set_taskget_pcvar_floatg_iConVarCheckFrequency ), "Task_CheckTeams", .flags "b" );

    new 
cFlag];
    
get_pcvar_stringg_iConVarAdminFlagcFlag);
    
g_iFlag read_flagscFlag );

    
g_iCsdmConVarPointer get_cvar_pointer"csdm_active" );
    
g_bCsdmEnabled g_iCsdmConVarPointer && get_pcvar_numg_iCsdmConVarPointer );
}

public 
Task_CheckTeams( )
{
    static 
iPlayers_TE32 ], iPlayers_CT32 ], iNum_TEiNum_CTiPlayer;
    
get_playersiPlayers_TEiNum_TE"e""TERRORIST" );
    
get_playersiPlayers_CTiNum_CT"e""CT" );

    
// Check whether teams should be balanced
    
if( iNum_TE == iNum_CT || !iNum_TE || !iNum_CT )
        return;

    
// Is the difference between terrorists and counter-terrorists higher than the specified value?
    
if( iNum_TE iNum_CT get_pcvar_numg_iConVarTerroristsDifference ) )
    {
        
// Get a terrorist
        
iPlayer GetLowestFragsTargetCsTeamsCS_TEAM_T );

        
// Is this specified target a valid one?
        
if( iPlayer == INVALID_PLAYER )
            return;

        
// Transfer him to the opposite team
        
cs_set_user_teamiPlayerCsTeamsCS_TEAM_CT );

        
// Make sure the difference between players is alright
        
Task_CheckTeams( );
    }

    
// Is the difference between counter-terrorists and terrorists higher than the specified value?
    
else if( iNum_CT iNum_TE get_pcvar_numg_iConVarCTerroristsDifference ) )
    {
        
// Get a counter-terrorist
        
iPlayer GetLowestFragsTargetCsTeamsCS_TEAM_CT );

        
// Is this specified target a valid one?
        
if( iPlayer == INVALID_PLAYER )
            return;

        
// Transfer him to the opposite team
        
cs_set_user_teamiPlayerCsTeamsCS_TEAM_T );

        
// Make sure the difference between players is alright
        
Task_CheckTeams( );
    }
}

// This function will return the player with the lowest frags from one team or INVALID_PLAYER on invalid specified target found
GetLowestFragsTargetCsTeamsiTeam )
{
    static 
iTargetiPlayers32 ], iNumiPlayeriiMinimumFragsiFrags;

    switch( 
CsTeamsiTeam )
    {
        case 
CS_TEAM_Tg_bCsdmEnabled get_playersiPlayersiNum"e""TERRORIST" ) : get_playersiPlayersiNum"be""TERRORIST" );
        case 
CS_TEAM_CTg_bCsdmEnabled get_playersiPlayersiNum"e""CT" ) : get_playersiPlayersiNum"be""CT" );
    }

    
// The biggest number
    
iMinimumFrags 0xFFFFFF;

    
// Invalid target
    
iTarget INVALID_PLAYER;

    for( 
0iNumi++ )
    {
        
iPlayer iPlayers];

        if( 
g_iFlag && get_user_flagsiPlayer ) & g_iFlag )
            continue;

        
iFrags get_user_fragsiPlayer );

        if( 
iFrags iMinimumFrags )
        {
            
iMinimumFrags iFrags;
            
iTarget iPlayer;
        }
    }

    return 
iTarget;



JocAnis 01-03-2023 05:35

Re: Team Balancer by High Frags
 
Hi, can you try with this:

if( iFrags < iMinimumFrags )
Make it to:
if( iFrags > iMinimumFrags )

And:
iMinimumFrags = 0xFFFFFF;
I hve no clue what this hex means (would be cool to hear explanation if someone know why original author used it, what is the meaning).. i would put:
iMinimumFrags = 0

Can you test with these two line changes firstly? So we will know what to do next

iclassdon 01-03-2023 23:45

Re: Team Balancer by High Frags
 
Thank JocAnis. I got it resolved by the plugin creator.

https://forums.alliedmods.net/showpo...49&postcount=1


All times are GMT -4. The time now is 10:09.

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