/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#include <csx>
#include <fvault>
#define PLUGIN "[182]AutoMix"
#define VERSION "1.2.0"
#define AUTHOR "by..pakilo"
#pragma dynamic 20480
#define PREFIX "[Auto-Mix]"
#define TIME_MAX 150
#define SPAWN_TASKID 3000
#define ADMIN_NONE (1 << 26)
#define PLAYER 5
#define MenuCode 205
#define PDActiveItem 373
#define cs_get_user_menu(%0) get_pdata_int(%0, MenuCode, PLAYER)
static menubody[512]
new SET_CONST_TASKID
new gPlayersLeft
new gMaxPlayers
new gPug_ini_file[64]
new gCptT
new gCptCT
new g_iScore[2]
new g_iLastTeamScore[2]
static gNotRdy[400]
static gRdy[400]
new bool:g_bIsReady[33]
new Float:gTypedCommand[33]
new g_LeftKills[33]
new g_LeftVotes[33]
new g_iTimeLeft[33]
new g_KillsAce[33]
new g_TotalKills[33]
new g_TotalDeaths[33]
new g_BombPlants[33]
new g_BombDefusions[33]
new gPoints[33]
new g_PugLeaves
new bool:g_IsStarted
new bool:g_AfterRdy
new bool:g_KnifeRound
new bool:g_MapChanged
new bool:g_Twon
new bool:g_VoteProg
new bool:g_bStop
new bool:g_bStop2
new bool:g_Restart
new bool:g_givenChance[33]
new g_givenChanceSteamIDs[33][64]
new g_givenTimes
new g_pVote
new g_MsgSync
new g_MsgSync3
new g_MsgSync2
new g_MsgSync4
new g_MsgSync5
new g_MsgSync6
new g_MsgSync7
new g_MsgSync8
new g_szTeamName[2]
new g_iTeam
new g_iAltScore
new g_iScoreOffset
new bool:g_CustomGame
new g_bVotes[2]
new g_Menu
new g_PlayersMenu
new g_abMenu
new g_switchmenu
new g_switchVotes[2]
new bool:g_bDidScore
new bool:g_bFFoff
new bool:g_bFFTKStop
new bool:g_bDidVoteFF
new bool:g_bSecondHalf
new bool:g_bCpt
new bool:gDidPlayUntilEnd[33]
new g_NotBalanced
new g_DidWaitEnough
new gPointsVault[] = "Points"
new gChanging, gChangerID
new gChanging2, gChangerID2
new gLeftSteamIDs[33][128], gLastTime[33]
new gLeftTimes
new gEntShowLeft
/* Cvars */
new cvar_FFvote
new cvar_KnifeRound
new cvar_pLeft
new cvar_pLeftMethod
new cvar_DetectTK
new cvar_MuteMenu
new cvar_AllowShield
new cvar_MapVote
new cvar_Rankings
new cvar_TimeLeft
new cvar_TeamTag
new cvar_AceHud
new cvar_AFKKick
new cvar_ReadyXPos, cvar_ReadyYPos
new cvar_NotReadyXPos, cvar_NotReadyYPos
new cvar_KillPoints, cvar_KnifePoints, cvar_WinsMatchPoints
new cvar_LeavesMatchPoints, cvar_LeavesMatchTime, cvar_PlaysUntilEndPoints
new cvar_TeamKillPoints, cvar_BombPlantPoints, cvar_BombDefusePoints
new cvar_KillLosePoints, cvar_KnifeLosePoints, cvar_LosesMatchPoints
new cvar_RanksSystem, cvar_RanksSystemMessages
new cvar_BeginnerPoints, cvar_RegularPoints, cvar_VeteranPoints
new cvar_ProPoints, cvar_HardCorePoints
new cvar_mp_friendlyfire
new cvar_mp_freezetime
new cvar_mp_roundtime
new cvar_mp_buytime
new cvar_sv_restart
//new cvar_sv_password
new cvar_humans_join_team
new cvar_mp_afktime
/* Cvars */
/* Mute menu */
#define MAX_PLAYERS 32
new bool:g_mute[MAX_PLAYERS+1][MAX_PLAYERS+1]
new g_menuposition[MAX_PLAYERS+1]
new g_menuplayers[MAX_PLAYERS+1][32]
new g_playersnum[MAX_PLAYERS+1]
new cvar_alltalk
/* Mute menu */
/* IP server */
#define MIN_AFK_TIME 30 // I use this incase stupid admins accidentally set mp_afktime to something silly.
#define WARNING_TIME 15 // Start warning the user this many seconds before they are about to be kicked.
#define CHECK_FREQ 5.0 // This is also the warning message frequency.
new g_oldangles[33][3]
new Float:g_afktime[33]
new bool:g_spawned[33] = {true, ...}
/* AFK Kicker */
/* Map & Votes variables */
new g_gVoteMenu
new g_gVotes[5]
new g_rVoteMenu
new g_rVotes[3]
new g_fVoteMenu
new g_fVotes[2]
new g_Maps_Ini_File[64]
new g_MapsCounter
new g_MapsAvailable[30][20]
new g_MapsChosen[4][20]
new g_DoneMaps
new g_ChangeMapTo
new g_LeftBans[24][124]
new g_LeftBansIPs[24][64]
new g_RoundsLeft[24] = {-1, ...}
/* Map & Votes variables */
enum {
T_WIN = 0,
CT_WIN = 1
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
cvar_FFvote = register_cvar("pug_ffvote", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_KnifeRound = register_cvar("pug_kniferound", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_pLeft = register_cvar("pug_players", "10", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_pLeftMethod = register_cvar("pug_playersmethod", "0", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_DetectTK = register_cvar("pug_detecttk", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_MuteMenu = register_cvar("mutemenu", "1", FCVAR_SPONLY|FCVAR_SERVER)
cvar_AllowShield = register_cvar("pug_allowshield", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_MapVote = register_cvar("pug_mapvote", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_Rankings = register_cvar("pug_ranking", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_TimeLeft = register_cvar("pug_timeleft", "120", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_TeamTag = register_cvar("pug_teamtag", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_AceHud = register_cvar("pug_acehud", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_AFKKick = register_cvar("pug_afkkick", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_ReadyXPos = register_cvar("pug_readyxpos", "0.72", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_ReadyYPos = register_cvar("pug_readyypos", "0.19", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_NotReadyXPos = register_cvar("pug_notreadyxpos", "0.02", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_NotReadyYPos = register_cvar("pug_notreadyypos", "0.19", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_RanksSystem = register_cvar("pug_rankssystem", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_RanksSystemMessages = register_cvar("pug_rankssystemmessages", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_KillPoints = register_cvar("pug_killpoints", "4", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_KillLosePoints = register_cvar("pug_killosepoints", "1", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_KnifePoints = register_cvar("pug_knifepoints", "10", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_KnifeLosePoints = register_cvar("pug_knifelosespoints", "4", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_WinsMatchPoints = register_cvar("pug_winsmatchpoints", "15", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_LosesMatchPoints = register_cvar("pug_losesmatchpoints", "10", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_LeavesMatchPoints = register_cvar("pug_leavesmatchpoints", "20", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_LeavesMatchTime = register_cvar("pug_leavesmatchtime", "360", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_PlaysUntilEndPoints = register_cvar("pug_playsuntilendpoints", "30", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_TeamKillPoints = register_cvar("pug_teamkillpoints", "8", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_BombPlantPoints = register_cvar("pug_bombplantpoints", "3", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_BombDefusePoints = register_cvar("pug_bombdefusepoints", "5", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_BeginnerPoints = register_cvar("pug_beginner", "200", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_RegularPoints = register_cvar("pug_regular", "500", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_VeteranPoints = register_cvar("pug_veteran", "900", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_ProPoints = register_cvar("pug_pro", "1400", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_HardCorePoints = register_cvar("pug_hardcore", "1900", FCVAR_ARCHIVE|FCVAR_SERVER)
cvar_mp_afktime = register_cvar("mp_afktime", "40") // Kick people AFK longer than this time
register_forward(FM_Voice_SetClientListening, "fwd_voice_setclientlistening")
register_menucmd(register_menuid("mute menu"), 1023, "action_mutemenu")
register_menucmd(register_menuid("ranks info"), 1023, "ranks_showInfo")
register_menucmd(register_menuid("setprices menu"), 1023, "menuHandler")
cvar_alltalk = get_cvar_pointer("sv_alltalk")
new Ent = create_entity("info_target")
entity_set_string(Ent, EV_SZ_classname, "checking_players_ent")
entity_set_float(Ent, EV_FL_nextthink, halflife_time() + CHECK_FREQ)
register_think("checking_players_ent", "afkCheck_entThink")
register_dictionary("automix_pk.txt")
g_MsgSync = CreateHudSyncObj()
g_MsgSync3 = CreateHudSyncObj()
g_MsgSync4 = CreateHudSyncObj()
g_MsgSync5 = CreateHudSyncObj()
g_MsgSync6 = CreateHudSyncObj()
g_MsgSync7 = CreateHudSyncObj()
g_MsgSync8 = CreateHudSyncObj()
g_MsgSync2 = CreateHudSyncObj()
cvar_mp_friendlyfire = get_cvar_pointer("mp_friendlyfire")
cvar_mp_freezetime = get_cvar_pointer("mp_freezetime")
cvar_mp_roundtime = get_cvar_pointer("mp_roundtime")
cvar_mp_buytime = get_cvar_pointer("mp_buytime")
cvar_sv_restart = get_cvar_pointer("sv_restart")
//cvar_sv_password = get_cvar_pointer("sv_password")
cvar_humans_join_team = get_cvar_pointer("humans_join_team")
gPlayersLeft = get_pcvar_num(cvar_pLeft)
get_configsdir(gPug_ini_file, 63);
formatex(gPug_ini_file, 63, "%s/pk.ini", gPug_ini_file);
get_configsdir(g_Maps_Ini_File, 63);
formatex(g_Maps_Ini_File, 63, "%s/maps.ini", g_Maps_Ini_File);
gMaxPlayers = get_maxplayers()
SET_CONST_TASKID = scanForTaskID()
formatex(gNotRdy, charsmax(gNotRdy), "%L:^n", LANG_PLAYER, "HUD_NOT_READY")
formatex(gRdy, charsmax(gRdy), "%L:^n", LANG_PLAYER, "HUD_READY")
register_clcmd("say !rr", "Restart")
register_clcmd("say !restart", "RestartS")
register_clcmd("say !add", "Prepare")
register_clcmd("radio1", "Prepare")
register_clcmd("say !unadd", "unPrepare")
register_clcmd("say !credit", "credits")
register_clcmd("say !credits", "credits")
register_clcmd("say !ranks", "showRanks")
register_clcmd("say !startmatch", "forcedStart_AdminCmd")
register_clcmd("radio2", "forcedStart_AdminCmd")
register_clcmd("say !stopmatch", "forcedStop_AdminCmd")
register_clcmd("say /ranks", "showRanks")
register_clcmd("say /showranks", "showRanks")
register_clcmd("say /xp", "showRanks")
register_clcmd("say /shop", "showRanks")
register_clcmd("say /level", "showRanks")
register_clcmd("say !ranks", "showRanks")
register_clcmd("say !xp", "showRanks")
register_clcmd("say !shop", "showRanks")
register_clcmd("say !level", "showRanks")
register_clcmd("say !cmd", "cmds")
register_clcmd("say !cmds", "cmds")
register_clcmd("say !commands", "cmds")
register_clcmd("say !menu", "player")
register_clcmd("chooseteam", "handled")
register_clcmd("jointeam", "handled")
register_clcmd("say !voteban", "voteban")
register_clcmd("say_team !voteban", "voteban")
register_clcmd("say !score", "showscore")
register_clcmd("say_team !score", "showscore")
register_clcmd("say", "clcmd_say")
register_clcmd("say_team", "clcmd_say")
register_clcmd("amx_automix_settings", "openSettingsMenu")
register_clcmd("menuselect 8", "blockShield")
register_clcmd("shield", "blockShield_ConsoleCommand")
register_logevent("round_end", 2, "1=Round_End")
register_event("TeamScore", "Event_TeamScore", "a")
register_event("DeathMsg", "Event_DeathMsg_Knife", "a", "1>0")
register_event("CurWeapon", "Event_CurWeapon_NotKnife", "be", "1=1", "2!29")
register_forward(FM_ClientUserInfoChanged, "infochanged")
register_forward(FM_GetGameDescription, "Change" );
register_forward(FM_PrecacheModel, "blockShieldPrecache")
RegisterHam(Ham_Touch, "weapon_shield", "fwNoShield", 1)
RegisterHam(Ham_Spawn, "player", "fwPlayerSpawn")
}
public Change() {
forward_return(FMV_STRING, "vk.com/automixkrepost");
return FMRES_SUPERCEDE;
}
public Event_CurWeapon_NotKnife(id) {
if ( g_Restart || !g_KnifeRound )
return
if( !user_has_weapon(id, CSW_KNIFE ) )
give_item(id, "weapon_knife")
engclient_cmd(id, "weapon_knife")
}
public Restart(id) {
if (is_user_admin(id))
server_cmd("sv_restart 1")
else
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NOT_ADMIN")
}
public RestartS(id) {
if (is_user_admin(id))
server_cmd("restart")
else
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NOT_ADMIN")
}
public showscore(id) {
if ( !get_pcvar_num(cvar_TeamTag) && g_IsStarted)
{
CrashAttempt(id)
client_print(0, print_chat, "%L", LANG_PLAYER, "SHOW_SCORE", g_iScore[0], g_iScore[1])
return PLUGIN_CONTINUE;
}
if (g_IsStarted)
{
if (g_Twon)
{
if (g_bSecondHalf)
client_print(0, print_chat, "%L",LANG_PLAYER, "SHOW_SCORE_TAG", g_iScore[0], g_iScore[1])
else
client_print(0, print_chat, "%L", LANG_PLAYER, "SHOW_SCORE_TAG", g_iScore[1], g_iScore[0])
}
else
{
if (g_bSecondHalf)
client_print(0, print_chat, "%L",LANG_PLAYER, "SHOW_SCORE_TAG", g_iScore[1], g_iScore[0])
else
client_print(0, print_chat, "%L",LANG_PLAYER, "SHOW_SCORE_TAG", g_iScore[0], g_iScore[1])
}
}
else
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_NOT_STARTED")
}
return PLUGIN_CONTINUE
}
public Event_DeathMsg_Knife()
{
if ( g_Restart || !g_IsStarted )
return
new attacker = read_data(1)
new victim = read_data(2)
if ( !( 1 <= attacker <= gMaxPlayers ) || !( 1 <= victim <= gMaxPlayers) )
return;
if ( cs_get_user_team(attacker) == cs_get_user_team(victim) && attacker != victim )
{
client_print(attacker, print_chat, "%s %L", PREFIX, LANG_PLAYER, "LOSE_POINTS_TK", get_pcvar_num(cvar_TeamKillPoints))
gPoints[attacker] -= get_pcvar_num(cvar_TeamKillPoints)
SaveStats(attacker)
}
if( victim != attacker && cs_get_user_team(attacker) != cs_get_user_team(victim))
{
new weap[7]
if( read_data(4, weap, charsmax(weap)) == 5 && equal(weap, "knife") )
{
new nameA[32]
new nameV[32]
get_user_name(attacker, nameA, 31)
get_user_name(victim, nameV, 31)
set_hudmessage(255, 255, 255, 0.04, 0.63, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync5, "%L", LANG_PLAYER, "JUST_KNIFED", nameA, nameV)
gPoints[attacker] += get_pcvar_num(cvar_KnifePoints)
gPoints[victim] -= get_pcvar_num(cvar_KnifeLosePoints)
SaveStats(attacker)
SaveStats(victim)
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_KnifePoints))
client_print(attacker, print_chat, "%s %L", PREFIX, LANG_PLAYER, "GAIN_POINTS_KNIFE", get_pcvar_num(cvar_KnifePoints))
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_KnifeLosePoints) )
client_print(victim, print_chat, "%s %L", PREFIX, LANG_PLAYER, "LOSE_POINTS_KNIFE", get_pcvar_num(cvar_KnifeLosePoints))
}
else
{
gPoints[attacker] += get_pcvar_num(cvar_KillPoints)
gPoints[victim] -= get_pcvar_num(cvar_KillLosePoints)
SaveStats(attacker)
SaveStats(victim)
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_KillPoints) )
client_print(attacker, print_chat, "%s %L", PREFIX, LANG_PLAYER, "GAIN_POINTS_KILL", get_pcvar_num(cvar_KillPoints))
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_KillLosePoints) )
client_print(victim, print_chat, "%s %L", PREFIX, LANG_PLAYER, "LOSE_POINTS_KILL", get_pcvar_num(cvar_KillLosePoints))
}
g_KillsAce[attacker]++
g_TotalKills[attacker]++
g_TotalDeaths[victim]++
}
}
public bomb_planted( planter )
{
if ( g_IsStarted )
{
g_BombPlants[planter]++
client_print(planter, print_chat, "%s %L", PREFIX, LANG_PLAYER, "GAIN_POINTS_PLANT", get_pcvar_num(cvar_BombPlantPoints))
gPoints[planter] += get_pcvar_num(cvar_BombPlantPoints)
SaveStats(planter)
}
}
public bomb_defused( defuser )
{
if ( g_IsStarted )
{
g_KillsAce[defuser] -= 3
g_BombDefusions[defuser]++
client_print(defuser, print_chat, "%s %L", PREFIX, LANG_PLAYER, "GAIN_POINTS_DEFUSE", get_pcvar_num(cvar_BombPlantPoints))
gPoints[defuser] += get_pcvar_num(cvar_BombDefusePoints)
SaveStats(defuser)
}
}
public fwNoShield(ent)
{
new id = pev(ent, pev_owner)
if( is_user_alive(id) )
{
No_Shield_Message(id)
remove_shield(id)
return HAM_SUPERCEDE
}
return HAM_IGNORED
}
public blockShield(id)
{
if( !get_pcvar_num(cvar_AllowShield) && is_user_alive(id) && cs_get_user_menu(id) == 10 && cs_get_user_team(id) == CS_TEAM_CT )
{
No_Shield_Message(id)
return PLUGIN_HANDLED_MAIN
}
return PLUGIN_CONTINUE
}
public blockShield_ConsoleCommand(id)
{
if( !get_pcvar_num(cvar_AllowShield) && is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT )
{
No_Shield_Message(id)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public client_command(id)
{
static szCommand[8]
if( read_argv(0, szCommand, charsmax(szCommand)) == 6 && equali(szCommand, "shield") && ( !get_pcvar_num(cvar_AllowShield) || g_KnifeRound ) )
{
No_Shield_Message(id)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public CS_InternalCommand(id, const szCommand[])
{
if( equali(szCommand, "shield") && ( !get_pcvar_num(cvar_AllowShield) || g_KnifeRound ) )
{
No_Shield_Message(id)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
No_Shield_Message(id)
{
if ( !get_pcvar_num(cvar_AllowShield) || g_KnifeRound )
{
if ( g_KnifeRound )
client_print(id, print_center, "%L", LANG_PLAYER, "NO_SHIELD_KNIFEROUND")
else
client_print(id, print_center, "%L", LANG_PLAYER, "NO_SHIELD")
}
}
public client_damage(attacker, victim, damage, wpnindex, hitplace, TA) {
if (!get_pcvar_num(cvar_DetectTK))
return PLUGIN_CONTINUE
if (attacker == victim)
{
damage = 0
}
if (g_IsStarted)
{
if (TA == 1)
{
g_LeftKills[attacker] += damage
if (g_LeftKills[attacker] >= 100)
{
new nameofp[50]
get_user_name(attacker, nameofp, 49)
server_cmd("amx_banip #%d 10 ^"%L^"", get_user_userid(attacker), LANG_PLAYER, "YOU_HAVE_BEEN_WARNED", PREFIX)
set_hudmessage(255, 0, 0, 0.32, 0.70, 0, 6.0, 12.0)
show_hudmessage(0, "%L", LANG_PLAYER, "TK_BANNED", nameofp)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_DISABLED")
set_pcvar_num(cvar_mp_friendlyfire, 0)
new players[32], pnum, tempid;
get_players(players, pnum, "ch")
for (new i ; i<pnum ; i++)
{
tempid = players
g_LeftKills[tempid] = 0
}
new taskId = scanForTaskID()
set_task(100.0, "TurnItBackOn", taskId)
return PLUGIN_HANDLED
}
if (g_LeftKills[attacker] - damage > 40)
return PLUGIN_HANDLED
else
{
if (g_LeftKills[attacker] < 40)
{
client_print(attacker, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_WARNING")
}
if ( g_LeftKills[attacker] >= 40 && !g_givenChance[attacker] )
{
g_givenChance[attacker] = true
client_print(attacker, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_WARNING_FINAL")
g_LeftKills[attacker] = 0
set_hudmessage(255, 0, 0, 0.19, 0.35, 0, 6.0, 12.0)
show_hudmessage(attacker, "%L", LANG_PLAYER, "TK_WARNING")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_OFF")
set_pcvar_num(cvar_mp_friendlyfire, 0)
g_bFFTKStop = true
}
else if (g_LeftKills[attacker] >= 40)
{
new nameofp[50]
get_user_name(attacker, nameofp, 49)
new pplayers[32], ppnum, ptempid;
get_players(pplayers, ppnum, "ch");
for( new i; i<ppnum; i++ )
{
ptempid = pplayers
if (ptempid != attacker)
{
client_print(ptempid, print_chat ,"%s %L", PREFIX, LANG_PLAYER, "FF_ANNOYING", nameofp)
set_hudmessage(255, 0, 0, 0.32, 0.70, 0, 6.0, 12.0)
show_hudmessage(ptempid, "%L", LANG_PLAYER, "TK_QUERY", nameofp)
client_print(ptempid, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_OFF")
}
}
set_pcvar_num(cvar_mp_friendlyfire, 0)
g_bFFTKStop = true
}
}
}
}
return PLUGIN_CONTINUE
}
public infochanged(id, buffer) {
if ( ( g_IsStarted || g_KnifeRound ) && get_pcvar_num(cvar_TeamTag) )
{
if( is_user_connected(id) )
{
new name[32]
new val[32]
get_user_name(id, name, 31)
engfunc(EngFunc_InfoKeyValue, buffer, "name", val, 31)
new posA = contain(name, "(Team-A)")
new posB = contain(name, "(Team-B)")
if (g_bSecondHalf)
{
if (cs_get_user_team(id) == CS_TEAM_T)
{
if (posB == 0)
{
engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", name)
return FMRES_SUPERCEDE
}
}
else if (cs_get_user_team(id) == CS_TEAM_CT)
{
if (posA == 0)
{
engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", name)
return FMRES_SUPERCEDE
}
}
}
else
{
if (cs_get_user_team(id) == CS_TEAM_T)
{
if (posA == 0)
{
engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", name)
return FMRES_SUPERCEDE
}
}
else if (cs_get_user_team(id) == CS_TEAM_CT)
{
if (posB == 0)
{
engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", name)
return FMRES_SUPERCEDE
}
}
}
static teamA[65], teamB[65], teamA2[65], teamB2[65]
formatex(teamA, charsmax(teamA), "(%L)", LANG_PLAYER, "TEAM_A")
formatex(teamB, charsmax(teamB), "(%L)", LANG_PLAYER, "TEAM_B")
formatex(teamA2, charsmax(teamA2), "(%L", LANG_PLAYER, "TEAM_A")
formatex(teamB2, charsmax(teamB2), "(%L", LANG_PLAYER, "TEAM_B")
if (((contain(val, teamA) == 0) && (contain(name, teamA2) == -1)) || ((contain(val, teamB) == 0) && (contain(name, teamB2) == -1)))
{
return FMRES_IGNORED
}
if (((contain(val, teamB) == 0) && (contain(name, teamA2) == 0)) || ((contain(val, teamA) == 0) && (contain(name, teamB2) == 0)))
{
return FMRES_IGNORED
}
if (equal(val, name))
{
return FMRES_IGNORED
}
engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", name)
return FMRES_SUPERCEDE
}
}
return FMRES_IGNORED
}
public TurnItBackOn() {
set_pcvar_num(cvar_mp_friendlyfire, 1)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_ON")
return PLUGIN_HANDLED
}
public voteban(id) {
if (g_LeftVotes[id] >= 1)
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_EXCEED")
return PLUGIN_HANDLED
}
else if (g_VoteProg)
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "VOTE_IN_PROGRESS")
return PLUGIN_HANDLED
}
new menuTitle[64]
formatex(menuTitle, charsmax(menuTitle), "%L", LANG_PLAYER, "CHOOSE_PLAYER_VOTEBAN")
g_Menu = menu_create(menuTitle, "voteban_menu");
new players[32], pnum, tempid;
new szName[32], szTempid[10];
new added
get_players(players, pnum, "ch");
for( new i; i<pnum; i++ )
{
tempid = players;
if (g_LeftKills[tempid] >= 40)
{
get_user_name(tempid, szName, 31);
num_to_str(tempid, szTempid, 9);
menu_additem(g_Menu, szName, szTempid, 0);
added++
}
}
for ( new i ; i < sizeof(g_LeftBans) ; i++ )
{
if ( g_LeftBans[0] && g_RoundsLeft != -1 )
{
num_to_str(i+32, szTempid, 9)
menu_additem(g_Menu, g_LeftBans, szTempid, 0)
added++
}
}
if ( !added )
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_NO_ABUSERS")
return PLUGIN_HANDLED
}
menu_display(id, g_Menu);
return PLUGIN_HANDLED;
}
public voteban_menu(id, menu, item) {
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
else if (g_VoteProg)
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "VOTE_IN_PROGRESS")
return PLUGIN_HANDLED
}
g_LeftVotes[id]++
new data[6], iName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new tempid = str_to_num(data);
new name[50]
if ( tempid < 32 && !is_user_connected(tempid) )
return PLUGIN_HANDLED
get_user_name(tempid, name, 49)
votebanonplayer(tempid)
menu_destroy(menu);
return PLUGIN_HANDLED
}
public votebanonplayer(id) {
g_VoteProg = true
new nameofplayer[52]
new banline[128]
formatex(banline, charsmax(banline), "%L", LANG_PLAYER, "BAN")
if ( id >= 32 )
{
id -= 32
add(banline, 127, g_LeftBans[id])
id += 32
}
else
{
get_user_name(id, nameofplayer, 51)
add(banline, 127, nameofplayer)
}
add(banline, 127, "?")
new yesItem[10], noItem[10]
formatex(yesItem, charsmax(yesItem), "%L", LANG_PLAYER, "MENU_ITEM_YES")
formatex(noItem, charsmax(noItem), "%L", LANG_PLAYER, "MENU_ITEM_NO")
g_abMenu = menu_create(banline, "votebanonplayer_menu");
menu_additem(g_abMenu, yesItem)
menu_additem(g_abMenu, noItem)
new pplayers[32], ppnum, ptempid;
if ( 1 <= id <= gMaxPlayers )
{
switch( cs_get_user_team(id) )
{
case CS_TEAM_CT: get_players(pplayers, ppnum, "che", "CT");
case CS_TEAM_T: get_players(pplayers, ppnum, "che", "TERRORIST");
}
}
else
get_players(pplayers, ppnum, "ch");
for( new i; i<ppnum; i++ )
{
ptempid = pplayers
if (ptempid != id)
{
menu_display(ptempid, g_abMenu, 0)
}
}
set_task(7.0, "EndBanVote", id)
return PLUGIN_HANDLED
}
public EndBanVote(id) {
g_VoteProg = false
show_menu(0, 0, "^n", 1);
if(g_bVotes[0] >= g_bVotes[1])
{
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "BAN_VOTE_SUCCESS")
set_hudmessage(255, 0, 0, 0.32, 0.70, 0, 6.0, 12.0)
if ( id < 32 )
{
server_cmd("amx_banip #%d 5 ^"%L^"", get_user_userid(id), LANG_PLAYER, "VOTED_TO_BAN", PREFIX)
new nameofp[50]
get_user_name(id, nameofp, 49)
ShowSyncHudMsg(0, g_MsgSync6, "%s %L", nameofp, LANG_PLAYER, "VOTED_TO_BE_BANNED")
}
else
{
server_cmd("amx_banip ^"%s^" 15", g_LeftBansIPs[id-32])
ShowSyncHudMsg(0, g_MsgSync6, "%s %L", g_LeftBans[id-32], LANG_PLAYER, "VOTED_TO_BE_BANNED")
copy(g_LeftBans[id-32], charsmax(g_LeftBans[]), "")
copy(g_LeftBansIPs[id-32], charsmax(g_LeftBansIPs[]), "")
g_RoundsLeft[id-32] = -1
}
g_bVotes[0] = 0
g_bVotes[1] = 0
return PLUGIN_HANDLED
}
else
{
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "BAN_VOTE_FAIL")
if ( id >= 32 )
{
copy(g_LeftBans[id-32], charsmax(g_LeftBans[]), "")
copy(g_LeftBansIPs[id-32], charsmax(g_LeftBansIPs[]), "")
g_RoundsLeft[id-32] = -1
}
else
{
g_bVotes[0] = 0
g_bVotes[1] = 0
g_LeftKills[id] = 0
}
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public votebanonplayer_menu(id, menu, item) {
if( item == MENU_EXIT )
return PLUGIN_HANDLED;
g_bVotes[item]++;
return PLUGIN_HANDLED;
}
public handled(id) {
if ( cs_get_user_team(id) == CS_TEAM_UNASSIGNED )
return PLUGIN_CONTINUE
player(id)
return PLUGIN_HANDLED
}
public openSettingsMenu(id)
settingsMenu(id, 0)
public settingsMenu(id, page)
{
if ( !is_user_admin(id) )
{
console_print(id, "Only admins can access the settings menu.")
return PLUGIN_HANDLED
}
static enabled[35], disabled[35], title[79]
formatex(enabled, charsmax(enabled), "\y%L\w", LANG_PLAYER, "ENABLED")
formatex(disabled, charsmax(disabled), "\r%L\w", LANG_PLAYER, "DISABLED")
formatex(title, charsmax(title), "\r[Auto-Mix]\w %L:", LANG_PLAYER, "SETTINGS_MENU_TITLE")
new menu = menu_create(title, "settingsHandler")
new item1[79], item2[79], item3[79], item4[79], item5[79], item6[79], item7[79]
new item8[79], item9[79], item10[79], item11[79], item12[79], item13[79], item14[79]
new item15[79], item16[79], item17[79], item18[79], item19[79]
switch ( get_pcvar_num(cvar_pLeftMethod) )
{
case 0: format(item3, charsmax(item3), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM3", LANG_PLAYER, "HUD_NOT_READY")
case 1: format(item3, charsmax(item3), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM3", LANG_PLAYER, "HUD_READY")
case 2: format(item3, charsmax(item3), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM3", LANG_PLAYER, "BOTH")
}
formatex(item1, charsmax(item1), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM1", get_pcvar_num(cvar_pLeft) )
formatex(item2, charsmax(item2), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM2", get_pcvar_num(cvar_TimeLeft) )
formatex(item4, charsmax(item4), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM4", get_pcvar_num(cvar_FFvote) ? enabled : disabled )
formatex(item5, charsmax(item5), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM5", get_pcvar_num(cvar_KnifeRound) ? enabled : disabled )
formatex(item6, charsmax(item6), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM6", get_pcvar_num(cvar_DetectTK) ? enabled : disabled )
formatex(item7, charsmax(item7), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM7", get_pcvar_num(cvar_MuteMenu) ? enabled : disabled )
formatex(item8, charsmax(item8), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM8", get_pcvar_num(cvar_AllowShield) ? enabled : disabled )
formatex(item9, charsmax(item9), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM9", get_pcvar_num(cvar_MapVote) ? enabled : disabled )
formatex(item10, charsmax(item10), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM10", get_pcvar_num(cvar_Rankings) ? enabled : disabled )
formatex(item11, charsmax(item11), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM11", get_pcvar_num(cvar_TeamTag) ? enabled : disabled )
formatex(item12, charsmax(item12), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM12", get_pcvar_num(cvar_AceHud) ? enabled : disabled )
formatex(item13, charsmax(item13), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM13", get_pcvar_num(cvar_AFKKick) ? enabled : disabled )
formatex(item14, charsmax(item14), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM14")
formatex(item15, charsmax(item15), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM15")
formatex(item16, charsmax(item16), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM16", get_pcvar_num(cvar_RanksSystem) ? enabled : disabled )
formatex(item17, charsmax(item17), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM17", ( get_pcvar_num(cvar_RanksSystem) && get_pcvar_num(cvar_RanksSystemMessages) ) ? enabled : disabled )
formatex(item18, charsmax(item18), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM18")
formatex(item19, charsmax(item19), "%L", LANG_PLAYER, "SETTINGS_MENU_ITEM19")
menu_additem(menu, item1, .paccess = g_IsStarted ? ADMIN_NONE : 0 )
menu_additem(menu, item2)
menu_additem(menu, item3)
menu_additem(menu, item4)
menu_additem(menu, item5)
menu_additem(menu, item6)
menu_additem(menu, item7)
menu_additem(menu, item8)
menu_additem(menu, item9)
menu_additem(menu, item10)
menu_additem(menu, item11, .paccess = g_IsStarted ? ADMIN_NONE : 0 )
menu_additem(menu, item12)
menu_additem(menu, item13)
menu_additem(menu, item14)
menu_additem(menu, item15)
menu_additem(menu, item16)
menu_additem(menu, item17)
menu_additem(menu, item18, .paccess = gChanging ? ADMIN_NONE : 0)
menu_additem(menu, item19, .paccess = gChanging2 ? ADMIN_NONE : 0)
menu_display(id, menu, page)
return PLUGIN_HANDLED
}
public settingsHandler(id, menu, item) {
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new currentCvarNum
switch ( item )
{
case 0:
{
new playersReady = -1
if ( !( g_AfterRdy || g_IsStarted || g_MapChanged ) )
{
playersReady = 0
for ( new i = 1 ; i <= gMaxPlayers ; i++ )
{
if ( !is_user_connected(i) )
continue;
if ( g_bIsReady )
playersReady++
}
}
currentCvarNum = get_pcvar_num(cvar_pLeft)
if ( playersReady == -1 )
{
if ( currentCvarNum + 2 <= gMaxPlayers )
currentCvarNum += 2
else
currentCvarNum = 2
}
else
{
if ( currentCvarNum + 2 <= gMaxPlayers )
currentCvarNum += 2
else
{
new setToNum = 2
while ( setToNum - playersReady <= 0)
setToNum += 2
currentCvarNum = setToNum
}
}
set_pcvar_num(cvar_pLeft, currentCvarNum)
gPlayersLeft = currentCvarNum
if ( !( g_AfterRdy || g_IsStarted || g_MapChanged ) )
{
for ( new i = 1 ; i <= gMaxPlayers ; i++ )
{
if ( !is_user_connected(i) )
continue;
if ( g_bIsReady )
gPlayersLeft--
}
}
}
case 1:
{
currentCvarNum = get_pcvar_num(cvar_TimeLeft)
if ( currentCvarNum + 5 <= TIME_MAX )
currentCvarNum += 5
else
currentCvarNum = 30
set_pcvar_num(cvar_TimeLeft, currentCvarNum)
}
case 2:
{
currentCvarNum = get_pcvar_num(cvar_pLeftMethod)
if ( currentCvarNum != 2 )
currentCvarNum++
else
currentCvarNum = 0
set_pcvar_num(cvar_pLeftMethod, currentCvarNum)
}
case 3:
{
currentCvarNum = get_pcvar_num(cvar_FFvote)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_FFvote, currentCvarNum)
}
case 4:
{
currentCvarNum = get_pcvar_num(cvar_KnifeRound)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_KnifeRound, currentCvarNum)
}
case 5:
{
currentCvarNum = get_pcvar_num(cvar_DetectTK)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_DetectTK, currentCvarNum)
}
case 6:
{
currentCvarNum = get_pcvar_num(cvar_MuteMenu)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_MuteMenu, currentCvarNum)
}
case 7:
{
currentCvarNum = get_pcvar_num(cvar_AllowShield)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
if ( !currentCvarNum )
{
new players[32], pnum, tempid
get_players(players, pnum, "ch")
for ( new i ; i < pnum ; i++ )
{
tempid = players
remove_shield( tempid )
}
}
set_pcvar_num(cvar_AllowShield, currentCvarNum)
}
case 8:
{
currentCvarNum = get_pcvar_num(cvar_MapVote)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_MapVote, currentCvarNum)
}
case 9:
{
currentCvarNum = get_pcvar_num(cvar_Rankings)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_Rankings, currentCvarNum)
}
case 10:
{
currentCvarNum = get_pcvar_num(cvar_TeamTag)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_TeamTag, currentCvarNum)
}
case 11:
{
currentCvarNum = get_pcvar_num(cvar_AceHud)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_AceHud, currentCvarNum)
}
case 12:
{
currentCvarNum = get_pcvar_num(cvar_AFKKick)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_AFKKick, currentCvarNum)
}
case 13: ReadyPosMenu(id)
case 14: NotReadyPosMenu(id)
case 15:
{
currentCvarNum = get_pcvar_num(cvar_RanksSystem)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
if ( !currentCvarNum )
set_pcvar_num(cvar_RanksSystemMessages, 0)
else
set_pcvar_num(cvar_RanksSystemMessages, 1)
set_pcvar_num(cvar_RanksSystem, currentCvarNum)
}
case 16:
{
currentCvarNum = get_pcvar_num(cvar_RanksSystemMessages)
if ( currentCvarNum )
currentCvarNum = 0
else
currentCvarNum = 1
set_pcvar_num(cvar_RanksSystemMessages, currentCvarNum)
if ( !get_pcvar_num(cvar_RanksSystem) )
set_pcvar_num(cvar_RanksSystemMessages, 0)
}
case 17: PointsPricesMenu(id)
case 18: RanksPricesMenu(id)
}
if ( item == 13 || item == 14 || item == 17 || item == 18 )
return PLUGIN_HANDLED
if ( item >= 7 && item <= 13 )
settingsMenu(id, 1)
else if ( item >= 14 && item <= 20 )
settingsMenu(id, 2)
else
settingsMenu(id, 0)
return PLUGIN_HANDLED
}
public ReadyPosMenu(id)
{
if ( !is_user_connected(id) )
return;
new Title[125]
formatex(Title, charsmax(Title), "%L", LANG_PLAYER, "READY_POS_TITLE", get_pcvar_float(cvar_ReadyXPos), get_pcvar_float(cvar_ReadyYPos))
new rPosMenu = menu_create(Title, "ReadyPosHandler")
new item[16]
formatex(item, charsmax(item), "%L", LANG_PLAYER, "UP")
menu_additem(rPosMenu, item)
formatex(item, charsmax(item), "%L", LANG_PLAYER, "DOWN")
menu_additem(rPosMenu, item)
formatex(item, charsmax(item), "%L", LANG_PLAYER, "RIGHT")
menu_additem(rPosMenu, item)
formatex(item, charsmax(item), "%L", LANG_PLAYER, "LEFT")
menu_additem(rPosMenu, item)
formatex(item, charsmax(item), "%L", LANG_PLAYER, "BACK")
menu_setprop(rPosMenu, MPROP_EXITNAME, item)
menu_display(id, rPosMenu)
}
public ReadyPosHandler(id, menu, item) {
if( item == MENU_EXIT )
{
settingsMenu(id, 1)
return PLUGIN_HANDLED;
}
new Float:setCvarNum
switch ( item )
{
case 0: setCvarNum = get_pcvar_float(cvar_ReadyYPos) - 0.01
case 1: setCvarNum = get_pcvar_float(cvar_ReadyYPos) + 0.01
case 2: setCvarNum = get_pcvar_float(cvar_ReadyXPos) + 0.01
case 3: setCvarNum = get_pcvar_float(cvar_ReadyXPos) - 0.01
}
set_pcvar_float(cvar_ReadyYPos, setCvarNum)
ReadyPosMenu(id)
return PLUGIN_HANDLED
}
public NotReadyPosMenu(id)
{
if ( !is_user_connected(id) )
return;
new Title[125]
formatex(Title, charsmax(Title), "%L", LANG_PLAYER, "NOTREADY_POS_TITLE", get_pcvar_float(cvar_NotReadyXPos), get_pcvar_float(cvar_NotReadyYPos))
new rPosMenu = menu_create(Title, "NotReadyPosHandler")
new item[16]
formatex(item, charsmax(item), "%L", LANG_PLAYER, "UP")
menu_additem(rPosMenu, item)
formatex(item, charsmax(item), "%L", LANG_PLAYER, "DOWN")
menu_additem(rPosMenu, item)
formatex(item, charsmax(item), "%L", LANG_PLAYER, "RIGHT")
menu_additem(rPosMenu, item)
formatex(item, charsmax(item), "%L", LANG_PLAYER, "LEFT")
menu_additem(rPosMenu, item)
formatex(item, charsmax(item), "%L", LANG_PLAYER, "BACK")
menu_setprop(rPosMenu, MPROP_EXITNAME, item)
menu_display(id, rPosMenu)
}
public NotReadyPosHandler(id, menu, item) {
if( item == MENU_EXIT )
{
settingsMenu(id, 2)
return PLUGIN_HANDLED;
}
new Float:setCvarNum
switch ( item )
{
case 0: setCvarNum = get_pcvar_float(cvar_NotReadyYPos) - 0.01
case 1: setCvarNum = get_pcvar_float(cvar_NotReadyYPos) + 0.01
case 2: setCvarNum = get_pcvar_float(cvar_NotReadyXPos) + 0.01
case 3: setCvarNum = get_pcvar_float(cvar_NotReadyXPos) - 0.01
}
set_pcvar_float(cvar_NotReadyYPos, setCvarNum)
NotReadyPosMenu(id)
return PLUGIN_HANDLED
}
public PointsPricesMenu(id)
{
if ( !is_user_connected(id) )
return;
new menuTitle[65]
formatex(menuTitle, charsmax(menuTitle), "\y[Auto-Mix]\w %L", LANG_PLAYER, "POINTS_PRICES_MENU_TITLE")
new pointsMenu = menu_create(menuTitle, "pointsHandler")
new item1[79], item2[79], item3[79], item4[79], item5[79], item6[79], item7[79]
new item8[79], item9[79], item10[79], item11[79], item12[79]
formatex(item1, charsmax(item1), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM1", get_pcvar_num(cvar_KillPoints))
formatex(item2, charsmax(item2), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM2", get_pcvar_num(cvar_KnifePoints))
formatex(item3, charsmax(item3), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM3", get_pcvar_num(cvar_WinsMatchPoints))
formatex(item4, charsmax(item4), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM4", get_pcvar_num(cvar_PlaysUntilEndPoints))
formatex(item5, charsmax(item5), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM5", get_pcvar_num(cvar_LeavesMatchPoints))
formatex(item6, charsmax(item6), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM6", get_pcvar_num(cvar_LeavesMatchTime))
formatex(item7, charsmax(item7), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM7", get_pcvar_num(cvar_TeamKillPoints))
formatex(item8, charsmax(item8), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM8", get_pcvar_num(cvar_BombPlantPoints))
formatex(item9, charsmax(item9), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM9", get_pcvar_num(cvar_BombDefusePoints))
formatex(item10, charsmax(item10), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM10", get_pcvar_num(cvar_KillLosePoints))
formatex(item11, charsmax(item11), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM11", get_pcvar_num(cvar_KnifeLosePoints))
formatex(item12, charsmax(item12), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_ITEM12", get_pcvar_num(cvar_LosesMatchPoints))
menu_additem(pointsMenu, item1)
menu_additem(pointsMenu, item2)
menu_additem(pointsMenu, item3)
menu_additem(pointsMenu, item4)
menu_additem(pointsMenu, item5)
menu_additem(pointsMenu, item6)
menu_additem(pointsMenu, item7)
menu_additem(pointsMenu, item8)
menu_additem(pointsMenu, item9)
menu_additem(pointsMenu, item10)
menu_additem(pointsMenu, item11)
menu_additem(pointsMenu, item12)
new ExitButton[16]
formatex(ExitButton, charsmax(ExitButton), "%L", LANG_PLAYER, "MENU_ITEM_BACK")
menu_setprop(pointsMenu, MPROP_EXITNAME, ExitButton)
menu_display(id, pointsMenu)
}
public pointsHandler(id, menu, item) {
if( item == MENU_EXIT )
{
settingsMenu(id, 2)
return PLUGIN_HANDLED;
}
gChanging = item
gChangerID = id
new menuTitle[128], menuTitle2[128]
formatex(menuTitle, charsmax(menuTitle), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_DIRECTIONS")
formatex(menuTitle2, charsmax(menuTitle2), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_DIRECTIONS2")
show_menu(id, MENU_KEY_0, ( item == 6 ) ? menuTitle : menuTitle2, -1, "setprices menu")
return PLUGIN_HANDLED
}
public RanksPricesMenu(id)
{
if ( !is_user_connected(id) )
return;
new menuTitle[65]
formatex(menuTitle, charsmax(menuTitle), "\y[Auto-Mix]\w %L", LANG_PLAYER, "RANKS_PRICES_MENU_TITLE")
new pointsMenu = menu_create(menuTitle, "ranksHandler")
new item1[79], item2[79], item3[79], item4[79], item5[79]
formatex(item1, charsmax(item1), "%L [\y%d\w]", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM1", get_pcvar_num(cvar_BeginnerPoints))
formatex(item2, charsmax(item2), "%L [\y%d\w]", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM2", get_pcvar_num(cvar_RegularPoints))
formatex(item3, charsmax(item3), "%L [\y%d\w]", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM3", get_pcvar_num(cvar_VeteranPoints))
formatex(item4, charsmax(item4), "%L [\y%d\w]", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM4", get_pcvar_num(cvar_ProPoints))
formatex(item5, charsmax(item5), "%L [\y%d\w]", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM5", get_pcvar_num(cvar_HardCorePoints))
menu_additem(pointsMenu, item1)
menu_additem(pointsMenu, item2)
menu_additem(pointsMenu, item3)
menu_additem(pointsMenu, item4)
menu_additem(pointsMenu, item5)
new ExitButton[16]
formatex(ExitButton, charsmax(ExitButton), "%L", LANG_PLAYER, "MENU_ITEM_BACK")
menu_setprop(pointsMenu, MPROP_EXITNAME, ExitButton)
menu_display(id, pointsMenu)
}
public ranksHandler(id, menu, item) {
if( item == MENU_EXIT )
{
settingsMenu(id, 2)
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new helpText[78]
formatex(helpText, charsmax(helpText), "%L", LANG_PLAYER, "POINTS_PRICES_MENU_DIRECTIONS2")
new menuOption = str_to_num(data)
gChanging2 = menuOption
gChangerID2 = id
show_menu(id, MENU_KEY_0, helpText, -1, "setprices menu")
return PLUGIN_HANDLED
}
public menuHandler(id, key)
{
gChanging = 0
gChanging2 = 0
gChangerID = 0
gChangerID2 = 0
return PLUGIN_HANDLED
}
public plugin_cfg() {
SetCheckFilled()
server_cmd("exec serverautomix.cfg")
DisplayCommands()
set_pcvar_string(cvar_humans_join_team, "")
if (!file_exists(gPug_ini_file))
{
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "PUG_INI_ERROR")
return PLUGIN_HANDLED
}
switch ( get_pug_state() )
{
case 0:
{
gEntShowLeft = create_entity("info_target")
entity_set_string(gEntShowLeft, EV_SZ_classname, "show_left_ent")
register_think("show_left_ent", "ShowLeft")
entity_set_float(gEntShowLeft, EV_FL_nextthink, halflife_time() + 1.0)
return PLUGIN_HANDLED
}
case 1:
{
g_MapChanged = true
new taskId = scanForTaskID()
set_task(20.0, "TeamsVote", taskId)
}
case 2:
{
g_MapChanged = true
g_CustomGame = true
set_pug_state(1)
new taskId = scanForTaskID()
set_task(20.0, "TeamsVote", taskId)
}
}
return PLUGIN_CONTINUE
}
public SetCheckFilled() {
new taskId = scanForTaskID()
set_task(5.0, "CheckFilled", taskId)
}
public CheckFilled() {
new players = get_playersnum()
for ( new i = 1 ; i <= gMaxPlayers ; i++ )
{
if ( !is_user_connected(i) )
continue;
if ( is_user_hltv(i) || is_user_bot(i) )
players--
}
if (players >= get_pcvar_num(cvar_pLeft))
{
new rnd = random_num(99, 9999)
new pass[10]
num_to_str(rnd, pass, 9)
//set_pcvar_string(cvar_sv_password, pass)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "SERVER_PASSWORD_PROTECTED")
new tokick = players - get_pcvar_num(cvar_pLeft)
for (new kick; kick<tokick ; kick++)
{
new playeract = random(get_pcvar_num(cvar_pLeft))
while ( !is_user_connected(playeract) || !is_user_bot(playeract) || !is_user_hltv(playeract) )
{
playeract = random(get_pcvar_num(cvar_pLeft))
}
server_cmd("kick # %d %s %L", get_user_userid(playeract), PREFIX, LANG_PLAYER, "SERVER_FULL")
}
}
return PLUGIN_CONTINUE
}
public DisplayCommands() {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "SHOW_INFO")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "SHOW_INFO_2")
new taskId = scanForTaskID()
set_task(g_IsStarted ? 50.0 : 300.0, "DisplayCommands", taskId)
}
public round_end() {
if ( g_Restart )
return PLUGIN_HANDLED
TKRoundsLeft()
if ( g_bFFTKStop )
{
g_bFFTKStop = false
set_pcvar_num(cvar_mp_friendlyfire, 1)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_ON")
}
if (g_KnifeRound)
{
new Players[32], pNum, ptn, pctn;
get_players(Players, pNum, "ch")
for ( new i ; i < pNum ; i++ ) {
new tempid = Players
if ( !is_user_alive(tempid) )
continue;
else if ( cs_get_user_team(tempid) == CS_TEAM_T )
ptn++;
else if ( cs_get_user_team(tempid) == CS_TEAM_CT )
pctn++;
}
new WinningTeam
if (ptn > pctn)
{
client_print(0, print_chat, "%s %L %L", PREFIX, LANG_PLAYER, ( get_pcvar_num(cvar_TeamTag) ? "TEAM_A" : "TERRORISTS" ), LANG_PLAYER, "KNIFE_ROUND_WON")
set_hudmessage(255, 0, 0, 0.40, 0.71, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync6, "%L - %L", LANG_PLAYER, ( get_pcvar_num(cvar_TeamTag) ? "TEAM_A" : "TERRORISTS" ), LANG_PLAYER, "KNIFE_ROUND_WINNERS")
g_Twon = true
WinningTeam = T_WIN
}
else if (pctn > ptn)
{
client_print(0, print_chat, "%s %L %L", PREFIX, LANG_PLAYER, ( get_pcvar_num(cvar_TeamTag) ? "TEAM_B" : "COUNTER_TERRORISTS" ), LANG_PLAYER, "KNIFE_ROUND_WON")
set_hudmessage(255, 0, 0, 0.40, 0.71, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync6, "%L - %L", LANG_PLAYER, ( get_pcvar_num(cvar_TeamTag) ? "TEAM_B" : "COUNTER_TERRORISTS" ), LANG_PLAYER, "KNIFE_ROUND_WINNERS")
WinningTeam = CT_WIN
}
else
{
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "KNIFE_ROUND_WITHDRAW")
set_hudmessage(255, 0, 0, 0.40, 0.71, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync6, "%L", LANG_PLAYER, "KNIFE_ROUND_WITHDRAWN_HUD")
new taskId = scanForTaskID()
set_task(3.0, "SettingsAfter", taskId)
return PLUGIN_CONTINUE
}
KnifeSwitch(WinningTeam)
return PLUGIN_CONTINUE
}
if (g_IsStarted)
{
new players[32], pnum, tempid;
new numTt, numCtt;
get_players(players, pnum, "ch")
if ( !( (get_playersnum() != get_pcvar_num(cvar_pLeft)) || (get_pcvar_num(cvar_pLeft) != 10) ) )
{
for ( new i ; i < pnum ; i++ )
{
tempid = players
switch ( cs_get_user_team(tempid) )
{
case CS_TEAM_T: numTt++
case CS_TEAM_CT: numCtt++
}
}
for (new i ; i < pnum ; i++)
{
tempid = players
g_LeftKills[tempid] = (g_LeftKills[tempid]/3)*2
if ( g_KillsAce[tempid] < 4 || get_playersnum() != 10 || !get_pcvar_num(cvar_AceHud) )
{
g_KillsAce[tempid] = 0
continue;
}
if ( cs_get_user_team(tempid) == CS_TEAM_T || cs_get_user_team(tempid) == CS_TEAM_CT )
{
if (g_KillsAce[tempid] == 4)
{
new name[32]
get_user_name(tempid, name, 31)
set_hudmessage(255, 255, 255, 0.07, 0.69, 0, 6.0, 12.0)
show_hudmessage(0, "%L", LANG_PLAYER, "DID_A_MINIACE", name)
}
else if (g_KillsAce[tempid] == 5)
{
new name[32]
get_user_name(tempid, name, 31)
set_hudmessage(255, 255, 255, 0.07, 0.69, 0, 6.0, 12.0)
show_hudmessage(0, "%L", LANG_PLAYER, "DID_AN_ACE", name)
}
}
g_KillsAce[tempid] = 0
}
}
}
if ( !g_CustomGame || true )
{
if (g_IsStarted)
{
new numT, numCt;
for ( new i = 1 ; i <= gMaxPlayers ; i++ )
{
if ( is_user_connected(i) )
{
if ( cs_get_user_team(i) == CS_TEAM_T )
numT++
else if ( cs_get_user_team(i) == CS_TEAM_CT )
numCt++
}
}
if ( numT <= (get_pcvar_num(cvar_pLeft)/2) - 2 || numCt <= (get_pcvar_num(cvar_pLeft)/2) - 2 )
{
if ( g_NotBalanced == 2 )
{
if (numT > numCt)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "T_AUTO_WON")
else if (numCt > numT)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CT_AUTO_WON")
else if (numCt == numT)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NO_TEAM_WON")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "ENDING_MATCH")
new taskId = scanForTaskID()
set_task(5.0, "EndMatch", taskId)
g_NotBalanced = 0
}
else
{
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NOT_ENOUGH_TEAMMATES", (get_pcvar_num(cvar_pLeft)/2) - 2)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NOT_ENOUGH_TEAMMATES2", 2 - g_NotBalanced )
g_NotBalanced++
}
}
else
g_NotBalanced = 0;
}
}
return PLUGIN_HANDLED
}
public TKRoundsLeft()
{
for ( new i ; i < sizeof(g_RoundsLeft) ; i++ )
{
if ( g_RoundsLeft != -1 )
g_RoundsLeft--
}
}
public LR() {
set_hudmessage(255, 255, 255, 0.07, 0.69, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync6, "%L", LANG_PLAYER, "LAST_ROUND")
}
public scndhalf() {
server_cmd("sv_restart 1")
new taskId = scanForTaskID()
set_task(3.0, "showscnd", taskId)
}
public showscnd() {
set_hudmessage(255, 255, 255, 0.07, 0.69, 0, 6.0, 18.0)
ShowSyncHudMsg(0, g_MsgSync3, "%L", LANG_PLAYER, "SECOND_HALF_STARTED")
return PLUGIN_HANDLED
}
public Event_TeamScore() {
if ( g_Restart )
return PLUGIN_HANDLED
if (g_IsStarted)
{
read_data(1, g_szTeamName, 1)
g_iTeam = (g_szTeamName[0] == 'T') ? 0 : 1
g_iAltScore = read_data(2)
g_iScoreOffset = g_iAltScore - g_iLastTeamScore[g_iTeam]
if(g_iScoreOffset > 0)
{
g_iScore[g_iTeam] += g_iScoreOffset
}
g_iLastTeamScore[g_iTeam] = g_iAltScore
if (g_iScore[0] + g_iScore[1] == 14)
{
new taskId = scanForTaskID()
set_task(10.0, "LR", taskId)
}
else if (g_iScore[0] + g_iScore[1] == 15)
{
if (g_bStop2)
{
return PLUGIN_HANDLED;
}
g_bStop2 = true
SwitchTeams()
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "SWITCH_TEAMS")
new taskId = scanForTaskID()
set_task(10.0, "scndhalf", taskId)
}
else if ((g_iScore[0] == 16) || (g_iScore[1] == 16))
{
if (g_bStop)
{
return PLUGIN_HANDLED
}
g_bStop = true
EndMatch()
return PLUGIN_HANDLED
}
else if ((g_iScore[0] == 15) || (g_iScore[1] == 15))
{
new taskId = scanForTaskID()
set_task(10.0, "LRFif", taskId)
return PLUGIN_HANDLED
}
ClientCommand_SayScore()
}
return PLUGIN_HANDLED
}
public LRFif() {
if ((g_iScore[1] == 16) || (g_iScore[0] == 16))
return PLUGIN_HANDLED
set_hudmessage(255, 255, 255, 0.06, 0.62, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync6, "%L (%L) %d - %d (%L)", LANG_PLAYER, "LAST_ROUND", LANG_PLAYER, ( get_pcvar_num(cvar_TeamTag) ? "TEAM_A" : "COUNTER_TERRORISTS" ), g_iScore[g_Twon ? 0 : 1], g_iScore[g_Twon ? 1 : 0], LANG_PLAYER, ( get_pcvar_num(cvar_TeamTag) ? "TEAM_B" : "TERRORISTS" ) )
return PLUGIN_HANDLED
}
public ClientCommand_SayScore() {
if (g_Twon)
{
if (g_bSecondHalf)
{
if (g_bDidScore)
{
showscore(0)
g_bDidScore = false
}
else
g_bDidScore = true
}
else
{
if (g_bDidScore)
{
showscore(0)
g_bDidScore = false
}
else
g_bDidScore = true
}
}
else
{
if (g_bSecondHalf)
{
if (g_bDidScore)
{
showscore(0)
g_bDidScore = false
}
else
g_bDidScore = true
}
else
{
if (g_bDidScore)
{
showscore(0)
g_bDidScore = false
}
else
g_bDidScore = true
}
}
return PLUGIN_HANDLED
}
public client_disconnect(id) {
if ( is_user_bot(id) || is_user_hltv(id) || !( 1 <= id <= gMaxPlayers ) )
return PLUGIN_HANDLED
if ( id == gChangerID )
{
gChangerID = 0
gChanging = 0
}
else if ( id == gChangerID2 )
{
gChangerID2 = 0
gChanging2 = 0
}
if ( g_IsStarted )
{
g_PugLeaves++
DidTK(id)
if ( get_pcvar_num(cvar_RanksSystem) )
{
gPoints[id] -= get_pcvar_num(cvar_LeavesMatchPoints)
enterLeaveRecord(id)
}
}
CheckEmpty()
clear_list(id)
gDidPlayUntilEnd[id] = false
g_LeftVotes[id] = 0
g_TotalKills[id] = 0
g_TotalDeaths[id] = 0
g_BombPlants[id] = 0
g_BombDefusions[id] = 0
if ( g_givenChance[id] )
get_user_authid(id, g_givenChanceSteamIDs[g_givenTimes++], charsmax(g_givenChanceSteamIDs[]))
g_givenChance[id] = false
if (g_bIsReady[id])
{
gPlayersLeft++
}
g_bIsReady[id] = false
remove_task(id)
remove_task(id+SET_CONST_TASKID)
return PLUGIN_HANDLED
}
public client_connect(id) {
if ( is_user_bot(id) || is_user_hltv(id) || (!is_user_connected(id) && !is_user_connecting(id)) || !( 1 <= id <= gMaxPlayers ) )
return PLUGIN_HANDLED;
g_afktime[id] = 0.0
g_LeftVotes[id] = 0
gTypedCommand[id] = 0.0
if (!file_exists(gPug_ini_file))
{
client_print(0, print_chat, "%s %L", PREFIX, "PUG_INI_ERROR")
return PLUGIN_HANDLED
}
if (get_pug_state() == 1)
{
g_LeftKills[id] = 0
return PLUGIN_HANDLED
}
if (g_bCpt && is_user_connected(id))
{
if (cs_get_user_team(id) != CS_TEAM_UNASSIGNED)
{
cs_set_user_team(id, CS_TEAM_SPECTATOR)
return PLUGIN_HANDLED
}
else
set_task(1.0, "client_connect", id)
return PLUGIN_HANDLED
}
if ( !( g_AfterRdy || g_IsStarted ) )
{
g_KillsAce[id] = 0
g_bIsReady[id] = false
remove_task(id)
g_iTimeLeft[id] = get_pcvar_num(cvar_TimeLeft)
g_LeftKills[id] = 0
ToSetTaskToInfo(id)
}
return PLUGIN_HANDLED
}
public client_authorized(id)
{
if ( is_user_hltv(id) || is_user_bot(id) )
return;
LoadStats(id)
new authID[64]
get_user_authid(id, authID, charsmax(authID))
for ( new i ; i < g_givenTimes ; i++ )
{
if ( equal(authID, g_givenChanceSteamIDs) )
{
for ( new z ; z < sizeof(g_givenChanceSteamIDs[]) ; z++ )
g_givenChanceSteamIDs[z] = 0
for ( new z = i ; z < g_givenTimes ; z++ )
copy(g_givenChanceSteamIDs[z], charsmax(g_givenChanceSteamIDs[]), g_givenChanceSteamIDs[z+1])
for ( new z ; z < sizeof(g_givenChanceSteamIDs[]) ; z++ )
g_givenChanceSteamIDs[g_givenTimes][z] = 0
g_givenTimes--
g_givenChance[id] = true
}
}
if ( g_IsStarted )
set_task(0.1, "returnPointsIfDeserves", id)
}
public DidTK(id)
{
if ( g_LeftKills[id] >= 40 )
{
new ip[64], name[64], szAdd[128]
get_user_ip(id, ip, charsmax(ip), 1)
get_user_name(id, name, charsmax(name))
for ( new i ; i < sizeof(g_LeftBans) ; i++ )
{
if ( equali(g_LeftBansIPs, ip) )
break;
else if ( !g_LeftBans[0] && !g_LeftBansIPs[0] )
{
formatex(szAdd, charsmax(szAdd), "%s - [\r%L\w]", name, LANG_PLAYER, "TK_BAN_MENU_ITEM")
copy(g_LeftBans, charsmax(g_LeftBans[]), szAdd)
copy(g_LeftBansIPs, charsmax(g_LeftBansIPs[]), ip)
g_RoundsLeft[id] = 3
}
}
}
}
public enterLeaveRecord(id)
{
get_user_authid(id, gLeftSteamIDs[gLeftTimes], charsmax(gLeftSteamIDs[]))
gLastTime[gLeftTimes++] = get_systime()
}
public returnPointsIfDeserves(id)
{
if ( !is_user_connected(id) || !( 1 <= id <= gMaxPlayers ) )
return;
new authid[64]
get_user_authid(id, authid, charsmax(authid))
for ( new i ; i < gLeftTimes ; i++ )
{
if ( equali(authid, gLeftSteamIDs) )
{
if ( get_systime() - gLastTime <= get_pcvar_num(cvar_LeavesMatchTime) )
{
gPoints[id] += get_pcvar_num(cvar_LeavesMatchPoints)
SaveStats(id)
}
for ( new z ; z < sizeof(gLeftSteamIDs[]) ; z++ )
gLeftSteamIDs[z] = 0
for ( new z = i ; z < gLeftTimes ; z++ )
copy(gLeftSteamIDs[z], charsmax(gLeftSteamIDs[]), gLeftSteamIDs[z+1])
for ( new z ; z < sizeof(gLeftSteamIDs[]) ; z++ )
gLeftSteamIDs[gLeftTimes][z] = 0
for ( new z = i ; z < sizeof(gLastTime) ; z++ )
gLastTime[z] = gLastTime[z+1]
gLastTime[gLeftTimes--] = 0
}
}
}
public CheckEmpty() {
if (get_maxplayers() == get_pcvar_num(cvar_pLeft))
return PLUGIN_HANDLED
new players[32], pnum
get_players(players, pnum, "ch")
if (pnum == get_pcvar_num(cvar_pLeft))
{
//set_pcvar_string(cvar_sv_password, "")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "SERVER_PASSWORD_REMOVED")
}
return PLUGIN_CONTINUE
}
public CheckFull(id) {
if (get_maxplayers() == get_pcvar_num(cvar_pLeft))
return PLUGIN_HANDLED
new players[32], pnum
get_players(players, pnum, "ch")
if ( pnum == get_pcvar_num(cvar_pLeft) && get_playersnum() != get_maxplayers() )
{
new rnd = random_num(99, 9999)
new pass[10]
num_to_str(rnd, pass, 9)
//set_pcvar_string(cvar_sv_password, pass)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "SERVER_PASSWORD_PROTECTED")
new players[32], pnum, tempid;
get_players(players, pnum, "ch")
for (new full; full<pnum ; full++)
{
players[full] = tempid
if (is_user_connecting(tempid))
server_cmd("kick # %d %s %L", get_user_userid(tempid), PREFIX, LANG_PLAYER, "SERVER_FULL")
}
}
else if (pnum > get_pcvar_num(cvar_pLeft))
{
server_cmd("kick # %d %s %L", get_user_userid(id), PREFIX, LANG_PLAYER, "SERVER_FULL")
}
return PLUGIN_HANDLED
}
public CheckNow() {
client_print(0, print_console, "get_playersnum() == %d", get_playersnum())
if (get_playersnum() < get_pcvar_num(cvar_pLeft))
{
//set_pcvar_string(cvar_sv_password, "")
return PLUGIN_HANDLED
}
else if (get_playersnum() > get_pcvar_num(cvar_pLeft))
{
new tokick = get_playersnum() - get_pcvar_num(cvar_pLeft)
for (new kick; kick<tokick ; kick++)
{
new playeract = random(get_pcvar_num(cvar_pLeft))
while (!is_user_connected(playeract))
{
playeract = random(get_pcvar_num(cvar_pLeft))
}
server_cmd("kick %d %s %L", get_user_userid(playeract), PREFIX, LANG_PLAYER, "SERVER_FULL")
}
}
new rnd = random_num(99, 9999)
new pass[10]
num_to_str(rnd, pass, 9)
//set_pcvar_string(cvar_sv_password, pass)
return PLUGIN_CONTINUE
}
public DoAgain(id) {
if ( !is_user_connected(id) || !( 1 <= id <= gMaxPlayers ) )
return PLUGIN_HANDLED
if (!file_exists(gPug_ini_file))
{
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "PUG_INI_ERROR")
return PLUGIN_HANDLED
}
if (get_pug_state() == 1)
{
g_LeftKills[id] = 0
return PLUGIN_HANDLED
}
if ( !g_AfterRdy && !g_IsStarted)
{
g_KillsAce[id] = 0
g_bIsReady[id] = false
remove_task(id)
g_iTimeLeft[id] = get_pcvar_num(cvar_TimeLeft)
g_LeftKills[id] = 0
ToSetTaskToInfo(id)
}
return PLUGIN_HANDLED
}
public client_putinserver(id) {
g_afktime[id] = 0.0
if (is_user_bot(id) || is_user_hltv(id))
return PLUGIN_HANDLED;
if ( get_playersnum() == 1 && ( g_IsStarted || g_AfterRdy || g_KnifeRound ) )
{
server_cmd("restart")
return PLUGIN_HANDLED
}
if ( get_playersnum() == 1 && !g_AfterRdy && !g_IsStarted )
entity_set_float(gEntShowLeft, EV_FL_nextthink, halflife_time() + 1.0)
CheckFull(id)
clear_list(id)
if (g_IsStarted || g_AfterRdy || g_KnifeRound)
{
g_LeftKills[id] = 0
MoveFromSpec(id)
return PLUGIN_HANDLED
}
set_task(30.0, "CheckUnAssigned", id)
return PLUGIN_HANDLED
}
public CheckUnAssigned(id) {
if ( !is_user_connected(id) )
return PLUGIN_HANDLED
if (cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
{
new name[50]
get_user_name(id, name, 49)
server_cmd("kick # %d %s %L", get_user_userid(id), PREFIX, LANG_PLAYER, "AFK_LOGIN")
client_print(0, print_chat, "%s %s %L", PREFIX, name, LANG_PLAYER, "CLIENT_AFK_KICKED")
}
return PLUGIN_HANDLED
}
public ShowInfo(id) {
id -= SET_CONST_TASKID
if ( !is_user_connected(id) || !( 1 <= id <= gMaxPlayers ) )
return PLUGIN_HANDLED
static hostname[64]
get_cvar_string("hostname", hostname, 63)
if (g_bIsReady[id] || g_IsStarted || g_AfterRdy || g_iTimeLeft[id] < 0 )
{
remove_task(id+SET_CONST_TASKID)
remove_task(id)
return PLUGIN_HANDLED
}
set_hudmessage(255, 255, 255, 0.23, 0.265, 0, 6.0, 1.0)
ShowSyncHudMsg(id, g_MsgSync4, "%L", LANG_PLAYER, "PLAYER_PERSONAL_INFO", hostname, g_iTimeLeft[id])
return PLUGIN_CONTINUE
}
public Continue(id) {
if ( !is_user_connected(id) || !( 1 <= id <= gMaxPlayers ) || is_user_bot(id) || is_user_hltv(id) )
return PLUGIN_HANDLED
if (g_IsStarted || g_AfterRdy)
{
return PLUGIN_HANDLED
}
if (g_bIsReady[id])
{
return PLUGIN_HANDLED
}
g_iTimeLeft[id] -= 1
switch(g_iTimeLeft[id]) {
case 120: client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TYPE_READY", g_iTimeLeft[id])
case 90: client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TYPE_READY", g_iTimeLeft[id])
case 60: client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TYPE_READY", g_iTimeLeft[id])
case 30: {
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TYPE_READY", g_iTimeLeft[id])
set_hudmessage(42, 127, 255, 0.07, 0.70, 0, 6.0, 12.0)
ShowSyncHudMsg(id, g_MsgSync, "30 %L", LANG_PLAYER, "TYPE_READY_HUD")
}
case 10: {
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TYPE_READY", g_iTimeLeft[id])
set_hudmessage(42, 127, 255, 0.07, 0.70, 0, 6.0, 12.0)
ShowSyncHudMsg(id, g_MsgSync, "10 %L", LANG_PLAYER, "TYPE_READY_HUD")
}
case 0: {
if ( is_user_connecting(id) )
DoAgain(id)
else {
new playername[32]
get_user_name(id, playername, 31)
server_cmd("amx_banip #%d 1 ^"%s %L^"", get_user_userid(id), PREFIX, LANG_PLAYER, "ADD_TIME_OVER", get_pcvar_num(cvar_TimeLeft))
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CLIENT_ADD_KICKED", playername, get_pcvar_num(cvar_TimeLeft))
}
}
}
return PLUGIN_HANDLED
}
public CrashAttempt(id) {
if ( !( 1 <= id <= gMaxPlayers ) || !is_user_connected(id) )
return
if ( get_gametime() - gTypedCommand[id] <= 1.0 ) {
gTypedCommand[id] = get_gametime()
return
}
gTypedCommand[id] = get_gametime()
}
public Prepare(id) {
if (g_AfterRdy || g_IsStarted || g_MapChanged) {
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_ALREADY_STARTED")
return PLUGIN_HANDLED
}
if( g_bIsReady[id] ) {
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "ALREADY_TYPED_ADD")
return PLUGIN_HANDLED
}
else {
CrashAttempt(id)
new playername[32]
get_user_name(id, playername, 31)
g_bIsReady[id] = true
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "YOU_ARE_READY")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "HE_IS_READY", playername)
gPlayersLeft--
remove_task(id)
}
if (gPlayersLeft != 0)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "PLAYERS_LEFT", gPlayersLeft)
else {
g_AfterRdy = true
removeAllTasks()
new taskId = scanForTaskID()
if ( get_pcvar_num(cvar_MapVote) )
{
for ( new i ; i < 3 ; i++ )
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MAP_VOTE_BEGINS")
set_task(10.0, "StartVote", taskId)
}
else
{
for ( new i ; i < 3 ; i++ )
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_VOTE_BEGINS")
set_task(10.0, "TeamsVote", taskId)
}
}
return PLUGIN_HANDLED
}
public forcedStart_AdminCmd(id)
{
if ( !is_user_admin(id) )
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "ADMINS_ONLY")
return PLUGIN_HANDLED
}
new taskId = scanForTaskID()
g_AfterRdy = true
g_CustomGame = true
if ( get_pcvar_num(cvar_MapVote) )
{
for ( new i ; i < 3 ; i++ )
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MAP_VOTE_BEGINS")
set_task(10.0, "StartVote", taskId)
}
else
{
for ( new i ; i < 3 ; i++ )
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_VOTE_BEGINS")
set_task(10.0, "TeamsVote", taskId)
}
return PLUGIN_CONTINUE
}
public forcedStop_AdminCmd(id)
{
if ( !is_user_admin(id) )
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "ADMINS_ONLY")
return PLUGIN_HANDLED
}
new pName[64]
get_user_name(id, pName, charsmax(pName))
set_hudmessage(255, 0, 0, 0.28, 0.64, 1, 6.0, 12.0)
show_hudmessage(id, "%L", LANG_PLAYER, "MATCH_STOPPED", pName)
set_pug_state(0)
EndMatch()
return PLUGIN_CONTINUE
}
public ToSetTaskToInfo(id)
{
set_task(1.0, "ShowInfo", id+SET_CONST_TASKID, .flags="a", .repeat=130)
set_task(1.0, "Continue", id, .flags="a", .repeat=130)
}
public unPrepare(id) {
if (g_AfterRdy || g_IsStarted || g_MapChanged) {
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_ALREADY_STARTED")
return PLUGIN_HANDLED
}
if (g_bIsReady[id]) {
CrashAttempt(id)
gPlayersLeft++
g_bIsReady[id] = false
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "YOU_ARE_NOT_READY")
g_iTimeLeft[id] = get_pcvar_num(cvar_TimeLeft)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "PLAYERS_LEFT", gPlayersLeft)
ToSetTaskToInfo(id)
}
else
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "ADD_NOT_TYPED")
return PLUGIN_HANDLED
}
public ShowLeft(ent) {
if ( g_IsStarted || g_AfterRdy )
{
entity_set_float(gEntShowLeft, EV_FL_nextthink, halflife_time() + 99999999.0)
return PLUGIN_HANDLED
}
if ( !get_playersnum() )
{
entity_set_float(gEntShowLeft, EV_FL_nextthink, halflife_time() + 99999999.0)
return PLUGIN_HANDLED
}
if ( !get_pcvar_num(cvar_pLeftMethod) || get_pcvar_num(cvar_pLeftMethod) == 2 )
showNotReady()
if ( get_pcvar_num(cvar_pLeftMethod) )
showReady()
entity_set_float(gEntShowLeft, EV_FL_nextthink, halflife_time() + 1.0)
return PLUGIN_HANDLED
}
public showNotReady()
{
if (gPlayersLeft != 0)
{
new players[32], pnum, tempid;
get_players(players, pnum, "ch");
for( new i; i<pnum; i++ ) {
tempid = players;
if (g_bIsReady[tempid] == false) {
new playername[32]
get_user_name(tempid, playername, 31)
add( gNotRdy, charsmax( gNotRdy ), "^n" );
add( gNotRdy, charsmax( gNotRdy ), playername );
}
}
}
else
return;
new playersl[2]
new toadd[64]
formatex(toadd, charsmax(toadd), " %L", LANG_PLAYER, "PLAYERS_LEFT_HUD")
num_to_str(gPlayersLeft, playersl, 2)
trim(playersl)
add(gNotRdy, charsmax(gNotRdy), "^n^n")
add(gNotRdy, charsmax(gNotRdy), playersl)
add(gNotRdy, charsmax(gNotRdy), toadd)
set_hudmessage(255, 255, 255, get_pcvar_float(cvar_NotReadyXPos), get_pcvar_float(cvar_NotReadyYPos), 0, 6.0, 1.0, _, _, 1)
show_hudmessage(0, gNotRdy)
formatex(gNotRdy, charsmax(gNotRdy), "%L:^n", LANG_PLAYER, "HUD_NOT_READY")
}
public showReady()
{
new readyPlayers
if (gPlayersLeft != 0)
{
new players[32], pnum, tempid;
get_players(players, pnum, "ch");
for( new i; i<pnum; i++ ) {
tempid = players;
if ( g_bIsReady[tempid] ) {
new playername[32]
readyPlayers++
get_user_name(tempid, playername, 31)
add( gRdy, charsmax( gRdy ), "^n" );
add( gRdy, charsmax( gRdy ), playername );
}
}
}
else
return;
new playersl[2], toAdd[65]
formatex(toAdd, charsmax(toAdd), " %L", LANG_PLAYER, "HUD_PLAYERS_READY")
num_to_str(readyPlayers, playersl, 2)
add(gRdy, charsmax(gNotRdy), "^n^n")
add(gRdy, charsmax(gNotRdy), playersl)
add(gRdy, charsmax(gNotRdy), toAdd)
set_hudmessage(255, 255, 255, get_pcvar_float(cvar_ReadyXPos), get_pcvar_float(cvar_ReadyYPos), 0, 6.0, 1.0, _, _, 2)
show_hudmessage(0, gRdy)
formatex(gRdy, charsmax(gRdy), "%L:^n", LANG_PLAYER, "HUD_READY")
}
public credits(id) {
client_print(id, print_chat, "%L", LANG_PLAYER, "CREDITS_1")
client_print(id, print_chat, "%L", LANG_PLAYER, "CREDITS_2")
return PLUGIN_CONTINUE
}
public cmds(id) {
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CMDS_1")
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CMDS_2")
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CMDS_3")
client_print(id, print_chat, "%L", LANG_PLAYER, "AUTO_MIX_BY", VERSION)
return PLUGIN_HANDLED
}
public StartVote() {
getmaps()
new rnd
while (g_DoneMaps != 4 && g_MapsCounter > 0) {
rnd = random(g_MapsCounter)
copy(g_MapsChosen[g_DoneMaps++], 19, g_MapsAvailable[rnd])
g_MapsAvailable[rnd] = g_MapsAvailable[--g_MapsCounter]
}
new title[64], extend[64]
formatex(title, charsmax(title), "\r%L", LANG_PLAYER, "CHANGE_MAP")
formatex(extend, charsmax(extend), "\n%L", LANG_PLAYER, "EXTEND_MAP")
g_gVoteMenu = menu_create(title, "votemap");
new num[11]
for(new i = 0; i < g_DoneMaps; i++) {
num_to_str(i, num, 10)
menu_additem(g_gVoteMenu, g_MapsChosen, num, 0)
}
menu_additem(g_gVoteMenu, extend, "4", 0)
menu_setprop(g_gVoteMenu, MPROP_EXIT, MEXIT_NEVER)
new players[32], pnum, tempid;
get_players(players, pnum, "ch");
for( new i; i<pnum; i++ ) {
tempid = players;
client_print(tempid, print_chat, "%s %L", PREFIX, LANG_PLAYER, "PLEASE_VOTE_MAP")
menu_display(tempid, g_gVoteMenu);
}
client_cmd(0, "spk ^"get red(e80) ninety(s45) to check(e20) use bay(s18) mass(e42) cap(s50)^"")
new taskId = scanForTaskID()
set_task(10.0, "EndVote", taskId);
return PLUGIN_HANDLED;
}
public votemap(id, menu, item) {
if( item == MENU_EXIT ) {
menu_display(id, g_gVoteMenu)
return PLUGIN_HANDLED;
}
new data[6], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
new voteid = str_to_num(data);
new playerna[32]
get_user_name(id, playerna, 31)
if (voteid != 4)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "VOTED_MAP", playerna, g_MapsChosen[voteid])
else
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "VOTED_EXTEND", playerna)
g_gVotes[voteid]++;
return PLUGIN_HANDLED;
}
public getmaps() {
new mapsfile = fopen(g_Maps_Ini_File, "r")
new linefortest[50]
while (g_MapsCounter < sizeof(g_MapsAvailable) && !feof(mapsfile)) {
fgets(mapsfile, linefortest, 49)
trim(linefortest)
new getcurrentmap[32]
get_mapname(getcurrentmap, 31)
if ((is_map_valid(linefortest)) && (!equali(linefortest, getcurrentmap)))
copy(g_MapsAvailable[g_MapsCounter++], 24, linefortest)
}
fclose(mapsfile)
}
public EndVote() {
show_menu(0, 0, "^n", 1);
new best = 0;
for(new i = 1; i < sizeof(g_gVotes); i++) {
if(g_gVotes > g_gVotes[best])
best = i;
}
g_gVotes[0] = 0
g_gVotes[1] = 0
g_gVotes[2] = 0
g_gVotes[3] = 0
g_gVotes[4] = 0
if(best == 4) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "EXTEND_FINAL");
TeamsVote()
}
else {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MAP_FINAL", g_MapsChosen[best]);
g_ChangeMapTo = best;
if ( g_CustomGame )
set_pug_state(2)
else
set_pug_state(1)
//set_pcvar_string(cvar_sv_password, "")
new taskId = scanForTaskID()
set_task(10.0, "ChangeMap", taskId);
}
return PLUGIN_HANDLED
}
public ChangeMap() {
new maptochangeto[25]
copy(maptochangeto, 24, g_MapsChosen[g_ChangeMapTo])
server_cmd("changelevel %s", maptochangeto)
return PLUGIN_CONTINUE
}
public FriendlyFire() {
new title[64]
formatex(title, charsmax(title), "\r%L", LANG_PLAYER, "FF_MENU_TITLE")
g_fVoteMenu = menu_create(title, "voteFF");
new itemOn[10], itemOff[10]
formatex(itemOn, charsmax(itemOn), "%L", LANG_PLAYER, "MENU_ITEM_ON")
formatex(itemOff, charsmax(itemOff), "%L", LANG_PLAYER, "MENU_ITEM_OFF")
menu_additem(g_fVoteMenu, itemOn)
menu_additem(g_fVoteMenu, itemOff)
new pplayers[32], ppnum, ptempid;
get_players(pplayers, ppnum, "ch");
for( new i; i<ppnum; i++ ){
ptempid = pplayers
client_print(ptempid, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_PICK")
menu_display(ptempid, g_fVoteMenu, 0)
}
new taskId = scanForTaskID()
set_task(10.0, "EndFFVote", taskId)
return PLUGIN_HANDLED
}
public voteFF(id, menu, item) {
if( item == MENU_EXIT ) {
menu_display(id, g_fVoteMenu)
return PLUGIN_HANDLED;
}
new playername[32]
get_user_name(id, playername, 31)
switch(item) {
case 0: client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_VOTED_ON",playername)
case 1: client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_VOTED_OFF", playername)
}
g_fVotes[item]++;
return PLUGIN_HANDLED;
}
public EndFFVote() {
show_menu(0, 0, "^n", 1);
new best = 0;
for(new i = 1; i < sizeof(g_fVotes); i++) {
if(g_fVotes > g_fVotes[best])
best = i;
}
g_fVotes[0] = 0
g_fVotes[1] = 0
switch(best){
case 0: client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_BE_ON")
case 1: {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_BE_OFF")
g_bFFoff = true
}
}
new taskId = scanForTaskID()
set_task(5.0, "StartMatch", taskId)
return PLUGIN_HANDLED
}
public TeamsVote() {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_VOTE_START")
new taskId = scanForTaskID()
set_task(10.0, "TeamsVote2", taskId)
}
public TeamsVote2() {
if ( !g_CustomGame ) {
if (get_playersnum() < get_pcvar_num(cvar_pLeft) - 2) {
if (g_DidWaitEnough == 16) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "PLAYERS_NOT_JOINING")
set_pug_state(0)
g_IsStarted = false
g_AfterRdy = false
new taskId = scanForTaskID()
set_task(3.0, "MatchIsOver", taskId)
return PLUGIN_HANDLED
}
new sum
sum = g_DidWaitEnough * 15
sum = 300 - sum
client_print(0, print_chat, "%s %L", PREFIX, "TEAMS_VOTE_DELAY")
set_hudmessage(255, 0, 0, 0.35, 0.66, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync6, "%L", LANG_PLAYER, "TEAMS_VOTE_DELAY_HUD", sum)
g_DidWaitEnough++
new taskId = scanForTaskID()
set_task(15.0, "TeamsVote2", taskId)
return PLUGIN_HANDLED
}
}
set_pug_state(0)
g_MapChanged = false
g_AfterRdy = true
g_DidWaitEnough = 0
new title[86]
new option1[32], option2[35], option3[35]
formatex(title, charsmax(title), "\r%L", LANG_PLAYER, "TEAMS_TITLE")
formatex(option1, charsmax(option1), "%L", LANG_PLAYER, "SAME_TEAMS")
formatex(option2, charsmax(option2), "%L", LANG_PLAYER, "RANDOM_CAPTAINS")
formatex(option3, charsmax(option3), "%L", LANG_PLAYER, "RANDOM_TEAMS")
g_rVoteMenu = menu_create(title, "voteteams");
menu_additem(g_rVoteMenu, option1)
menu_additem(g_rVoteMenu, option2)
menu_additem(g_rVoteMenu, option3)
new pplayers[32], ppnum, ptempid;
get_players(pplayers, ppnum, "ch");
for( new i; i<ppnum; i++ ) {
ptempid = pplayers
client_print(ptempid, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_PLEASE_VOTE")
menu_display(ptempid, g_rVoteMenu)
}
client_cmd(0, "spk Gman/Gman_Choose1")
new taskId = scanForTaskID()
set_task(10.0, "EndTeamsVote", taskId)
return PLUGIN_HANDLED
}
public voteteams(id, menu, item) {
if( item == MENU_EXIT ) {
menu_display(id, menu)
return PLUGIN_HANDLED;
}
new players[32], pnum, tempid
new bool:IsThereBot
get_players(players, pnum, "h")
for ( new i ; i < pnum ; i++ )
{
tempid = players
if ( is_user_bot(tempid) )
IsThereBot = true
}
new playername[32]
get_user_name(id, playername, 31)
if ( IsThereBot && item == 1 )
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NOT_AVAILABLE_WITH_BOTS")
menu_display(id, menu)
return PLUGIN_HANDLED
}
switch(item) {
case 0: client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "VOTED_SAME", playername)
case 1: client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "VOTED_CAPTAINS", playername)
case 2: client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "VOTED_RANDOM", playername)
}
g_rVotes[item]++;
return PLUGIN_HANDLED;
}
public EndTeamsVote() {
show_menu(0, 0, "^n", 1);
new best = 0;
for(new i = 1; i < sizeof(g_rVotes); i++) {
if(g_rVotes > g_rVotes[best])
best = i;
}
switch(best) {
case 0:
{
new playersT[32] , numT , playersCt[32] , numCt
get_players( playersT , numT , "che" , "TERRORIST" )
get_players( playersCt , numCt , "che" , "CT" )
g_rVotes[0] = 0
g_rVotes[1] = 0
g_rVotes[2] = 0
if (numT != numCt)
{
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_NOT_BALANCED")
new taskId = scanForTaskID()
set_task(10.0, "RandomTeams", taskId)
return PLUGIN_HANDLED
}
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_WILL_REMAIN_SAME")
new taskId = scanForTaskID()
set_task(10.0, "CurrentTeams", taskId)
}
case 1:
{
g_rVotes[0] = 0
g_rVotes[1] = 0
g_rVotes[2] = 0
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_WILL_BE_CAPTAINS")
new taskId = scanForTaskID()
set_task(10.0, "RandomCpt", taskId)
}
case 2:
{
g_rVotes[0] = 0
g_rVotes[1] = 0
g_rVotes[2] = 0
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_WILL_BE_RANDOM")
new taskId = scanForTaskID()
set_task(10.0, "RandomTeams", taskId)
}
}
return PLUGIN_HANDLED
}
public CurrentTeams() {
new players[32], pnum, tempid;
get_players(players, pnum, "ch");
for( new i; i<pnum; i++ ) {
tempid = players
if (cs_get_user_team(tempid) == CS_TEAM_SPECTATOR)
set_task(1.0, "MoveFromSpec", tempid)
}
StartMatch()
}
public MoveFromSpec(id) {
new playersT[ 32 ] , numT , playersCt[ 32 ] , numCt
get_players( playersT , numT , "che" , "TERRORIST" )
get_players( playersCt , numCt , "che" , "CT" )
if (g_Twon) {
if (g_bSecondHalf) {
if( numT > numCt )
{
set_pcvar_string(cvar_humans_join_team, "CT")
client_cmd(id, "slot1")
ChangeTagB(id)
}
else
{
set_pcvar_string(cvar_humans_join_team, "T")
client_cmd(id, "slot1")
ChangeTagA(id)
}
}
else
{
if( numT > numCt )
{
set_pcvar_string(cvar_humans_join_team, "CT")
client_cmd(id, "slot1")
ChangeTagA(id)
}
else
{
set_pcvar_string(cvar_humans_join_team, "T")
client_cmd(id, "slot1")
ChangeTagB(id)
}
}
}
else
{
if (g_bSecondHalf)
{
if( numT > numCt )
{
set_pcvar_string(cvar_humans_join_team, "CT")
client_cmd(id, "slot1")
ChangeTagA(id)
}
else
{
set_pcvar_string(cvar_humans_join_team, "T")
client_cmd(id, "slot1")
ChangeTagB(id)
}
}
else
{
if( numT > numCt )
{
set_pcvar_string(cvar_humans_join_team, "CT")
client_cmd(id, "slot1")
ChangeTagB(id)
}
else
{
set_pcvar_string(cvar_humans_join_team, "T")
client_cmd(id, "slot1")
ChangeTagA(id)
}
}
}
if (g_bCpt) {
client_cmd(id, "kill")
cs_set_user_team(id, CS_TEAM_SPECTATOR)
}
return PLUGIN_CONTINUE
}
public RandomCpt() {
set_pcvar_num(cvar_mp_freezetime, 9999)
new players[32], pnum, tempid;
get_players(players, pnum, "ch");
new specialCount
for( new i; i<pnum; i++ ) {
tempid = players;
client_cmd(tempid, "kill")
if ( cs_get_user_team(tempid) != CS_TEAM_UNASSIGNED )
{
specialCount++
cs_set_user_team(tempid, CS_TEAM_SPECTATOR)
}
}
log_amx("RandomCpt stage 1")
if (specialCount < 2) {
if (g_CustomGame) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "LESS_PLAYERS_CUSTOM")
new taskId = scanForTaskID()
set_task(3.0, "RandomTeams", taskId)
}
else {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "LESS_PLAYERS")
new taskId = scanForTaskID()
set_task(5.0, "EndMatch", taskId)
}
return;
}
log_amx("RandomCpt stage 2")
new z = random(pnum)
while (cs_get_user_team(players[z]) == CS_TEAM_UNASSIGNED)
z = random(pnum)
cs_set_user_team(players[z], CS_TEAM_T)
gCptT = players[z]
new q = random(pnum)
while ( (q == z) || cs_get_user_team(players[q]) == CS_TEAM_UNASSIGNED )
q = random(pnum)
log_amx("RandomCpt stage 3")
cs_set_user_team(players[q], CS_TEAM_CT)
gCptCT = players[q]
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "RANDOM_CAPTAINS_CHOSEN")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TERROR_CAPTAIN_FIRST")
g_bCpt = true
log_amx("RandomCpt stage 4")
moveT()
return;
}
public kickhimout(id) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CAPTAINS_AFK")
set_hudmessage(255, 0, 0, 0.40, 0.32, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync2, "%L", LANG_PLAYER, "CAPTAINS_AFK")
show_menu(0, 0, "^n", 1);
g_bCpt = false
new taskId = scanForTaskID()
set_task(5.0, "RandomTeams", taskId)
return PLUGIN_HANDLED
}
public moveT() {
log_amx("moveT stage 1")
TeamsInfo()
log_amx("moveT stage 2")
new title[64]
formatex(title, charsmax(title), "%L", LANG_PLAYER, "CHOOSE_PLAYER")
g_PlayersMenu = menu_create(title, "moveT_menu");
new players[32], pnum, tempid;
new Tplayers[32], Tpnum;
new szName[32], szTempid[10];
new pickisdone, check
get_players(players, pnum, "ch");
if ( !pnum )
return PLUGIN_HANDLED
get_players(Tplayers, Tpnum, "che", "TERRORIST");
log_amx("moveT stage 3")
for( new i; i<pnum; i++ )
{
tempid = players;
if ((tempid == gCptT) || (tempid == gCptCT))
check++
if (cs_get_user_team(tempid) == CS_TEAM_UNASSIGNED)
continue;
else if (cs_get_user_team(tempid) == CS_TEAM_SPECTATOR) {
get_user_name(tempid, szName, 31);
num_to_str(tempid, szTempid, 9);
menu_additem(g_PlayersMenu, szName, szTempid);
pickisdone++
}
}
log_amx("moveT stage 4")
if (check != 2) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CAPTAINS_DISCONNECTED")
g_bCpt = false
removeAllTasks()
new taskId = scanForTaskID()
set_task(3.0, "RandomTeams", taskId)
return PLUGIN_HANDLED
}
if (pickisdone == 0) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_ARE_SET")
g_bCpt = false
removeAllTasks()
new taskId = scanForTaskID()
set_task(10.0, "StartMatch", taskId)
return PLUGIN_HANDLED
}
if (Tpnum >= get_pcvar_num(cvar_pLeft)/2 ) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TERROR_TEAM_FULL")
moveCT()
return PLUGIN_HANDLED
}
log_amx("moveT stage 5")
menu_display(gCptT, g_PlayersMenu)
set_task(25.0, "kickhimout", gCptT)
log_amx("moveT stage 6")
return PLUGIN_HANDLED;
}
public moveT_menu(id, g_PlayersMenu, item) {
if( item == MENU_EXIT )
{
menu_display(id, g_PlayersMenu)
return PLUGIN_HANDLED;
}
remove_task(gCptT)
new data[6], iName[64];
new access, callback;
menu_item_getinfo(g_PlayersMenu, item, access, data,5, iName, 63, callback);
new tempid = str_to_num(data);
new name[32]
new g_bCptNm[64]
get_user_name(gCptT, g_bCptNm, 63)
get_user_name(tempid, name, 31)
cs_set_user_team(tempid, CS_TEAM_T)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CHOSEN_IN_TEAM_TERROR", name, g_bCptNm)
menu_destroy(g_PlayersMenu);
remove_task(gCptT);
moveCT()
return PLUGIN_HANDLED
}
public moveCT() {
new title[64]
formatex(title, charsmax(title), "%L", LANG_PLAYER, "CHOOSE_PLAYER")
g_PlayersMenu = menu_create(title, "moveCT_menu");
new players[32], pnum, tempid;
new CTplayers[32], CTpnum;
new szName[32], szTempid[10];
new pickisdone, check
get_players(players, pnum, "ch");
get_players(CTplayers, CTpnum, "che", "CT");
for( new i; i<pnum; i++ )
{
tempid = players;
if ((tempid == gCptT) || (tempid == gCptCT))
check++
if (cs_get_user_team(tempid) == CS_TEAM_UNASSIGNED)
continue;
else if (cs_get_user_team(tempid) == CS_TEAM_SPECTATOR) {
get_user_name(tempid, szName, 31);
num_to_str(tempid, szTempid, 9);
menu_additem(g_PlayersMenu, szName, szTempid);
pickisdone++
}
}
if (check != 2) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CAPTAINS_DISCONNECTED")
g_bCpt = false
new taskId = scanForTaskID()
set_task(3.0, "RandomTeams", taskId)
return PLUGIN_HANDLED
}
if (pickisdone == 0) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_ARE_SET")
g_bCpt = false
new taskId = scanForTaskID()
set_task(10.0, "StartMatch", taskId)
return PLUGIN_HANDLED
}
if (CTpnum >= get_pcvar_num(cvar_pLeft)/2 ) {
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CT_TEAM_FULL")
moveT()
return PLUGIN_HANDLED
}
menu_display(gCptCT, g_PlayersMenu)
set_task(20.0, "kickhimout", gCptCT)
return PLUGIN_HANDLED;
}
public moveCT_menu(id, g_PlayersMenu, item) {
if( item == MENU_EXIT ) {
menu_display(id, g_PlayersMenu)
return PLUGIN_HANDLED;
}
remove_task(gCptCT)
new data[6], iName[64];
new access, callback;
menu_item_getinfo(g_PlayersMenu, item, access, data,5, iName, 63, callback);
new tempid = str_to_num(data);
new name[32]
new g_bCptNm[64]
get_user_name(gCptCT, g_bCptNm, 63)
get_user_name(tempid, name, 31)
cs_set_user_team(tempid, CS_TEAM_CT)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CHOSEN_IN_TEAM_CT", name, g_bCptNm)
menu_destroy(g_PlayersMenu);
remove_task(gCptCT);
moveT()
return PLUGIN_HANDLED
}
public TeamsInfo() {
log_amx("TeamsInfo stage 1")
if (g_bCpt) {
log_amx("TeamsInfo stage 2")
new nameCT[70], nameT[70]
new infoT[500]
new infoCT[500]
new players[32], pnum, tempid;
new toapprove
get_players(players, pnum, "ch")
get_user_name(gCptT, nameT, 69)
get_user_name(gCptCT, nameCT, 69)
formatex(infoT, 499, "%L^n-------------^n%L^n^n", LANG_PLAYER, ( get_pcvar_num(cvar_TeamTag) ? "TEAM_A" : "TERRORISTS" ), LANG_PLAYER, "TEAM_INFO_CAPTAINS", nameT)
formatex(infoCT, 499, "%L^n-------------^n%L^n^n", LANG_PLAYER, ( get_pcvar_num(cvar_TeamTag) ? "TEAM_B" : "COUNTER_TERRORISTS" ), LANG_PLAYER, "TEAM_INFO_CAPTAINS", nameCT)
log_amx("TeamsInfo stage 3")
for (new i ; i < pnum ; i++)
{
tempid = players
if ((cs_get_user_team(tempid) == CS_TEAM_T) && (tempid != gCptT))
{
new nameofp[70]
get_user_name(tempid, nameofp, 69)
add(infoT, 499, nameofp)
add(infoT, 499, "^n")
}
else if ((cs_get_user_team(tempid) == CS_TEAM_CT) && (tempid != gCptCT))
{
new nameofCTp[70]
get_user_name(tempid, nameofCTp, 69)
add(infoCT, 499, nameofCTp)
add(infoCT, 499, "^n")
}
if ((cs_get_user_team(tempid) == CS_TEAM_T) && (tempid == gCptT))
toapprove++
else if ((cs_get_user_team(tempid) == CS_TEAM_CT) && (tempid == gCptCT))
{
toapprove++
}
}
if (toapprove != 2) {
set_hudmessage(255, 0, 0, 0.40, 0.32, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync2, "%L", LANG_PLAYER, "CAPTAINS_DISCONNECTED_HUD")
new taskId = scanForTaskID()
set_task(5.0, "RandomTeams", taskId)
return PLUGIN_HANDLED
}
set_hudmessage(27, 162, 229, 0.28, 0.32, 0, 6.0, 1.0)
ShowSyncHudMsg(0, g_MsgSync8, infoT)
log_amx("TeamsInfo stage 4")
set_hudmessage(27, 162, 229, 0.58, 0.32, 0, 6.0, 1.0)
ShowSyncHudMsg(0, g_MsgSync2, infoCT)
new taskId = scanForTaskID()
set_task(1.0, "TeamsInfo", taskId)
}
else
{
set_hudmessage(0, 255, 0, 0.40, 0.32, 0, 6.0, 12.0)
ShowSyncHudMsg(0, g_MsgSync2, "%L", LANG_PLAYER, "TEAMS_ARE_SET_HUD")
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public RandomTeams()
{
new players[32], pnum, tempid;
get_players(players, pnum, "ch");
for( new i; i<pnum; i++ ) {
tempid = players;
client_cmd(tempid, "kill")
if (cs_get_user_team(tempid) == CS_TEAM_UNASSIGNED)
continue;
cs_set_user_team(tempid, CS_TEAM_SPECTATOR)
}
new topick, idop
while (AnyoneInSpec()) {
if (cs_get_user_team(players[idop]) == CS_TEAM_UNASSIGNED)
{
idop++
continue;
}
topick = random(2)
if (topick == 1)
{
cs_set_user_team(players[idop], CS_TEAM_T)
}
else
{
cs_set_user_team(players[idop], CS_TEAM_CT)
}
new pplayers[32], ppnum, tempid;
new ppplayers[32], pppnum;
new temppnum
get_players(players, pnum, "ch");
get_players(pplayers, ppnum, "che", "CT")
get_players(ppplayers, pppnum, "che", "TERRORIST")
if (ppnum == pnum/2)
{
get_players(players, temppnum, "ch");
for( new i; i<temppnum; i++ )
{
tempid = players;
if (cs_get_user_team(tempid) == CS_TEAM_SPECTATOR)
{
cs_set_user_team(tempid, CS_TEAM_T)
}
}
}
else if (pppnum == pnum/2)
{
get_players(players, temppnum, "ch");
for( new i; i<temppnum; i++ )
{
tempid = players;
if (cs_get_user_team(tempid) == CS_TEAM_SPECTATOR)
{
cs_set_user_team(tempid, CS_TEAM_CT)
}
}
}
idop++
}
new taskId = scanForTaskID()
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "TEAMS_RANDOMIZED")
set_task(5.0, "StartMatch", taskId)
}
public AnyoneInSpec() {
new players[32], pnum, tempid;
get_players(players, pnum, "ch");
for( new i; i<pnum; i++ )
{
tempid = players;
if (cs_get_user_team(tempid) == CS_TEAM_SPECTATOR)
return true
}
return false
}
public StartMatch() {
if(get_pcvar_num(cvar_FFvote) && (g_bDidVoteFF == false))
{
g_bDidVoteFF = true
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "FF_VOTE_START")
new taskId = scanForTaskID()
set_task(5.0, "FriendlyFire", taskId)
return PLUGIN_HANDLED
}
new players[32], pnum, tempid;
get_players(players, pnum, "ch")
if (pnum < get_pcvar_num(cvar_pLeft) - 2)
{
if ( !g_CustomGame )
{
if (g_DidWaitEnough < 8)
{
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_DELAYED")
g_DidWaitEnough++
new taskId = scanForTaskID()
set_task(15.0, "StartMatch", taskId)
return PLUGIN_HANDLED
}
set_pcvar_string(cvar_humans_join_team, "")
g_iScore[0] = 0
g_iScore[1] = 0
g_AfterRdy = false
g_IsStarted = false
g_bDidVoteFF = false
g_DidWaitEnough = 0
gPlayersLeft = get_maxplayers()
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NO_MINIMUM", get_pcvar_num(cvar_pLeft) - 2)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NO_MINIMUM_CONTINUE")
entity_set_float(gEntShowLeft, EV_FL_nextthink, 1.0)
server_cmd("exec serverautomix.cfg")
server_exec()
for( new i; i<pnum; i++ ) {
tempid = players;
g_bIsReady[tempid] = false
remove_task(tempid)
g_iTimeLeft[tempid] = get_pcvar_num(cvar_TimeLeft)
g_LeftKills[tempid] = 0
g_bSecondHalf = false
ToSetTaskToInfo(tempid)
}
return PLUGIN_HANDLED
}
}
for (new x ; x<pnum ; x++)
{
tempid = players[x]
switch( cs_get_user_team(tempid) ) {
case CS_TEAM_UNASSIGNED: continue;
case CS_TEAM_SPECTATOR: server_cmd("kick # %d", get_user_userid(tempid))
case CS_TEAM_T: ChangeTagA(tempid)
case CS_TEAM_CT: ChangeTagB(tempid)
}
}
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MIX_SETTINGS_LOADED")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MIX_SETTINGS_LOADED")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MIX_SETTINGS_LOADED")
new taskId = scanForTaskID()
set_task(4.0, "Settings", taskId)
return PLUGIN_HANDLED
}
public ChangeTagA(id) {
if ( !( 1 <= id <= gMaxPlayers ) || !get_pcvar_num(cvar_TeamTag) )
return;
new pname[65]
new newname[70]
get_user_name(id, pname, 64)
pname = RemoveOldTag(pname, strlen(pname))
formatex(newname, 69, "(%L) %s", LANG_PLAYER, "TEAM_A", pname)
set_user_info(id, "name", newname)
}
public ChangeTagB(id) {
if ( !( 1 <= id <= gMaxPlayers ) || !get_pcvar_num(cvar_TeamTag) )
return;
new pname[65]
new newname[70]
get_user_name(id, pname, 64)
pname = RemoveOldTag(pname, strlen(pname))
formatex(newname, 69, "(%L) %s", LANG_PLAYER, "TEAM_B", pname)
set_user_info(id, "name", newname)
}
public RemoveOldTag(pname[65], p_len) { // SUPPORTS ONLY DEFAULT GIVEN NAMES (TEAM A AND TEAM B)
if ( containi(pname, "team") != -1 && ( containi(pname, "a)") != -1 || containi(pname, "b)") != -1 ) )
{
new newName[64], indicator
new pos = containi(pname, "a)")
if ( pos == -1 )
pos = containi(pname, "b)")
for ( new i = pos+3 ; i < p_len ; i++ )
newName[indicator++] = pname
trim(newName)
formatex(pname, charsmax(pname), "%s", newName)
return pname
}
return pname
}
public SwitchTeams() {
new supportvariable
supportvariable = g_iScore[0]
g_iScore[0] = g_iScore[1]
g_iScore[1] = supportvariable
new players[32], pnum, tempid;
get_players(players, pnum, "ch");
for( new i; i<pnum; i++ ) {
tempid = players;
switch( cs_get_user_team(tempid) ) {
case CS_TEAM_T: cs_set_user_team(tempid, CS_TEAM_CT)
case CS_TEAM_CT: cs_set_user_team(tempid, CS_TEAM_T)
}
}
g_bSecondHalf = true
return PLUGIN_HANDLED
}
public KnifeSwitch(WinningTeam) {
new players[32], pnum;
switch ( WinningTeam ) {
case T_WIN: get_players(players, pnum, "che", "TERRORIST")
case CT_WIN: get_players(players, pnum, "che", "CT")
}
new menuTitle[78], options[78]
formatex(menuTitle, charsmax(menuTitle), "[Auto-Mix]\w %L", LANG_PLAYER, "KNIFE_MENU_TITLE")
g_switchmenu = menu_create(menuTitle, "handleSwitch")
formatex(options, charsmax(options), "%L", LANG_PLAYER, "KNIFE_MENU_STAY")
menu_additem(g_switchmenu, options)
formatex(options, charsmax(options), "%L", LANG_PLAYER, "KNIFE_MENU_SWAP")
menu_additem(g_switchmenu, options)
for ( new i ; i < pnum ; i++ )
menu_display(players, g_switchmenu)
new intParam[1]
new taskId = scanForTaskID()
intParam[0] = WinningTeam
set_task(8.0, "declareSwitch", taskId, intParam, 1)
}
public handleSwitch(id, menu, item) {
if( item == MENU_EXIT ) {
menu_display(id, g_switchmenu)
return PLUGIN_HANDLED;
}
g_switchVotes[item]++
switch ( item ) {
case 0: client_print(id, 3, "%s You have voted to: Stay.", PREFIX)
case 1: client_print(id, 3, "%s You have voted to: Swap.", PREFIX)
}
return PLUGIN_CONTINUE
}
public declareSwitch(recvParam[], prevTaskId) {
new taskId = scanForTaskID()
if ( g_switchVotes[0] > g_switchVotes[1] ) {
client_print(0, 3, "%s %L ---> %L.", PREFIX, LANG_PLAYER, "KNIFE_MENU_RESULT", LANG_PLAYER, "KNIFE_MENU_STAY")
g_Twon = false
set_task(3.0, "SettingsAfter", taskId)
return PLUGIN_HANDLED
}
else
client_print(0, 3, "%s %L ---> %L.", PREFIX, LANG_PLAYER, "KNIFE_MENU_RESULT", LANG_PLAYER, "KNIFE_MENU_SWAP")
g_Twon = true
for ( new i = 1 ; i <= gMaxPlayers ; i++ )
{
if ( is_user_connected(i) )
{
if ( cs_get_user_team(i) == CS_TEAM_CT )
cs_set_user_team(i, CS_TEAM_T)
else if ( cs_get_user_team(i) == CS_TEAM_T )
cs_set_user_team(i, CS_TEAM_CT)
}
}
set_task(3.0, "SettingsAfter", taskId)
return PLUGIN_CONTINUE
}
public Settings() {
if (get_pcvar_num(cvar_KnifeRound)) {
g_KnifeRound = true
set_pcvar_float(cvar_mp_roundtime, 1.75)
set_pcvar_num(cvar_mp_freezetime, 7)
set_pcvar_float(cvar_mp_buytime, 0.1)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "KNIFE_ROUND_START")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "KNIFE_ROUND_START")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "KNIFE_ROUND_START")
set_pcvar_num(cvar_sv_restart, 3)
new taskId = scanForTaskID()
set_task(4.0, "TSAYKnife", taskId)
}
else
{
g_KnifeRound = false
server_cmd("exec svpk.cfg")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_START")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_START")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_START")
server_cmd("sv_restart 1")
new taskId = scanForTaskID()
set_task(2.0, "Started", taskId)
}
}
public TSAYKnife() {
for ( new i = 1 ; i <= gMaxPlayers ; i++ )
{
if ( is_user_alive(i) )
engclient_cmd(i, "weapon_knife")
}
set_hudmessage(255, 255, 255, 0.10, 0.68, 0, 6.0, 15.0)
ShowSyncHudMsg(0, g_MsgSync7, "%L", LANG_PLAYER, "KNIFE_ROUND_ATTENTION")
}
public SettingsAfter() {
g_KnifeRound = false
g_bCpt = false
server_cmd("exec svpk.cfg")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_START")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_START")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_START")
set_pcvar_num(cvar_sv_restart, 1)
new taskId = scanForTaskID()
set_task(5.0, "Started", taskId)
}
public Started() {
if (g_bFFoff)
set_pcvar_num(cvar_mp_friendlyfire, 0)
else
set_pcvar_num(cvar_mp_friendlyfire, 1)
set_hudmessage(255, 255, 255, 0.07, 0.69, 0, 6.0, 20.0)
ShowSyncHudMsg(0, g_MsgSync3, "%L", LANG_PLAYER, "FIRST_HALF_STARTED")
for ( new i = 1 ; i <= gMaxPlayers ; i++ )
{
if ( is_user_connected(i) && cs_get_user_team(i) != CS_TEAM_SPECTATOR && !is_user_hltv(i) && !is_user_bot(i) )
gDidPlayUntilEnd = true
}
g_IsStarted = true
g_AfterRdy = false
}
public EndMatch() {
set_hudmessage(255, 255, 255, 0.07, 0.59, 0, 6.0, 15.0)
ShowSyncHudMsg(0, g_MsgSync3, "%L", LANG_PLAYER, "MATCH_OVER", g_iScore[0], g_iScore[1])
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_OVER2")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MATCH_OVER3")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "PLUGIN_RESTART")
g_Restart = true
sortPoints()
if ( get_pcvar_num(cvar_Rankings) )
doRankings()
new taskId = scanForTaskID()
set_task(15.0, "MatchIsOver", taskId)
}
public sortPoints()
{
for ( new i = 1 ; i <= gMaxPlayers ; i++ )
{
if ( !is_user_connected(i) || ( g_iScore[0] != 16 && g_iScore[1] != 16 ) )
continue;
if ( gDidPlayUntilEnd )
{
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_PlaysUntilEndPoints) )
client_print(i, print_chat, "%s You have GAINED %d points for playing a full match.", PREFIX, get_pcvar_num(cvar_PlaysUntilEndPoints))
gPoints += get_pcvar_num(cvar_PlaysUntilEndPoints)
}
switch ( get_pcvar_num(cvar_TeamTag) )
{
case 0:
{
if ( g_iScore[0] > g_iScore[1] && cs_get_user_team(i) == CS_TEAM_T )
{
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_WinsMatchPoints) )
client_print(i, print_chat, "%s %L", PREFIX, LANG_PLAYER, "GAIN_POINTS_WIN", get_pcvar_num(cvar_WinsMatchPoints))
gPoints += get_pcvar_num(cvar_WinsMatchPoints)
}
else if ( g_iScore[1] > g_iScore[0] && cs_get_user_team(i) == CS_TEAM_CT )
{
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_WinsMatchPoints) )
client_print(i, print_chat, "%s %L", PREFIX, LANG_PLAYER, "GAIN_POINTS_WIN", get_pcvar_num(cvar_WinsMatchPoints))
gPoints += get_pcvar_num(cvar_WinsMatchPoints)
}
else
{
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_LosesMatchPoints) )
client_print(i, print_chat, "%s %L", PREFIX, LANG_PLAYER, "LOSE_POINTS_LOSE", get_pcvar_num(cvar_LosesMatchPoints))
gPoints -= get_pcvar_num(cvar_LosesMatchPoints)
}
}
case 1:
{
new CsTeams:team
switch ( g_Twon )
{
case 1:
{
if ( g_iScore[0] > g_iScore[1] )
team = CS_TEAM_T
else
team = CS_TEAM_CT
}
case 0:
{
if ( g_iScore[1] > g_iScore[0] )
team = CS_TEAM_CT
else
team = CS_TEAM_T
}
}
if ( cs_get_user_team(i) == team )
{
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_WinsMatchPoints) )
client_print(i, print_chat, "%s %L", PREFIX, LANG_PLAYER, "GAIN_POINTS_WIN", get_pcvar_num(cvar_WinsMatchPoints))
gPoints += get_pcvar_num(cvar_WinsMatchPoints)
}
else
{
if ( get_pcvar_num(cvar_RanksSystemMessages) && get_pcvar_num(cvar_LosesMatchPoints) )
client_print(i, print_chat, "%s %L", PREFIX, LANG_PLAYER, "LOSE_POINTS_LOSE", get_pcvar_num(cvar_WinsMatchPoints))
gPoints -= get_pcvar_num(cvar_LosesMatchPoints)
}
}
}
SaveStats(i)
}
}
public doRankings()
{
new KillerName[256], DeathsName[256], BombPName[256], BombDName[256]
new players[32], pnum, tempid
new topKillerID, topDeathsID, topBombPID, topBombDID
new topKills, topDeaths, topBombP, topBombD
new winningTeam[65]
get_players(players, pnum, "ch")
switch ( get_pcvar_num(cvar_TeamTag) )
{
case 0:
{
if ( g_iScore[0] > g_iScore[1] )
formatex(winningTeam, charsmax(winningTeam), "%L", LANG_PLAYER, "T_FULL")
else
formatex(winningTeam, charsmax(winningTeam), "%L", LANG_PLAYER, "CT_FULL")
}
case 1:
{
switch ( g_Twon )
{
case 1:
{
if ( g_iScore[g_bSecondHalf ? 0 : 1] > g_iScore[g_bSecondHalf ? 1 : 0] )
formatex(winningTeam, charsmax(winningTeam), "%L", LANG_PLAYER, "TEAM_A")
else
formatex(winningTeam, charsmax(winningTeam), "%L", LANG_PLAYER, "TEAM_B")
}
case 0:
{
if ( g_iScore[g_bSecondHalf ? 1 : 0] > g_iScore[g_bSecondHalf ? 0 : 1] )
formatex(winningTeam, charsmax(winningTeam), "%L", LANG_PLAYER, "TEAM_A")
else
formatex(winningTeam, charsmax(winningTeam), "%L", LANG_PLAYER, "TEAM_B")
}
}
}
}
for ( new i ; i < pnum ; i++ )
{
tempid = players
if ( g_TotalKills[tempid] >= topKills && g_TotalKills[tempid] )
{
topKills = g_TotalKills[tempid]
topKillerID = tempid
}
if ( g_TotalDeaths[tempid] >= topDeaths && g_TotalDeaths[tempid] )
{
topDeaths = g_TotalDeaths[tempid]
topDeathsID = tempid
}
if ( g_BombPlants[tempid] >= topBombP && g_BombPlants[tempid] )
{
topBombP = g_BombPlants[tempid]
topBombPID = tempid
}
if ( g_BombDefusions[tempid] >= topBombD && g_BombDefusions[tempid] )
{
topBombD = g_BombDefusions[tempid]
topBombDID = tempid
}
}
if ( 1 <= topKillerID <= gMaxPlayers )
get_user_name(topKillerID, KillerName, charsmax(KillerName))
if ( 1 <= topDeathsID <= gMaxPlayers )
get_user_name(topDeathsID, DeathsName, charsmax(DeathsName))
if ( 1 <= topBombPID <= gMaxPlayers )
get_user_name(topBombPID, BombPName, charsmax(BombPName))
if ( 1 <= topBombDID <= gMaxPlayers )
get_user_name(topBombDID, BombDName, charsmax(BombDName))
for ( new i ; i < pnum ; i++ )
{
tempid = players
if ( g_TotalKills[tempid] == topKills && tempid != topKillerID && g_TotalKills[tempid] )
{
new lineToAdd[65] = ", "
new pName[64]
get_user_name(tempid, pName, charsmax(pName))
add(lineToAdd, charsmax(lineToAdd), pName)
add(KillerName, charsmax(KillerName) - strlen(BombDName) , lineToAdd)
}
if ( g_TotalDeaths[tempid] == topDeaths && tempid != topDeathsID && g_TotalDeaths[tempid] )
{
new lineToAdd[65] = ", "
new pName[64]
get_user_name(tempid, pName, charsmax(pName))
add(lineToAdd, charsmax(lineToAdd), pName)
add(DeathsName, charsmax(DeathsName) - strlen(DeathsName) , lineToAdd)
}
if ( g_BombPlants[tempid] == topBombP && tempid != topBombPID && g_BombPlants[tempid] )
{
new lineToAdd[65] = ", "
new pName[64]
get_user_name(tempid, pName, charsmax(pName))
add(lineToAdd, charsmax(lineToAdd), pName)
add(BombPName, charsmax(BombPName) - strlen(BombPName) , lineToAdd)
}
if ( g_BombDefusions[tempid] == topBombD && tempid != topBombDID && g_BombDefusions[tempid] )
{
new lineToAdd[65] = ", "
new pName[64]
get_user_name(tempid, pName, charsmax(pName))
add(lineToAdd, charsmax(lineToAdd), pName)
add(BombDName, charsmax(BombDName) - strlen(BombDName) , lineToAdd)
}
}
new msgToDisplay[456] = "%L"
format(msgToDisplay, charsmax(msgToDisplay), msgToDisplay, LANG_PLAYER, "RANKING_TABLE", winningTeam, strlen(KillerName) ? KillerName : "NONE", topKills, strlen(DeathsName) ? DeathsName : "NONE", topDeaths,
strlen(BombPName) ? BombPName : "NONE", topBombP, strlen(BombDName) ? BombDName : "NONE", topBombD, g_PugLeaves)
new taskId = scanForTaskID()
set_task(1.0, "displayRankingTable", taskId, msgToDisplay, strlen(msgToDisplay), "b")
}
public displayRankingTable(msgToDisplay[], taskId)
{
set_hudmessage(135, 135, 135, 0.35, 0.21, 1, 6.0, 1.0)
show_hudmessage(0, msgToDisplay)
}
public MatchIsOver()
{
//set_pcvar_string(cvar_sv_password, "")
set_task(1.0, "restartServer", scanForTaskID())
}
public restartServer()
{
server_cmd("restart")
}
public player(id) {
if (g_bCpt) {
client_print(id, print_chat, "%L", PREFIX, LANG_PLAYER, "MENU_BLOCK")
return PLUGIN_HANDLED
}
new title[79]
new item1[79], item2[79], item3[79], item4[79], item5[79], item6[79], item7[79]
formatex(title, charsmax(title), "%L", LANG_PLAYER, "PLAYERS_MENU_TITLE")
formatex(item1, charsmax(item1), "%L", LANG_PLAYER, "PLAYERS_MENU_ITEM1")
formatex(item4, charsmax(item4), "%L", LANG_PLAYER, "PLAYERS_MENU_ITEM4")
formatex(item5, charsmax(item5), "%L", LANG_PLAYER, "PLAYERS_MENU_ITEM5")
formatex(item6, charsmax(item6), "%L", LANG_PLAYER, "PLAYERS_MENU_ITEM6")
formatex(item7, charsmax(item7), "\y%L", LANG_PLAYER, "PLAYERS_MENU_ITEM7")
g_pVote = menu_create(title, "pmenu")
menu_additem(g_pVote, item1)
if (g_IsStarted) {
formatex(item2, charsmax(item2), "\d%L", LANG_PLAYER, "PLAYERS_MENU_ITEM2")
formatex(item3, charsmax(item3), "\d%L", LANG_PLAYER, "PLAYERS_MENU_ITEM3")
menu_additem(g_pVote, item2)
menu_additem(g_pVote, item3)
}
else if (g_bIsReady[id]) {
formatex(item2, charsmax(item2), "\d%L", LANG_PLAYER, "PLAYERS_MENU_ITEM2")
formatex(item3, charsmax(item3), "%L", LANG_PLAYER, "PLAYERS_MENU_ITEM3")
menu_additem(g_pVote, item2)
menu_additem(g_pVote, item3)
}
else {
formatex(item2, charsmax(item2), "%L", LANG_PLAYER, "PLAYERS_MENU_ITEM2")
formatex(item3, charsmax(item3), "\d%L", LANG_PLAYER, "PLAYERS_MENU_ITEM3")
menu_additem(g_pVote, item2)
menu_additem(g_pVote, item3)
}
menu_additem(g_pVote, item4)
menu_additem(g_pVote, item5)
menu_additem(g_pVote, item6)
menu_additem(g_pVote, item7)
menu_display(id, g_pVote)
return PLUGIN_CONTINUE
}
public pmenu(id, menu, item) {
if( item == MENU_EXIT )
return PLUGIN_HANDLED;
new playername[32]
get_user_name(id, playername, 31)
switch(item) {
case 0: cmds(id)
case 1: {
if (g_IsStarted || g_bIsReady[id]) {
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "OPTION_NOT_AVAILABLE")
player(id)
return PLUGIN_HANDLED
}
else {
Prepare(id)
return PLUGIN_HANDLED
}
}
case 2: {
if (g_bIsReady[id])
{
if (g_IsStarted)
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "OPTION_NOT_AVAILABLE")
menu_display(id, g_pVote)
return PLUGIN_HANDLED
}
unPrepare(id)
return PLUGIN_HANDLED
}
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "OPTION_NOT_AVAILABLE")
player(id)
return PLUGIN_HANDLED
}
case 3: {
display_mutemenu(id, g_menuposition[id] = 0)
return PLUGIN_HANDLED
}
case 4:
{
if ( !get_pcvar_num(cvar_RanksSystem) )
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "RANK_SYSTEM_DISABLED")
player(id)
return PLUGIN_HANDLED
}
showRanks(id)
return PLUGIN_HANDLED
}
case 5:
{
client_cmd(id, "amx_langmenu")
return PLUGIN_HANDLED
}
case 6: credits(id)
}
player(id)
return PLUGIN_HANDLED
}
public get_pug_state() {
new file = fopen(gPug_ini_file, "r")
fseek(file, -1, SEEK_END)
new getchar = fgetc(file)
fclose(file)
return getchar - '0'
}
public set_pug_state(iState) {
new file = fopen(gPug_ini_file, "w")
fseek(file, -1, SEEK_END)
fputc(file, iState + '0')
fclose(file)
}
stock replace_it(string[], len, const what[], const with[]) {
new pos = 0;
if ((pos = contain(string, what)) == -1)
{
return 0;
}
new total = 0;
new with_len = strlen(with);
new diff = strlen(what) - with_len;
new total_len = strlen(string);
new temp_pos = 0;
while (replace(string[pos], len - pos, what, with) != 0)
{
total++;
pos += with_len;
total_len -= diff;
if (pos >= total_len)
break;
temp_pos = contain(string[pos], what);
if (temp_pos == -1)
break;
pos += temp_pos;
}
return total;
}
clear_list(id) {
for(new i = 0; i <= gMaxPlayers; ++i)
g_mute[id] = false
}
public clcmd_say(id) {
static say_args[10]
read_args(say_args, 9)
remove_quotes(say_args)
if ( 1 <= gChangerID <= gMaxPlayers && id == gChangerID )
{
new enteredValue = str_to_num(say_args)
if ( enteredValue < 0 )
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "ENTER_POSITIVE_VALUE")
return PLUGIN_HANDLED
}
switch ( gChanging )
{
case 0: set_pcvar_num(cvar_KillPoints, enteredValue)
case 1: set_pcvar_num(cvar_KnifePoints, enteredValue)
case 2: set_pcvar_num(cvar_WinsMatchPoints, enteredValue)
case 3: set_pcvar_num(cvar_PlaysUntilEndPoints, enteredValue)
case 4: set_pcvar_num(cvar_LeavesMatchPoints, enteredValue)
case 5: set_pcvar_num(cvar_LeavesMatchTime, enteredValue)
case 6: set_pcvar_num(cvar_TeamKillPoints, enteredValue)
case 7: set_pcvar_num(cvar_BombPlantPoints, enteredValue)
case 8: set_pcvar_num(cvar_BombDefusePoints, enteredValue)
case 9: set_pcvar_num(cvar_KillLosePoints, enteredValue)
case 10: set_pcvar_num(cvar_KnifeLosePoints, enteredValue)
case 11: set_pcvar_num(cvar_LosesMatchPoints, enteredValue)
}
show_menu(id, 0, "^n", 0)
gChanging = 0
gChangerID = 0
PointsPricesMenu(id)
return PLUGIN_HANDLED
}
else if ( 1 <= gChangerID2 <= gMaxPlayers && id == gChangerID2 )
{
new enteredValue = str_to_num(say_args)
if ( enteredValue < 0 )
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "ENTER_POSITIVE_VALUE")
return PLUGIN_HANDLED
}
switch ( gChanging )
{
case 0: set_pcvar_num(cvar_BeginnerPoints, enteredValue)
case 1: set_pcvar_num(cvar_RegularPoints, enteredValue)
case 2: set_pcvar_num(cvar_VeteranPoints, enteredValue)
case 3: set_pcvar_num(cvar_ProPoints, enteredValue)
case 4: set_pcvar_num(cvar_HardCorePoints, enteredValue)
}
show_menu(id, 0, "^n", 0)
gChanging2 = 0
gChangerID2 = 0
RanksPricesMenu(id)
return PLUGIN_HANDLED
}
if(say_args[0] == '!' && containi(say_args, "mute") != -1)
{
if ( !get_pcvar_num(cvar_MuteMenu) )
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "MUTE_MENU_DISABLED")
return PLUGIN_HANDLED
}
display_mutemenu(id, g_menuposition[id] = 0)
return PLUGIN_HANDLED_MAIN
}
return PLUGIN_CONTINUE
}
public fwd_voice_setclientlistening(receiver, sender, listen)
{
if(receiver == sender)
return FMRES_IGNORED
if(g_mute[receiver][sender]) {
engfunc(EngFunc_SetClientListening, receiver, sender, 0)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
display_mutemenu(id, pos) {
if(pos < 0)
return
static team[11]
get_user_team(id, team, 10)
new at = get_pcvar_num(cvar_alltalk)
get_players(g_menuplayers[id], g_playersnum[id],
at ? "c" : "ce", at ? "" : team)
new start = pos * 8
if(start >= g_playersnum[id])
start = pos = g_menuposition[id]
new end = start + 8
if(end > g_playersnum[id])
end = g_playersnum[id]
new len = formatex(menubody, 511, "\r%s \w%L^n^n", PREFIX, LANG_PLAYER, "MUTE_MENU_TITLE")
static name[32]
new b = 0, i
new keys = MENU_KEY_0
for(new a = start; a < end; ++a)
{
i = g_menuplayers[id][a]
get_user_name(i, name, 31)
if(i == id)
{
++b
len += formatex(menubody[len], 511 - len, "\d#vk.com/automixkrepost\w^n")
}
else
{
keys |= (1<<b)
len += formatex(menubody[len], 511 - len, "\w%d. %s %s\w^n", ++b, name, g_mute[id] ? "\r(Muted)" : "")
}
}
if(end != g_playersnum[id])
{
formatex(menubody[len], 511 - len, "^n9. %L...^n0. %L", LANG_PLAYER, "MENU_ITEM_MORE", LANG_PLAYER, pos ? "MENU_ITEM_BACK" : "MENU_ITEM_EXIT")
keys |= MENU_KEY_9
}
else
formatex(menubody[len], 511-len, "^n0. %L", LANG_PLAYER, pos ? "MENU_ITEM_BACK" : "MENU_ITEM_EXIT")
show_menu(id, keys, menubody, -1, "mute menu")
}
public action_mutemenu(id, key)
{
switch(key)
{
case 8: display_mutemenu(id, ++g_menuposition[id])
case 9: display_mutemenu(id, --g_menuposition[id])
default:
{
new player = g_menuplayers[id][g_menuposition[id] * 8 + key]
g_mute[id][player] = g_mute[id][player] ? false : true
display_mutemenu(id, g_menuposition[id])
static name[32]
get_user_name(player, name, 31)
client_print(id, print_chat, "You have %smuted %s", g_mute[id][player] ? "" : "un", name)
}
}
return PLUGIN_HANDLED
}
public showRanks(id)
{
if ( !is_user_connected(id) || is_user_bot(id) || is_user_hltv(id) )
return PLUGIN_HANDLED
if ( !get_pcvar_num(cvar_RanksSystem) )
{
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "RANK_SYSTEM_DISABLED")
return PLUGIN_HANDLED
}
new title[64]
formatex(title, charsmax(title), "\y[Auto-Mix]\w %L:", LANG_PLAYER, "RANKS_LIST_MENU_TITLE")
new menu = menu_create(title, "ranksMenuHandler")
new players[32], pnum, tempid
get_players(players, pnum, "ch")
for ( new i ; i < pnum ; i++ )
{
tempid = players
new szId[5]
new pName[64], lineToDisplay[128] = "%s -\r "
num_to_str(tempid, szId, charsmax(szId))
get_user_name(tempid, pName, charsmax(pName))
format(lineToDisplay, charsmax(lineToDisplay), lineToDisplay, pName)
new toadd_rank[32]
formatex(toadd_rank, charsmax(toadd_rank), "%L", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM1")
if ( gPoints[tempid] < get_pcvar_num(cvar_BeginnerPoints) )
formatex(toadd_rank, charsmax(toadd_rank), "%L", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM1")
else if ( gPoints[tempid] < get_pcvar_num(cvar_RegularPoints) )
formatex(toadd_rank, charsmax(toadd_rank), "%L", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM2")
else if ( gPoints[tempid] < get_pcvar_num(cvar_VeteranPoints) )
formatex(toadd_rank, charsmax(toadd_rank), "%L", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM3")
else if ( gPoints[tempid] < get_pcvar_num(cvar_ProPoints) )
formatex(toadd_rank, charsmax(toadd_rank), "%L", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM4")
else if ( gPoints[tempid] < get_pcvar_num(cvar_HardCorePoints) )
formatex(toadd_rank, charsmax(toadd_rank), "%L", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM5")
else
formatex(toadd_rank, charsmax(toadd_rank), "%L", LANG_PLAYER, "RANKS_PRICES_MENU_ITEM6")
add(lineToDisplay, charsmax(lineToDisplay), toadd_rank)
menu_additem(menu, lineToDisplay, szId, 0)
}
menu_display(id, menu)
return PLUGIN_HANDLED
}
public ranksMenuHandler(id, menu, item) {
if( item == MENU_EXIT )
return PLUGIN_HANDLED
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
new pickedId = str_to_num(data)
if ( !is_user_connected(pickedId) )
return PLUGIN_HANDLED
new pName[64]
get_user_name(pickedId, pName, charsmax(pName))
new menuToDisplay[248]
new lineToAdd[32]
new keys = MENU_KEY_0
if ( gPoints[pickedId] < get_pcvar_num(cvar_BeginnerPoints) )
formatex(lineToAdd, charsmax(lineToAdd), "%d\r /\w %d", gPoints[pickedId], get_pcvar_num(cvar_BeginnerPoints))
else if ( gPoints[pickedId] < get_pcvar_num(cvar_RegularPoints) )
formatex(lineToAdd, charsmax(lineToAdd), "%d\r /\w %d", gPoints[pickedId], get_pcvar_num(cvar_RegularPoints))
else if ( gPoints[pickedId] < get_pcvar_num(cvar_VeteranPoints) )
formatex(lineToAdd, charsmax(lineToAdd), "%d\r /\w %d", gPoints[pickedId], get_pcvar_num(cvar_VeteranPoints))
else if ( gPoints[pickedId] < get_pcvar_num(cvar_ProPoints) )
formatex(lineToAdd, charsmax(lineToAdd), "%d\r /\w %d", gPoints[pickedId], get_pcvar_num(cvar_ProPoints))
else if ( gPoints[pickedId] < get_pcvar_num(cvar_HardCorePoints) )
formatex(lineToAdd, charsmax(lineToAdd), "%d\r /\w %d", gPoints[pickedId], get_pcvar_num(cvar_HardCorePoints))
else
formatex(lineToAdd, charsmax(lineToAdd), "%d", gPoints[pickedId])
if ( gPoints[pickedId] < get_pcvar_num(cvar_BeginnerPoints) )
formatex(menuToDisplay, charsmax(menuToDisplay), "%L", LANG_PLAYER, "RANKS_MENU_TITLE", pName, lineToAdd, LANG_PLAYER, "RANKS_PRICES_MENU_ITEM1", "1")
else if ( gPoints[pickedId] < get_pcvar_num(cvar_RegularPoints) )
formatex(menuToDisplay, charsmax(menuToDisplay), "%L", LANG_PLAYER, "RANKS_MENU_TITLE", pName, lineToAdd, LANG_PLAYER, "RANKS_PRICES_MENU_ITEM2", "2")
else if ( gPoints[pickedId] < get_pcvar_num(cvar_VeteranPoints) )
formatex(menuToDisplay, charsmax(menuToDisplay), "%L", LANG_PLAYER, "RANKS_MENU_TITLE", pName, lineToAdd, LANG_PLAYER, "RANKS_PRICES_MENU_ITEM3", "3")
else if ( gPoints[pickedId] < get_pcvar_num(cvar_ProPoints) )
formatex(menuToDisplay, charsmax(menuToDisplay), "%L", LANG_PLAYER, "RANKS_MENU_TITLE", pName, lineToAdd, LANG_PLAYER, "RANKS_PRICES_MENU_ITEM4", "4")
else if ( gPoints[pickedId] < get_pcvar_num(cvar_HardCorePoints) )
formatex(menuToDisplay, charsmax(menuToDisplay), "%L", LANG_PLAYER, "RANKS_MENU_TITLE", pName, lineToAdd, LANG_PLAYER, "RANKS_PRICES_MENU_ITEM5", "5")
else
formatex(menuToDisplay, charsmax(menuToDisplay), "%L", LANG_PLAYER, "RANKS_MENU_TITLE", pName, lineToAdd, LANG_PLAYER, "RANKS_PRICES_MENU_ITEM6", "MAX")
show_menu(id, keys, menuToDisplay, -1, "ranks info")
return PLUGIN_HANDLED
}
public ranks_showInfo(id, key)
{
showRanks(id)
return PLUGIN_HANDLED
}
public afkCheck_entThink(ent)
{
if ( get_playersnum() && g_IsStarted && get_pcvar_num(cvar_AFKKick) )
checkPlayers()
entity_set_float(ent, EV_FL_nextthink, halflife_time() + CHECK_FREQ)
}
public checkPlayers() {
for (new i = 1; i <= gMaxPlayers; i++)
{
if (is_user_alive(i) && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i) && g_spawned)
{
new newangle[3]
get_user_origin(i, newangle)
if ( newangle[0] == g_oldangles[0] && newangle[1] == g_oldangles[1] && newangle[2] == g_oldangles[2] )
{
g_afktime += CHECK_FREQ
check_afktime(i)
}
else
{
g_oldangles[0] = newangle[0]
g_oldangles[1] = newangle[1]
g_oldangles[2] = newangle[2]
g_afktime = 0.0
}
}
}
return PLUGIN_HANDLED
}
check_afktime(id) {
new maxafktime = get_pcvar_num(cvar_mp_afktime)
if (maxafktime < MIN_AFK_TIME) {
log_amx("cvar mp_afktime %i is too low. Minimum value is %i.", maxafktime, MIN_AFK_TIME)
maxafktime = MIN_AFK_TIME
set_pcvar_num(cvar_mp_afktime, MIN_AFK_TIME)
}
if ( maxafktime-WARNING_TIME <= floatround(g_afktime[id]) < maxafktime) {
new timeleft = maxafktime - floatround(g_afktime[id])
client_print(id, print_chat, "%s %L", PREFIX, LANG_PLAYER, "AFK_TIME_WARN", timeleft)
}
else if (floatround(g_afktime[id]) > maxafktime) {
new name[32]
get_user_name(id, name, 31)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "AFK_KICKED", name, maxafktime)
log_amx("%s was kicked for being AFK longer than %i seconds", name, maxafktime)
server_cmd("kick #%d ^"%s %L^"", get_user_userid(id), PREFIX, LANG_PLAYER, "AFK_KICK", maxafktime)
}
}
public reCallSpawn(id)
fwPlayerSpawn(id-SPAWN_TASKID)
public fwPlayerSpawn(id) {
if ( !( 1 <= id <= gMaxPlayers ) )
return HAM_IGNORED
g_spawned[id] = false
if ( task_exists(id+SPAWN_TASKID) )
remove_task(id+SPAWN_TASKID)
if ( !is_user_alive(id) )
{
set_task(0.1, "reCallSpawn", id+SPAWN_TASKID)
return HAM_IGNORED
}
g_spawned[id] = true
get_user_origin(id, g_oldangles[id])
return HAM_IGNORED
}
scanForTaskID()
{
for ( new i = 1337 ; i < 1337*2 ; i++ )
{
if ( !task_exists(i) )
return i
}
log_amx("Auto-Mix Task ID Error! Couldn't find a TASK ID!")
return 0
}
removeAllTasks()
{
for ( new i = 1337 ; i < 1337*2 ; i++ )
{
if ( task_exists(i) )
remove_task(i)
}
}
stock remove_shield(id)
{
if ( !is_user_alive(id) || !( 1 <= id <= gMaxPlayers) )
return 0;
const m_iUserPrefs = 510;
const USING_SHIELD = (1<<16);
const HAS_SHIELD = (1<<24);
new prefs = get_pdata_int(id, m_iUserPrefs) & ~USING_SHIELD;
new model[64];
if(prefs & HAS_SHIELD)
pev(id, pev_viewmodel2, model, charsmax(model));
if(equal(model, "models/shield/v_shield_", 23))
{
replace(model, charsmax(model), "shield/v_shield", "v");
set_pev(id, pev_viewmodel2, model);
}
pev(id, pev_weaponmodel2, model, charsmax(model));
if(equal(model, "models/shield/p_shield_", 23))
{
replace(model, charsmax(model), "shield/p_shield", "p");
set_pev(id, pev_weaponmodel2, model);
}
set_pdata_int(id, m_iUserPrefs, (prefs & ~HAS_SHIELD));
return 1;
}
LoadStats(id)
{
if ( is_user_hltv(id) || is_user_bot(id) )
return;
new authid[35]
get_user_authid(id, authid, sizeof(authid) - 1)
if (equali(authid, "STEAM_ID_LAN"))
return
new data[16]
if( fvault_get_data(gPointsVault, authid, data, sizeof(data) - 1) )
gPoints[id] = str_to_num(data)
else
gPoints[id] = 0
return;
}
SaveStats(id)
{
if ( is_user_hltv(id) || is_user_bot(id) || !get_pcvar_num(cvar_RanksSystem) )
return;
new authid[35]
get_user_authid(id, authid, sizeof(authid) - 1)
if (gPoints[id] < 0)
gPoints[id] = 0
if (equali(authid, "STEAM_ID_LAN"))
return
new data[16]
num_to_str(gPoints[id], data, sizeof(data) - 1)
fvault_set_data(gPointsVault, authid, data)
return;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ fbidis\\ ansi\\ ansicpg1252\\ deff0{\\ fonttbl{\\ f0\\ fnil\\ fcharset0 Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ ltrpar\\ lang1037\\ f0\\ fs16 \n\\ par }
*/