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

[TF2] Old balancer fix.


Post New Thread Reply   
 
Thread Tools Display Modes
Author
VOLK_RuS
Junior Member
Join Date: Mar 2016
Plugin ID:
5454
Plugin Version:
0.2
Plugin Category:
Gameplay
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Destroy engi buildings on balance.(if mp_autoteambalance 1)
    Old 12-23-2016 , 09:56   [TF2] Old balancer fix.
    Reply With Quote #1

    0.1 - Release.
    0.2 - Changed destroy code(thx TonyBaretta)
    Attached Files
    File Type: sp Get Plugin or Get Source (balance_fix.sp - 501 views - 1.4 KB)
    File Type: smx balance_fix.smx (6.0 KB, 263 views)

    Last edited by VOLK_RuS; 12-23-2016 at 10:45.
    VOLK_RuS is offline
    TonyBaretta
    Senior Member
    Join Date: Mar 2014
    Location: nope.avi
    Old 12-23-2016 , 10:08   Re: [TF2] Old balancer fix.
    Reply With Quote #2

    Code:
    stock int DestroyBuildings(client)
    {
        char strObjects[3][] = {"obj_sentrygun","obj_dispenser","obj_teleporter"};
        for( int o = 0; o < sizeof(strObjects); o++ ){
            int iEnt = -1;
            while( ( iEnt = FindEntityByClassname( iEnt, strObjects[o] ) ) != -1 )
            if (client == GetEntPropEnt(iEnt, Prop_Send, "m_hBuilder"))
            {
                if( IsValidEdict(iEnt) )
                {
                    SetEntityHealth( iEnt, 100 );
                    SetVariantInt( 1488 );
                    AcceptEntityInput( iEnt, "RemoveHealth" );
                }
            }
        }
    }
    use this is better
    __________________

    Last edited by TonyBaretta; 12-23-2016 at 10:09.
    TonyBaretta is offline
    VOLK_RuS
    Junior Member
    Join Date: Mar 2016
    Old 12-23-2016 , 10:12   Re: [TF2] Old balancer fix.
    Reply With Quote #3

    Quote:
    Originally Posted by TonyBaretta View Post
    Code:
    stock int DestroyBuildings(client)
    {
        char strObjects[3][] = {"obj_sentrygun","obj_dispenser","obj_teleporter"};
        for( int o = 0; o < sizeof(strObjects); o++ ){
            int iEnt = -1;
            while( ( iEnt = FindEntityByClassname( iEnt, strObjects[o] ) ) != -1 )
            if (client == GetEntPropEnt(iEnt, Prop_Send, "m_hBuilder"))
            {
                if( IsValidEdict(iEnt) )
                {
                    SetEntityHealth( iEnt, 100 );
                    SetVariantInt( 1488 );
                    AcceptEntityInput( iEnt, "RemoveHealth" );
                }
            }
        }
    }
    use this is better
    First version of plugin was with that code, but for some reason that code is crashing server. Will try again later .

    Last edited by VOLK_RuS; 12-23-2016 at 10:16.
    VOLK_RuS is offline
    TonyBaretta
    Senior Member
    Join Date: Mar 2014
    Location: nope.avi
    Old 12-23-2016 , 10:23   Re: [TF2] Old balancer fix.
    Reply With Quote #4

    Code:
    #include <sdktools>
    #include <tf2_stocks>
    #pragma newdecls required
    
    public Plugin myinfo =
    {
        name = "Balancer Fix",
        author = "VOLK_RuS",
        description = "Destroy engi buildings on balance.",
        version = "0.1",
        url = "awpcountry.ru"
    } 
    
    public void OnPluginStart()
    {
        HookEvent("player_team", Player_Team);
    }
    public void Player_Team(Event event, const char[] name, bool dontBroadcast)
    {
        int client = GetClientOfUserId(GetEventInt(event, "userid"));
        if(IsValidClient(client) && TF2_GetPlayerClass(client) == TFClass_Engineer){
            DestroyBuildings(client);
        }
    }
    
    stock int DestroyBuildings(int client)
    {
        char strObjects[3][] = {"obj_sentrygun","obj_dispenser","obj_teleporter"};
        for( int o = 0; o < sizeof(strObjects); o++ ){
            int iEnt = -1;
            while( ( iEnt = FindEntityByClassname( iEnt, strObjects[o] ) ) != -1 )
            if (client == GetEntPropEnt(iEnt, Prop_Send, "m_hBuilder"))
            {
                if( IsValidEdict(iEnt) )
                {
                    SetEntityHealth( iEnt, 100 );
                    SetVariantInt( 1488 );
                    AcceptEntityInput( iEnt, "RemoveHealth" );
                }
            }
        }
    }
    stock bool IsValidClient(int client)
    {
        if (client <= 0 || client > MaxClients) return false;
        if (!IsClientInGame(client)) return false;
        if (IsClientSourceTV(client) || IsClientReplay(client)) return false;
        return true;
    }
    no crash i'm using this code from months

    edit:using new declarations
    __________________

    Last edited by TonyBaretta; 12-23-2016 at 10:30.
    TonyBaretta is offline
    VOLK_RuS
    Junior Member
    Join Date: Mar 2016
    Old 12-23-2016 , 10:46   Re: [TF2] Old balancer fix.
    Reply With Quote #5

    Quote:
    Originally Posted by TonyBaretta View Post
    Code:
    #include <sdktools>
    #include <tf2_stocks>
    #pragma newdecls required
    
    public Plugin myinfo =
    {
        name = "Balancer Fix",
        author = "VOLK_RuS",
        description = "Destroy engi buildings on balance.",
        version = "0.1",
        url = "awpcountry.ru"
    } 
    
    public void OnPluginStart()
    {
        HookEvent("player_team", Player_Team);
    }
    public void Player_Team(Event event, const char[] name, bool dontBroadcast)
    {
        int client = GetClientOfUserId(GetEventInt(event, "userid"));
        if(IsValidClient(client) && TF2_GetPlayerClass(client) == TFClass_Engineer){
            DestroyBuildings(client);
        }
    }
    
    stock int DestroyBuildings(int client)
    {
        char strObjects[3][] = {"obj_sentrygun","obj_dispenser","obj_teleporter"};
        for( int o = 0; o < sizeof(strObjects); o++ ){
            int iEnt = -1;
            while( ( iEnt = FindEntityByClassname( iEnt, strObjects[o] ) ) != -1 )
            if (client == GetEntPropEnt(iEnt, Prop_Send, "m_hBuilder"))
            {
                if( IsValidEdict(iEnt) )
                {
                    SetEntityHealth( iEnt, 100 );
                    SetVariantInt( 1488 );
                    AcceptEntityInput( iEnt, "RemoveHealth" );
                }
            }
        }
    }
    stock bool IsValidClient(int client)
    {
        if (client <= 0 || client > MaxClients) return false;
        if (!IsClientInGame(client)) return false;
        if (IsClientSourceTV(client) || IsClientReplay(client)) return false;
        return true;
    }
    no crash i'm using this code from months

    edit:using new declarations
    Ok, thx. Plugin updated
    VOLK_RuS is offline
    Reply



    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 04:00.


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