PHP Code:
#include <amxmodx>
#include <cstrike>
new PLUGIN[] = "Teamchanger"
new AUTHOR[] = "Schwabba"
new VERSION[] = "1.0"
new g_newbie = 0;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
set_task(5.0,"CTcheck",0,_,_,"b")
}
public CTcheck( )
{
new iPlayers[32],iNum, Cts, Ts, newbie
get_players(iPlayers, Cts, "e", "CT");
get_players(iPlayers, Ts, "e", "TERRORIST");
get_players(iPlayers, iNum)
newbie = 999999
for(new i=0;i<iNum;i++)
{
new plr = iPlayers[i]
if(cs_get_user_team(plr) == CS_TEAM_CT)
{
if(get_user_time(plr) < newbie)
{
newbie = get_user_time(plr)
g_newbie = plr
}
}
}
if (Cts > Ts/3 && Cts > 2)
{
new snick[32];
get_user_name(g_newbie, snick, 31);
cs_set_user_team(g_newbie, CS_TEAM_T)
client_print(0, print_chat, "There are to many Ct's, %s got switched to the T's", snick);
// Remove '//' on the line below to slay the switched player.
// set_user_health(g_newbie, 0)
}
}
Now i made it with get_user_time, because when someone disconnect and a new player gets his id, the old plugin thinks that this player is longer connected.
But i'm not sure if that is rly what you want, because when someone joines CT with a longer connection time as someone else, then the player who already was CT get moved to the T's.
Example:
Player A is T and is connected 10 minutes, player B is CT and is connected 5 minutes.
Player A joines CT and player B get switched to the T's, because player A is longer connected.