Raised This Month: $ Target: $400
 0% 

[Request] Team switch prevention if it would cause teams to become uneven


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellomoto
Member
Join Date: Sep 2006
Old 06-22-2014 , 13:46   [Request] Team switch prevention if it would cause teams to become uneven
Reply With Quote #1

Hi,

I play a mod called Fortress Forever which is currently on the original Source 2006 SDK. Currently, the game does not have native support for preventing teams from becoming uneven by players and wanted to know if someone could create a simple plugin that would help prevent this.

I don't need the plugin to do anything else such as automatically balancing the teams. Just the prevention from someone choosing or switching to another team that already has too many players. And also a CVAR to be able to disable the plugin for maps that don't need it turned on.

Traditionally, there are 2 teams, Red and Blue, similar to TF2. But in FF, there are actually 4 total teams including Yellow and Green which I would need this to apply to as well.

If someone could create this I'd greatly appreciate it. This mod has been out since 2007 and has not yet got this feature so I'm tired of waiting for the developers to add it.

I thank you for your time,

FPSMoto

Last edited by hellomoto; 06-22-2014 at 13:49.
hellomoto is offline
SadScrub
Member
Join Date: May 2014
Old 06-23-2014 , 16:38   Re: [Request] Team switch prevention if it would cause teams to become uneven
Reply With Quote #2

Hello. This might work (it's just preventing team switch if a client's old team has less players than the new team):

Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define THRESHOLD 1

new Handle:g_Enabled;
new bool:isEnabled = true;

public OnPluginStart()
{
    g_Enabled = CreateConVar("ff_teambalance", "1", "Enables/disables plugin");
    
    HookConVarChange(g_Enabled, OnEnabledChange);
    HookEvent("player_team", Event_TeamChange, EventHookMode_Pre);
}

public OnEnabledChange(Handle:cvar, const String:oldVal[], const String:newVal[])
{
    isEnabled = GetConVarBool(g_Enabled);
}

public Action:Event_TeamChange(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!isEnabled)
        return Plugin_Continue;
        
    new client = GetClientOfUserId(GetEventInt(event, "userid"));

    new oldteam = GetEventInt(event, "oldteam");
    new newteam = GetEventInt(event, "team");
    
    if ( (oldteam > 1) && (newteam > 1) && ( (GetTeamClientCount(newteam) - GetTeamClientCount(oldteam)) >= THRESHOLD ) )
    {
        ChangeClientTeam(client, oldteam);
        return Plugin_Handled;
    }
    
    return Plugin_Continue;
}
SadScrub is offline
hellomoto
Member
Join Date: Sep 2006
Old 06-24-2014 , 02:43   Re: [Request] Team switch prevention if it would cause teams to become uneven
Reply With Quote #3

Thanks for your assistance but I tried this and it didn't work.
hellomoto is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 06-24-2014 , 08:50   Re: [Request] Team switch prevention if it would cause teams to become uneven
Reply With Quote #4

If you could, run this "debug" plugin on your server few map changes.
Want to know how those team index have shared, will FF game use same team index 0 and 1 as teams etc. etc.
Or will people have spectator team even there is 4 teams.
And have people "random" team join.
depug




But here another plugin for test, after you have run above plugin to collect enough info, so you had get logs in file cmd_debug.txt
Show that file in here then.

This is totally guessing now.
test
Bacardi 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 23:15.


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