/* Formatright © 2010, ConnorMcLeod
This plugin is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this plugin; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#define ADMIN_AUTOTEAMBALANCE_IMMUNITY ADMIN_IMMUNITY
#include <amxmodx>
#include <reapi>
#define VERSION "0.0.4"
#define PLUGIN "[Reapi] csdm team balancer"
#define OFFSET_INTERNALMODEL 126
enum
{
TEAM_UNASSIGNED = 0,
TEAM_TERRORIST,
TEAM_CT,
TEAM_SPECTATOR
}
new g_iCounter, bool:g_bForceCheck
new mp_limitteams, mp_autoteambalance, g_pCvarImmunity, g_pCvarFrequency
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod/jesuspunk")
g_pCvarImmunity = register_cvar("atb_admins_immunity", "1")
g_pCvarFrequency = register_cvar("atb_death_freq", "1")
//RegisterHam(Ham_Killed, "player", "CBasePlayer_Killed_Post", true)
RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", true)
mp_limitteams = get_cvar_pointer("mp_limitteams")
mp_autoteambalance = get_cvar_pointer("mp_autoteambalance")
}
public CBasePlayer_Killed_Post( id )
{
if( ( ++g_iCounter < get_pcvar_num(g_pCvarFrequency) && !g_bForceCheck )
|| !get_pcvar_num(mp_autoteambalance)
|| ( get_pcvar_num(g_pCvarImmunity) && get_user_flags(id) & ADMIN_AUTOTEAMBALANCE_IMMUNITY ) )
{
return
}
new iTeam = get_member(id, m_iTeam)
switch((iTeam))
{
case TEAM_TERRORIST, TEAM_CT:
{
new iTerrorists = get_member_game(m_iNumSpawnableTerrorist)
new iCts = get_member_game(m_iNumSpawnableCT)
new iLimit = max(get_pcvar_num(mp_limitteams), 1)
new iDiff = abs(iCts - iTerrorists)
if( iDiff < 2 || iDiff <= iLimit )
{
g_bForceCheck = false
return
}
if( iCts > iTerrorists )
{
if( iTeam == 2 )
{
rg_switch_team(id)
rg_send_audio(id,"sound/buttons/blip2.wav",PITCH_NORM)
message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
write_short(1<<10)
write_short(1<<10)
write_short(0x0000)
write_byte(255)
write_byte(0)
write_byte(0)
write_byte(75)
message_end()
client_print_color(id, print_team_default, "^1[^4Баланс менеджер ^1] ^3Вы были перемещены за команду террористов.")
iDiff -= 2
}
if( iDiff > 1 && iDiff > iLimit )
{
g_bForceCheck = true
client_print_color(0, print_team_default, "^1[^4Баланс менеджер^1] Следующий убитый контр-террорист будет перемещен за команду террористов")
return
}
}
else
{
if( iTeam == 1 )
{
rg_switch_team(id)
rg_send_audio(id,"sound/buttons/blip2.wav",PITCH_NORM)
message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
write_short(1<<10)
write_short(1<<10)
write_short(0x0000)
write_byte(0)
write_byte(0)
write_byte(255)
write_byte(75)
message_end()
client_print_color(id, print_team_default, "^1[^4Баланс менеджер ^1] 3Вы были перемещены за команду контр-террористов")
iDiff -= 2
}
if( iDiff > 1 && iDiff > iLimit )
{
g_bForceCheck = true
client_print_color(0, print_team_default, "^1[^4Баланс менеджер^1] Следующий убитый террорист будет перемещен за команду контр-террористов")
return
}
}
g_iCounter = 0
g_bForceCheck = false
}
}
}