PDA

View Full Version : Most Important TF2 Mod Yet...


thinkr
05-04-2009, 15:45
Everyone dislikes losing a round...
On the other hand its just plain annoying losing with the exact same players Round after round...

This stifles player spirits and not wanting to play...
So we desperatley need a way to balance good players vs the latter...

This option should be for the dedicated TF2 Servers

It should go like this, after every round, Randomly dices the players up to opposite teams accoriding to how many frags they got in the last round...
example a TF2 round is over badly biased....

RED TEAM Frags | Blue Team Frags
RedPlayer A 55 | BluePlayer A 106
RedPlayer B 30 | BluePlayer B 101
RedPlayer C 16 | BluePlayer C 60
RedPlayer D 14 | BluePlayer D 20
RedPlayer E 03 | BluePlayer E 15
RedPlayer F 00 | BluePlayer F 01

Than Put all the players in order from most frags to least You would have to code this...

BluePlayer A 106
BluePlayer B 101
BluePlayer C 60
RedPlayer A 55
RedPlayer B 30
BluePlayer D 20
RedPlayer C 16
BluePlayer E 15
RedPlayer D 14
RedPlayer E 03
BluePlayer F 01
RedPlayer F 00

Once this is Done ... than Stagger the teams So BluePlayer A with 106 Frags goes to Red team next round and BluePlayer B with 101 frags stays on blue... etc... I'm sure this can be done considering the wide variety of mods there are this one would be the most benifitical to Evening OUT the better players to apposing sides...
Let me know what you think!
_Nick_

santoriin
05-07-2009, 21:51
I think the scramble teams sm plugin does this (albeit based on points rather than frags)

bl4nk
05-07-2009, 23:24
#pragma semicolon 1

#include <sourcemod>
#include <tf2_stocks>

#define PLUGIN_VERSION "1.0.0"

new bool:g_bFirstRound;
new bool:g_bSwitchingTeams;

public Plugin:myinfo =
{
name = "End-Round Scrambler",
author = "bl4nk",
description = "Scrambles the teams at the start of a new round",
version = PLUGIN_VERSION,
url = "http://forums.alliedmods.net"
};

public OnPluginStart()
{
CreateConVar("ers_version", PLUGIN_VERSION, "End-Round Scrambler Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FC VAR_NOTIFY|FCVAR_DONTRECORD);

HookEvent("player_team", Event_PlayerTeam, EventHookMode_Pre);
HookEvent("teamplay_round_start", Event_RoundStart, EventHookMode_Post);
}

public OnMapStart()
{
g_bFirstRound = true;
}

public Action:Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
if (g_bSwitchingTeams && !dontBroadcast)
{
dontBroadcast = true;
}
}

public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
if (g_bFirstRound)
{
g_bFirstRound = false;
return;
}

g_bSwitchingTeams = true;

new Handle:aPlayers = CreateArray(MAXPLAYERS+1);

for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
PushArrayCell(aPlayers, i);
}
}

SortADTArrayCustom(aPlayers, SortFunc);

new team = 3;
for (new i = 0; i <= GetArraySize(aPlayers); i++)
{
switch(team)
{
case 2:
team = 3;
case 3:
team = 2;
}

ChangeClientTeam(i, team);
}

g_bSwitchingTeams = false;

CloseHandle(aPlayers);
}

public SortFunc(index1, index2, Handle:array, Handle:hndl)
{
new value1 = GetArrayCell(array, index1);
new value2 = GetArrayCell(array, index2);

if (value1 == value2)
{
return 0;
}
else if (TF2_GetPlayerResourceData(value1, TFResource_TotalScore) > TF2_GetPlayerResourceData(value2, TFResource_TotalScore))
{
return -1;
}

return 1;
}Try that out. I haven't tested it, so I can't guarantee it'll work 100%, but it should do just fine.

BrutalGoerge
05-09-2009, 00:45
like santoriin (http://forums.alliedmods.net/member.php?u=50863) said, my plugin gets player scores (frags, caps, assists etc), not just frags, but I'm some people are already liking the score-per-hour feature it has since it might even things up better than just by score.

however, bl4nk's is small and simple, mine is kinda complicated. :(

thinkr
05-09-2009, 18:53
You guys Rock! now if we just could encourage other people to use it ! :):crab: lol...

Kevin_b_er
05-09-2009, 20:28
So how does it deal with medics?

bl4nk
05-10-2009, 14:48
It doesn't. It just sticks all of the players into an array, and sorts them by their scores. Then it just puts the top player on team A, the next player on team B, the next on A, etc until there are no more players left in the array.

bl4nk
05-10-2009, 15:01
Just noticed a typo in the plugin. I was using "player_changeteam" instead of "player_team". I updated the posted code with the right stuff.