Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <csx>
- #include <hamsandwich>
- #include <fakemeta>
- #include <reapi>
- #include <celltrie>
- #define PLUGIN "RE-PUG"
- #define VERSION "1.35"
- #define AUTHOR "Sugisaki & Flys"
- #define END_ROUND_KNIFE_FIX
- #define MAXPLAYERS 15
- #define get_user_team(%i) get_member(%i, m_iTeam)
- new TASK_HUD_READY = 552214
- new TASK_HUD_VOTE = 996541
- new TASK_END_VOTE = 441017
- new TASK_PUG_END = 778745
- new TASK_HUD_MONEY = 55414
- new const TAG[] = "^4[CBP]^1"
- new const GameName[] = "Hola soy tu gamename"
- enum _:PUGSTATE
- {
- NO_ALIVE = 0,
- ALIVE,
- COMMENCING
- }
- enum _:PUG_ROUND
- {
- TT = 0,
- CT
- }
- new bool:RoundRestart
- new Trie:t_Command
- new Trie:t_Command_Plugin
- new pug_state
- new g_PluginId
- new iMaxPlayers
- new bool:ready[MAXPLAYERS]
- new ready_count
- new HamHook:SpawnWeapon
- new HamHook:DefuseKit
- new HamHook:PlayerPostink
- new HamHook:PlayerSpawn
- new bool:vote_map
- new bool:vote_knife
- new g_vote_id
- new g_pcvar_votemap
- new g_vote_countdown
- new bool:private
- new Trie:g_private
- new bool:round_knife
- new bool:half_time
- new team_check_id
- new team_check_time
- new Float:last_damage[MAXPLAYERS][MAXPLAYERS]
- new bool:round_start
- new g_forward
- new g_forward_round_end
- new bool:round_knife_start_vote
- new bool:torneo_limit
- new bool:captainrun
- new TASK = 41454
- new capitan_ct
- new capitan_tt
- new team_voting
- new Sync1
- new Sync2
- new Sync3
- new pcvar_max_players
- new g_iDmg[MAXPLAYERS][MAXPLAYERS]
- new g_iHits[MAXPLAYERS][MAXPLAYERS]
- new Array:g_maps
- new g_votes[32]
- new g_iRound_team[2]
- new g_iRounds
- new g_iFrags[MAXPLAYERS]
- new g_iDeaths[MAXPLAYERS]
- new g_vote_count
- new g_VoteMenu
- new gMsgStatusIcon
- new gMsgRegisterStatusIcon
- new gMsgServerName
- new gMsgTextMsg
- new gMsgScoreInfo
- new gMsgTeamScore
- new bool:is_intermission
- new bool:OnSurrender, bool:OffFreeze, menu_surrender, g_cvotes[2], suteam
- new name[32], tryid[33], c[33]
- new pcvar_max_tryid
- new SND_MUSIC[][] =
- {
- "sound/pug/music1.mp3"
- }
- new SND_COUNTER_BEEP[] = "sound/UI/buttonrollover.wav"
- new SND_STINGER[] = "sound/pug/cs_stinger.wav"
- enum _:CMDS
- {
- COMMAND[40],
- VALUE[10]
- }
- new Pregame_Cmds[][CMDS] =
- {
- {"mp_forcerespawn", "1"},
- {"mp_round_infinite", "acdefg"},
- {"mp_auto_reload_weapons", "1"},
- {"mp_auto_join_team", "0"},
- {"mp_autoteambalance", "0"},
- {"mp_limitteams", "1"},
- {"mp_freezetime", "0"},
- {"mp_timelimit", "0"},
- {"mp_refill_bpammo_weapons", "3"},
- {"mp_startmoney", "16000"},
- {"sv_alltalk", "1"},
- {"mp_buytime", "-1"},
- {"mp_consistency", "1"},
- {"mp_flashlight", "0"},
- {"mp_forcechasecam", "0"},
- {"mp_forcecamera", "0"},
- {"mp_item_staytime", "0"},
- {"mp_roundtime", "9"},
- {"allow_spectators", "1"},
- {"mp_friendlyfire", "0"},
- {"mp_respawn_immunitytime", "5"},
- {"mp_roundrespawn_time", "0"},
- {"sv_timeout", "20"},
- {"sv_rehlds_stringcmdrate_burst_punish", "-1"},
- {"sv_rehlds_stringcmdrate_avg_punish ", "-1"},
- {"sv_rehlds_movecmdrate_burst_punish", "-1"},
- {"sv_rehlds_movecmdrate_avg_punish", "-1"},
- {"sv_rehlds_force_dlmax", "1"}
- }
- new PugStartCmds[][CMDS] =
- {
- {"mp_forcerespawn", "0"},
- {"mp_startmoney", "800"},
- {"mp_freezetime", "6"},
- {"sv_alltalk", "2"},
- {"mp_limitteams", "0"},
- {"mp_refill_bpammo_weapons", "0"},
- {"mp_buytime", ".25"},
- {"mp_forcechasecam", "2"},
- {"mp_item_staytime", "300"},
- {"mp_forcecamera", "2"},
- {"mp_freezetime", "11"},
- {"mp_roundtime", "1.75"},
- {"mp_respawn_immunitytime", "0"},
- {"mp_roundrespawn_time", "10"},
- {"mp_auto_join_team", "0"}
- }
- public plugin_init()
- {
- g_PluginId = register_plugin(PLUGIN, VERSION, AUTHOR)
- pug_state = NO_ALIVE
- register_clcmd("say", "pfn_Hook_Say")
- register_clcmd("say_team", "pfn_Hook_Say")
- pcvar_max_players = register_cvar("pug_players", "10")
- g_pcvar_votemap = register_cvar("pug_votemap", "1")
- pcvar_max_tryid = register_cvar("pug_rendirse", "2")
- SpawnWeapon = RegisterHam(Ham_Spawn, "weaponbox", "pfn_remove_weapon", 1)
- PlayerPostink = RegisterHam(Ham_Player_PostThink, "player", "pfn_postink", 1)
- PlayerSpawn = RegisterHam(Ham_Spawn, "player", "pfn_player_spawn", 1)
- DefuseKit = RegisterHam(Ham_Spawn, "item_thighpack", "pfn_remove_weapon", 1)
- DisableHamForward(PlayerSpawn)
- DisableHamForward(PlayerPostink)
- register_forward( FM_GetGameDescription, "GameDesc" )
- register_event("DeathMsg", "pfn_PlayerDeath", "a")
- register_event("Money", "pfn_money", "b")
- register_event("Damage", "pfn_EVENT_damage", "b")
- register_event("HLTV", "EV_new_round", "a", "1=0", "2=0")
- g_maps = ArrayCreate(32)
- g_private = TrieCreate()
- t_Command = TrieCreate()
- t_Command_Plugin = TrieCreate()
- iMaxPlayers = get_maxplayers();
- Sync1 = CreateHudSyncObj()
- Sync2 = CreateHudSyncObj()
- Sync3 = CreateHudSyncObj()
- gMsgStatusIcon = get_user_msgid("StatusIcon")
- gMsgServerName = get_user_msgid("ServerName")
- gMsgTextMsg = get_user_msgid("TextMsg")
- gMsgScoreInfo = get_user_msgid("ScoreInfo")
- gMsgTeamScore = get_user_msgid("TeamScore")
- g_forward = CreateMultiForward("pug_end", ET_STOP, FP_CELL)
- g_forward_round_end = CreateMultiForward("pug_round_end", ET_STOP, FP_CELL)
- register_message(gMsgTeamScore, "pfn_TeamScore")
- RegisterHookChain(RG_RoundEnd, "pfn_Round_End_Hook")
- RegisterHookChain(RG_HandleMenu_ChooseTeam, "pfn_Hook_ChooseTeam")
- RegisterHookChain(RG_CSGameRules_OnRoundFreezeEnd, "pfn_End_FreezeTime", true)
- register_message(gMsgTextMsg, "pfn_TextMsg")
- register_message(gMsgScoreInfo, "pfn_ScoreInfo")
- register_message(get_user_msgid("SendAudio"), "pfnSendAudioHook")
- pug_register_command(".ready", "pfn_ready", g_PluginId)
- pug_register_command(".notready", "pfn_unready", g_PluginId)
- pug_register_command(".score", "pfn_score", g_PluginId)
- pug_register_command(".start", "pfn_force_start_pug", g_PluginId)
- pug_register_command(".forceready", "pfn_forceready", g_PluginId)
- pug_register_command(".cancel", "pfn_force_cancel", g_PluginId)
- pug_register_command(".dmg", "cmd_dmg", g_PluginId)
- pug_register_command(".rdmg", "cmd_rdmg", g_PluginId)
- pug_register_command(".hp", "cmds_vidas", g_PluginId)
- pug_register_command(".hpteam", "cmds_vidas_team", g_PluginId)
- pug_register_command(".rendirse", "pfn_Surrender", g_PluginId)
- set_task(5.0, "start_pregame")
- read_maps()
- }
- public pfnSendAudioHook(m, e, id)
- {
- new sz[20]
- get_msg_arg_string(2, sz, charsmax(sz))
- if(equal(sz, "%!MRAD_ctwin") || equal(sz, "%!MRAD_terwin") || equal(sz, "%!MRAD_BOMBDEF"))
- {
- return PLUGIN_HANDLED
- }
- return PLUGIN_CONTINUE
- }
- public pfn_player_spawn(id)
- {
- if(!is_user_alive(id))
- {
- return
- }
- if(round_knife)
- {
- rg_remove_all_items(id)
- rg_give_item(id, "weapon_knife")
- set_member(id, m_iAccount, 1)
- }
- }
- public pfn_money(id)
- {
- if(round_knife)
- {
- set_member(id, m_iAccount, 1)
- return
- }
- if(pug_state == ALIVE)
- {
- if(get_member_game(m_bFreezePeriod))
- {
- update_team_money(get_user_team(id))
- }
- return
- }
- set_member(id, m_iAccount, 25000)
- }
- public pfn_PlayerDeath()
- {
- if(pug_state == ALIVE && !is_intermission && !round_knife )
- {
- new v = read_data(2)
- new k = read_data(1)
- if(!(1<= k <= iMaxPlayers) || v == k)
- {
- g_iDeaths[v]++
- g_iFrags[v]--
- }
- else
- {
- g_iFrags[k]++
- g_iDeaths[v]++
- }
- new dteam = get_user_team(v)
- new name1[32]
- new name2[32]
- new name3[32]
- get_user_name(k, name1, 31)
- get_user_name(v, name2, 31)
- new u, b
- get_user_aiming(v, u, b)
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(!is_user_alive(i) || get_user_team(i) == dteam || i == k )
- {
- continue
- }
- if(last_damage[v][i] > get_gametime() || u == i )
- {
- client_print_color(i, 0, "^4*** %s Te Ha salvado matando a %s ***", name1, name2)
- get_user_name(i, name3, 31)
- client_print_color(k, 0, "^4*** Has salvado a %s ***", name3)
- }
- }
- if(!torneo_limit){
- cmd_dmg(v)
- }
- }
- }
- public pfn_ScoreInfo(m, s, id)
- {
- static _score_player_id
- _score_player_id = get_msg_arg_int(1)
- if(pug_state == ALIVE && !round_knife)
- {
- set_msg_arg_int(2, ARG_SHORT, g_iFrags[_score_player_id])
- set_msg_arg_int(3, ARG_SHORT, g_iDeaths[_score_player_id])
- }
- }
- public cmds_vidas(id)
- {
- if(pug_state != ALIVE || is_user_alive(id))
- {
- client_print_color(id, id, " Accion no permitida en este momento", TAG)
- return
- }
- if(torneo_limit){
- client_print_color(id, id, "%s Accion no permitida en modo torneo", TAG)
- return;
- }
- new team = get_user_team(id)
- new name[32]
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(team == get_user_team(i) || !is_user_alive(i)) continue
- get_user_name(i, name, 32)
- client_print_color(id, i, "%s %s HP: %i", TAG, name, get_user_health(i))
- }
- }
- public cmds_vidas_team(id)
- {
- if(pug_state != ALIVE || (is_user_alive(id) && round_start))
- {
- client_print_color(id, id, "%s Accion no permitida en este momento", TAG)
- return
- }
- new team = get_user_team(id)
- new name[32]
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(team != get_user_team(i) || 1 <= get_user_team(i) <= 2 || !is_user_alive(i)) continue
- get_user_name(i, name, 32)
- client_print_color(id, i, "%s %s HP: %i", TAG, name, get_user_health(i))
- }
- }
- public pfn_EVENT_damage(id)
- {
- new a = get_user_attacker(id)
- new damage = read_data(2)
- if(pug_state != ALIVE || !is_user_alive(a) || !(1 <= a <= iMaxPlayers) || a == id || damage <= 0)
- {
- return
- }
- g_iDmg[id][a] += damage
- g_iHits[id][a] += 1
- last_damage[id][a] = get_gametime() + 0.5
- }
- public cmd_dmg(id)
- {
- if(pug_state != ALIVE || (is_user_alive(id) && round_start))
- {
- client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
- return
- }
- if(torneo_limit){
- client_print_color(id, id, "%s Accion no permitida en modo torneo", TAG)
- return
- }
- new tmp_name[32], count
- client_print(id, print_console, "===========[ DMG ]===========")
- for(new i = 0 ; i <= MAXPLAYERS ; i++)
- {
- if(!is_user_connected(i))
- {
- continue;
- }
- if(g_iHits[i][id] > 0)
- {
- get_user_name(i, tmp_name, charsmax(tmp_name))
- client_print_color(id, 0, "%s | %s | Dmg: %i | Hits: %i ", TAG, tmp_name, g_iDmg[i][id], g_iHits[i][id])
- client_print(id, print_console, "| %s | Dmg: %i | Hits: %i ", tmp_name, g_iDmg[i][id], g_iHits[i][id])
- count++
- }
- }
- if(!count)
- {
- client_print_color(id, 0, "%s No Le diste a nadie en esta ronda", TAG)
- console_print(id, "%s No Le diste a nadie en esta ronda", TAG)
- }
- client_print(id, print_console, "=============================")
- }
- public cmd_rdmg(id)
- {
- if(pug_state != ALIVE || (is_user_alive(id) && round_start))
- {
- client_print_color(id, id, "%s Accion no permitida en este momento", TAG)
- return
- }
- new tmp_name[32], count
- client_print(id, print_console, "===========[ RDMG ]===========")
- for(new i = 0 ; i <= MAXPLAYERS ; i++)
- {
- if(!is_user_connected(i))
- {
- continue;
- }
- if(g_iHits[id][i] > 0)
- {
- get_user_name(i, tmp_name, charsmax(tmp_name))
- client_print_color(id, id, "%s | %s | RDmg: %i | Hits: %i ", TAG, tmp_name, g_iDmg[id][i], g_iHits[id][i])
- client_print(id, print_console, "| %s | Dmg: %i | Hits: %i ", tmp_name, g_iDmg[id][i], g_iHits[id][i])
- count++
- }
- }
- if(!count)
- {
- client_print_color(id, id, "%s No recibiste daño esta ronda", TAG)
- }
- client_print(id, print_console, "=============================")
- }
- public bomb_explode(id)
- {
- g_iFrags[id] += 3
- }
- public bomb_defused(id)
- {
- g_iFrags[id] += 3
- }
- public pfn_TeamScore(m, e, id)
- {
- static _____team_score[2]
- get_msg_arg_string(1, _____team_score, charsmax(_____team_score))
- switch(_____team_score[0])
- {
- case 'T' : set_msg_arg_int(2, ARG_SHORT, g_iRound_team[TT])
- case 'C' : set_msg_arg_int(2, ARG_SHORT, g_iRound_team[CT])
- }
- }
- public newRound(id)
- {
- fn_update_server_name(id)
- }
- public pfn_Round_End_Hook(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
- {
- if(pug_state == NO_ALIVE || event == ROUND_GAME_RESTART || event == ROUND_GAME_COMMENCE || status == WINSTATUS_DRAW)
- {
- return HC_CONTINUE
- }
- else if(is_intermission)
- {
- SetHookChainReturn(ATYPE_INTEGER, 1)
- return HC_SUPERCEDE
- }
- if(round_knife)
- {
- client_print_color(0, 0, "%s Ronda cuchillo finalizada, elegiran equipo los %s", TAG, status == WINSTATUS_CTS ? "Anti-Terroristas" : "Terroristas")
- round_knife = false
- #if defined END_ROUND_KNIFE_FIX
- set_cvar_num(Pregame_Cmds[1][COMMAND], 1)
- #endif
- DisableHamForward(PlayerSpawn)
- Send_TextMsg(status == WINSTATUS_TERRORISTS ? "#Terrorists_Win" : status == WINSTATUS_CTS ? "#CTs_Win" : "")
- start_vote_win_team_knife(status == WINSTATUS_TERRORISTS ? 1 : 2)
- DisableHamForward(SpawnWeapon)
- unregister_message(gMsgStatusIcon, gMsgRegisterStatusIcon)
- rg_send_audio(0, status == WINSTATUS_TERRORISTS ? "%!MRAD_terwin" : status == WINSTATUS_CTS ? "%!MRAD_ctwin" : "%!MRAD_rounddraw", PITCH_NORM)
- SetHookChainReturn(ATYPE_INTEGER, 1)
- return HC_SUPERCEDE
- }
- round_start = false
- if(status == WINSTATUS_CTS)
- {
- g_iRound_team[CT]++
- emessage_begin(MSG_ALL, gMsgTeamScore)
- ewrite_string("CT")
- ewrite_short(g_iRound_team[CT])
- emessage_end()
- if(event == ROUND_BOMB_DEFUSED)
- {
- client_cmd(0, "spk ^"radio/bombdef ctwin^"")
- }
- else
- {
- client_cmd(0, "spk radio/ctwin")
- }
- ExecuteForward(g_forward_round_end, _, 2)
- }
- else if(status == WINSTATUS_TERRORISTS)
- {
- client_cmd(0, "spk radio/terwin")
- g_iRound_team[TT]++
- emessage_begin(MSG_ALL, gMsgTeamScore)
- ewrite_string("TERRORIST")
- ewrite_short(g_iRound_team[TT])
- emessage_end()
- ExecuteForward(g_forward_round_end, _, 1)
- }
- fn_update_server_name(0)
- set_task(0.1, "end_dmg")
- if(g_iRounds == 15 && !half_time)
- {
- EnableHamForward(PlayerPostink)
- client_cmd(0, "+strafe")
- g_vote_countdown = 11
- set_task(1.0, "pfn_intermission_count", TASK_HUD_READY, _, _, "b")
- rg_round_end(float(g_vote_countdown) + 0.5, WINSTATUS_DRAW, ROUND_NONE, "", "")
- is_intermission = true
- half_time = true
- Send_TextMsg(status == WINSTATUS_TERRORISTS ? "#Terrorists_Win" : status == WINSTATUS_CTS ? "#CTs_Win" : "")
- client_cmd(0, "mp3 play ^"%s^"", SND_MUSIC[random_num(0, charsmax(SND_MUSIC))])
- cmdDirector(0, "MP3FadeTime 0.5")
- SetHookChainReturn(ATYPE_INTEGER, 1)
- return HC_SUPERCEDE
- }
- else if(g_iRounds == 30 || g_iRound_team[CT] >= 16 || g_iRound_team[TT] >= 16)
- {
- EnableHamForward(PlayerPostink)
- client_cmd(0, "+strafe")
- g_vote_countdown = 15
- set_task(1.0, "pfn_pug_end_countdown", TASK_PUG_END, _, _, "b")
- is_intermission = true
- ExecuteForward(g_forward, _, status == WINSTATUS_TERRORISTS ? 1 : status == WINSTATUS_CTS ? 2 : 0)
- Send_TextMsg(status == WINSTATUS_TERRORISTS ? "#Terrorists_Win" : status == WINSTATUS_CTS ? "#CTs_Win" : "")
- client_cmd(0, "mp3 play ^"%s^"", SND_MUSIC[random_num(0, charsmax(SND_MUSIC))])
- cmdDirector(0, "MP3FadeTime 0.5")
- SetHookChainReturn(ATYPE_INTEGER, 1)
- return HC_SUPERCEDE
- }
- return HC_CONTINUE
- }
- public start_vote_win_team_knife(team)
- {
- arrayset(g_votes, 0, sizeof(g_votes))
- g_vote_count = 0
- set_task(5.0, "end_vote_team_win_knife", TASK_END_VOTE)
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(get_user_team(i) == team)
- {
- make_vote_win_team_knife(i);
- }
- }
- }
- make_vote_win_team_knife(id)
- {
- round_knife_start_vote = true
- new menu = menu_create("\r¿Cambiar el equipo actual?", "mh_vote_team_win_knife")
- menu_additem(menu, "Si")
- menu_additem(menu, "No")
- menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER)
- menu_display(id, menu, 0, 5)
- }
- public mh_vote_team_win_knife(id, menu, item)
- {
- if(item == MENU_EXIT || !round_knife_start_vote)
- {
- menu_destroy(menu)
- return
- }
- menu_destroy(menu)
- if(item > 2)
- {
- return
- }
- g_votes[item] += 1
- g_vote_count += 1
- if(g_vote_count >= get_team_num(get_user_team(id)))
- {
- end_vote_team_win_knife(TASK_END_VOTE)
- }
- return
- }
- public end_vote_team_win_knife(task)
- {
- remove_task(task)
- new w = 0;
- for(new i = 0 ; i < sizeof (g_votes) ; i++)
- {
- if(g_votes[w] > g_votes[i])
- {
- w = i
- }
- }
- if(g_vote_count <= 0)
- {
- w = 0;
- }
- if(w)
- {
- for(new i = 1 ; i <= get_pcvar_num(pcvar_max_players) ; i++)
- {
- if(!is_user_connected(i))
- {
- continue;
- }
- rg_switch_team(i)
- }
- }
- arrayset(g_votes, 0, sizeof(g_votes))
- g_vote_count = 0;
- round_knife_start_vote = false
- set_cvar_num("sv_restart", 1)
- }
- get_team_num(team)
- {
- new count = 0
- for(new i = 1 ; i <= get_playersnum() ;i++)
- {
- if(!is_user_connected(i))
- {
- continue
- }
- if(get_user_team(i) == team)
- {
- count += 1
- }
- }
- return count
- }
- public end_dmg()
- {
- for(new i = 1; i <= get_playersnum() ; i++)
- {
- if(is_user_alive(i) && !torneo_limit)
- {
- cmd_dmg(i);
- }
- }
- }
- stock Send_TextMsg(msg[])
- {
- message_begin(MSG_BROADCAST, gMsgTextMsg)
- write_byte(4)
- write_string(msg)
- message_end()
- }
- public pfn_pug_end_countdown(task)
- {
- g_vote_countdown--
- if(g_vote_countdown > 0)
- {
- if(suteam)
- if(g_iRound_team[CT] == g_iRound_team[TT])
- {
- send_server_name(0, "Empate 00:%02i", g_vote_countdown)
- }
- else if(g_iRound_team[CT] >= g_iRound_team[TT])
- {
- send_server_name(0, "Anti-Terroristas Ganan 00:%02i", g_vote_countdown)
- }
- else
- {
- send_server_name(0, "Los Terroristas Ganan 00:%02i", g_vote_countdown)
- }
- }
- else
- {
- DisableHamForward(PlayerPostink)
- client_cmd(0, "-strafe")
- remove_task(task)
- start_pregame()
- client_cmd(0, "-showscores")
- cmdDirector(0, "MP3FadeTime 0.5")
- cmdDirector(0, "cd fadeout")
- fn_update_server_name(0)
- }
- }
- send_server_name(id, msg[], any:...)
- {
- new fmt[33]
- vformat(fmt, charsmax(fmt), msg, 3)
- message_begin(id ? MSG_ONE_UNRELIABLE : MSG_ALL, gMsgServerName, _, id)
- write_string(fmt)
- message_end()
- message_begin(MSG_ALL, gMsgScoreInfo)
- write_byte(33)
- write_short(0)
- write_short(0)
- write_short(0)
- write_short(0)
- message_end()
- }
- public pfn_intermission_count(task)
- {
- g_vote_countdown--
- if(g_vote_countdown > 0)
- {
- send_server_name(0, "Cambio de equipos 00:%02i", g_vote_countdown)
- }
- else
- {
- cmdDirector(0, "MP3FadeTime 0.5")
- cmdDirector(0, "cd fadeout")
- remove_task(task)
- DisableHamForward(PlayerPostink)
- client_cmd(0, "-strafe")
- new temp = g_iRound_team[CT]
- g_iRound_team[CT] = g_iRound_team[TT]
- g_iRound_team[TT] = temp
- for(new i = 1 ; i<= iMaxPlayers ;i++)
- {
- if(!is_user_connected(i) || !(1<= get_user_team(i) <= 2))
- {
- continue
- }
- rg_switch_team(i)
- set_member(i, m_iAccount, 800);
- if(is_user_alive(i))
- {
- rg_set_user_armor(i, 0, ARMOR_NONE)
- rg_give_default_items(i)
- if(get_member(i, m_bHasC4))
- {
- rg_give_item(i, "weapon_c4", GT_REPLACE)
- }
- }
- }
- fn_update_server_name(0)
- client_cmd(0, "-showscores")
- }
- }
- fn_update_server_name(id)
- {
- new szFmt[40]
- if(round_knife)
- {
- formatex(szFmt, charsmax(szFmt), "Ronda de cuchillos")
- }
- else if(pug_state != NO_ALIVE)
- {
- if(g_iRound_team[CT] == g_iRound_team[TT])
- {
- formatex(szFmt, charsmax(szFmt), "Ronda: %i | Empate: %i - %i", g_iRounds, g_iRound_team[CT], g_iRound_team[TT])
- }
- else if(g_iRound_team[CT] > g_iRound_team[TT])
- {
- formatex(szFmt, charsmax(szFmt), "Ronda: %i | CT: %i | TT: %i", g_iRounds, g_iRound_team[CT], g_iRound_team[TT])
- }
- else
- {
- formatex(szFmt, charsmax(szFmt), "Ronda: %i | TT: %i | CT: %i", g_iRounds, g_iRound_team[TT], g_iRound_team[CT])
- }
- }
- else
- {
- formatex(szFmt, charsmax(szFmt), "Esperando Jugadores")
- }
- send_server_name(id, szFmt)
- new nTAG[20]
- format(nTAG, charsmax(nTAG), "%s", TAG)
- replace_all(nTAG, charsmax(nTAG), "^4", "")
- replace_all(nTAG, charsmax(nTAG), "^1", "")
- if(pug_state != NO_ALIVE)
- {
- if(round_knife)
- {
- formatex(szFmt, charsmax(szFmt), "Ronda de cuchillos")
- }
- else if(g_iRound_team[CT] == g_iRound_team[TT])
- {
- formatex(szFmt, charsmax(szFmt), "%s: TT: %i vs CT: %i", nTAG, g_iRound_team[CT], g_iRound_team[TT])
- }
- else if(g_iRound_team[CT] > g_iRound_team[TT])
- {
- formatex(szFmt, charsmax(szFmt), "%s: CT: %i vs TT: %i", nTAG, g_iRound_team[CT], g_iRound_team[TT])
- }
- else
- {
- formatex(szFmt, charsmax(szFmt), "%s: TT: %i vs CT: %i", nTAG, g_iRound_team[TT], g_iRound_team[CT])
- }
- set_member_game(m_GameDesc, szFmt)
- }
- else
- {
- set_member_game(m_GameDesc, GameName)
- }
- }
- public pfn_show_money(tid)
- {
- update_team_money(1)
- update_team_money(2)
- }
- update_team_money(team)
- {
- new hud[256], name[32]
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(!is_user_connected(i) || get_user_team(i) != team)
- {
- continue
- }
- get_user_name(i, name, 31)
- format(hud, charsmax(hud), "%s%s - $%i^n", hud, name, get_member(i, m_iAccount))
- }
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(!is_user_connected(i) || get_user_team(i) != team)
- {
- continue
- }
- set_hudmessage(0, 255, 0, 0.6, 0.0, 0, 1.0, 1.1, 0.1, 0.2, 1)
- show_hudmessage(i, team == 1 ? "Terrorista:" : "Anti-Terrorista:")
- set_hudmessage(255, 255, 255, 0.6, 0.03, 0, 1.0, 1.1, 0.1, 0.2, 2)
- show_hudmessage(i, hud)
- }
- }
- public EV_new_round()
- {
- if(pug_state == NO_ALIVE)
- {
- return
- }
- else if(pug_state == COMMENCING)
- {
- set_cvar_num("mp_round_infinite", 0);
- pug_state = ALIVE;
- }
- if(is_intermission)
- {
- is_intermission = false
- g_iRounds += 1
- }
- else if(!RoundRestart)
- {
- g_iRounds += 1
- }
- else
- {
- if(g_iRounds < 13){
- g_iRounds = 1
- g_iRound_team[TT] = 0
- g_iRound_team[CT] = 0
- }
- RoundRestart = false
- }
- round_start = true
- OffFreeze=false
- if(OnSurrender)
- {
- for(new i=1; i<get_maxplayers(); i++)
- {
- if(!is_user_connected(i))
- {
- continue
- }
- if(get_member(i, m_iTeam) == suteam)
- {
- client_print_color(i, suteam==1?print_team_red:print_team_blue, "%s Jugador ^3%s^1 solicita rendirse.", TAG, name)
- }
- }
- for(new i=1; i<get_maxplayers(); i++)
- {
- if(!is_user_connected(i))
- {
- continue
- }
- menu_surrender = menu_create("\rPUG\w Elige una opcion", "pfn_surren_handler")
- menu_additem(menu_surrender, "Si, Elijo rendirme")
- menu_additem(menu_surrender, "No, Aun no me rendire")
- new item1[100], name[32]
- get_user_name(i, name, 31)
- formatex(item1, charsmax(item1), "^n\dHecha por:\y %s",name)
- menu_addtext(menu_surrender, item1)
- menu_addtext(menu_surrender, "^n\rNOTA:\w Se necesitan 4 votos a^nfavor para rendirse.")
- menu_setprop(menu_surrender, MPROP_EXIT, MEXIT_NEVER)
- }
- arrayset(g_cvotes, 0, sizeof g_cvotes)
- for(new i = 1 ; i <= get_maxplayers() ; i++)
- {
- if(!is_user_connected(i) || get_member(i, m_iTeam) != suteam)
- {
- continue;
- }
- menu_display(i, menu_surrender)
- client_cmd(i, "spk Gman/Gman_Choose2")
- pfn_hud_vote_surrender()
- }
- }
- if(round_knife)
- {
- fn_update_server_name(0)
- client_print_color(0, 0, "%s Ronda cuchillo, el equipo ganador elegira equipo.", TAG)
- return
- }
- if(team_check_id > 0)
- {
- new count = 0
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(!is_user_connected(i) ||get_user_team(i) != team_check_id)
- {
- continue
- }
- count++
- }
- if(count <= 2)
- {
- if(get_systime() >= team_check_time)
- {
- client_print_color(0, print_team_grey, "^3Partida cancelada por falta de jugadores")
- client_print_color(0, print_team_grey, "^3En el equipo %s", team_check_id == 1 ? "Terrorista" : "Anti-Terrorista")
- team_check_id = 0
- start_pregame()
- return
- }
- else
- {
- new p_time = ((team_check_time - get_systime()) / 60) + 1
- client_print_color(0, team_check_id == 1 ? print_team_red : print_team_blue, "^3Esperando minimo de judadores del equipo %s", team_check_id == 1 ? "Terrorista" : "Anti-Terrorista")
- client_print_color(0, team_check_id == 1 ? print_team_red : print_team_blue, "^3La partida se cancelara en %i minuto%s", p_time, p_time > 1 ? "s" : "")
- }
- }
- else
- {
- team_check_id = 0
- }
- }
- if(team_check_id == 0)
- {
- new t_count = 0
- new ct_count = 0
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(!is_user_connected(i))
- {
- continue;
- }
- switch(get_user_team(i))
- {
- case 1 : t_count++
- case 2 : ct_count++
- }
- }
- if(t_count <= 2 || ct_count <= 2)
- {
- team_check_id = t_count <= 2 ? 1 : 2
- team_check_time = get_systime() + 180
- client_print_color(0, team_check_id == 1 ? print_team_red : print_team_blue, "^3Esperando minimo de judadores del equipo %s", team_check_id == 1 ? "Terrorista" : "Anti-Terrorista")
- client_print_color(0, team_check_id == 1 ? print_team_red : print_team_blue, "^3La partida se cancelara en 3 minutos")
- }
- }
- set_task(1.0, "pfn_show_money", TASK_HUD_MONEY, "", 0, "a", get_cvar_num("mp_freezetime"))
- #if defined END_ROUND_KNIFE_FIX
- if(g_iRounds == 1)
- {
- set_cvar_num(Pregame_Cmds[1][COMMAND], 0)
- arrayset(g_iFrags, 0, MAXPLAYERS)
- arrayset(g_iDeaths, 0, MAXPLAYERS)
- }
- #endif
- if(g_iRounds == 15 || g_iRound_team[CT] == 15 || g_iRound_team[TT] == 15)
- {
- client_cmd(0, "spk ^"%s^"; spk ^"%s^"", SND_STINGER[6], SND_STINGER[6])
- set_dhudmessage(255, 255, 255, -1.0, 0.3, 0, 1.0, 1.5)
- if(g_iRounds == 30)
- {
- show_dhudmessage(0, "Ronda Final")
- }
- else
- {
- show_dhudmessage(0, "Punto de partido")
- }
- }
- fn_update_server_name(0)
- fn_score(0)
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(!is_user_connected(i)){
- continue
- }
- arrayset(g_iDmg[i], 0, MAXPLAYERS)
- arrayset(g_iHits[i], 0, MAXPLAYERS)
- }
- return
- }
- public plugin_end()
- {
- TrieDestroy(t_Command)
- TrieDestroy(t_Command_Plugin)
- ArrayDestroy(g_maps)
- }
- read_maps()
- {
- new file[32]
- new curmap[32]
- ArrayPushString(g_maps, "Jugar Este Mapa")
- get_mapname(curmap, charsmax(curmap))
- if(!file_exists("mapcycle.txt"))
- {
- log_amx("%s Mapcycle.txt no existe", TAG)
- return
- }
- new fh = fopen("mapcycle.txt", "r")
- if(!fh)
- {
- log_amx("%s error con Mapcycle.txt", TAG)
- return
- }
- while(!feof(fh))
- {
- fgets(fh, file, charsmax(file))
- trim(file)
- if(!file[0] || file[0] == ';' || equali(curmap, file))
- {
- continue;
- }
- ArrayPushString(g_maps, file)
- }
- fclose(fh)
- }
- stock bool:check_bsp_file(file[])
- {
- if(equal(file[strlen(file)-4], ".bsp"))
- {
- return true
- }
- return false
- }
- public pfn_postink(id)
- {
- if(!(1 <= get_user_team(id) <= 2))
- {
- return
- }
- set_pev(id, pev_maxspeed, 0.1)
- if(pug_state == ALIVE)
- {
- client_cmd(id, "+showscores")
- }
- if(is_user_alive(id))
- {
- new ent = get_member(id, m_pActiveItem)
- set_member(ent, m_Weapon_flNextPrimaryAttack, 2.0)
- set_member(ent, m_Weapon_flNextSecondaryAttack, 2.0)
- }
- }
- public pfn_remove_weapon(ent)
- {
- if(pug_state == ALIVE && !round_knife)
- {
- DisableHamForward(SpawnWeapon)
- return
- }
- set_pev(ent, pev_flags, FL_KILLME)
- }
- reset_user_vars()
- {
- arrayset(ready, false, sizeof(ready))
- arrayset(tryid, false, (sizeof tryid)-1)
- arrayset(c, false, (sizeof c)-1)
- ready_count = 0
- g_vote_id = 0;
- round_knife = false
- half_time = false
- RoundRestart = false
- g_iRound_team[TT] = 0
- g_iRound_team[CT] = 0
- arrayset(g_iFrags, 0, MAXPLAYERS)
- arrayset(g_iDeaths, 0, MAXPLAYERS)
- }
- stock pug_register_command(Command[], Function[], Plugin)
- {
- new funcid = get_func_id(Function, Plugin)
- if(!funcid)
- {
- server_print("Funcion: ^"%s^" No encontrada", Function)
- return
- }
- else if(TrieKeyExists(t_Command, Command))
- {
- server_print("Funcion ^"%s^" ya existente", Command)
- return
- }
- TrieSetCell(t_Command, Command, Plugin)
- TrieSetCell(t_Command_Plugin, Command, funcid)
- }
- public start_pregame()
- {
- for(new i = 0 ; i < sizeof(Pregame_Cmds) ; i++)
- {
- set_cvar_string(Pregame_Cmds[i][COMMAND], Pregame_Cmds[i][VALUE])
- }
- torneo_limit = false
- is_intermission = false
- pug_state = NO_ALIVE
- gMsgRegisterStatusIcon = register_message(gMsgStatusIcon, "pfn_StatusIcon")
- set_cvar_num("sv_restart", 1)
- EnableHamForward(SpawnWeapon)
- EnableHamForward(DefuseKit)
- reset_user_vars()
- fn_update_server_name(0)
- if(get_pcvar_num(g_pcvar_votemap) == 1)
- {
- set_task(1.0, "pfn_Hud_Ready", TASK_HUD_READY, _, _, "b")
- }
- else
- {
- g_vote_countdown = 60
- set_task(1.0, "pfn_waiting_players", TASK_HUD_READY, _, _, "b")
- }
- if(private)
- {
- set_cvar_string(Pregame_Cmds[3][COMMAND], "0")
- }
- }
- public pfn_StatusIcon(m, e, id)
- {
- if(pug_state == ALIVE && !round_knife)
- {
- unregister_message(gMsgStatusIcon, gMsgRegisterStatusIcon)
- return PLUGIN_CONTINUE
- }
- new arg[4]
- get_msg_arg_string(2, arg, charsmax(arg))
- if(equal(arg, "c4"))
- {
- client_cmd(id, "drop weapon_c4")
- }
- return PLUGIN_CONTINUE
- }
- public pfn_Hud_Ready()
- {
- set_hudmessage(0, 255, 0, 0.75, 0.07, 0, 1.0, 1.1)
- new i;
- new __pcount = 0
- for(i = 1 ; i <= iMaxPlayers ;i++ )
- {
- if(!is_user_connected(i) || !(1 <= get_user_team(i) <= 2))
- {
- continue;
- }
- __pcount += 1
- }
- ShowSyncHudMsg(0, Sync1, "Jugadores: ( %i / %i ) ", __pcount , get_pcvar_num(pcvar_max_players))
- new fmt[33 * 33], name[16]
- copy(fmt, charsmax(fmt), "")
- for(i = 1 ; i <= iMaxPlayers ;i++ )
- {
- if(!is_user_connected(i) || !(1 <= get_user_team(i) <= 2))
- {
- continue;
- }
- if(ready[i]){
- get_user_name(i, name, charsmax(name))
- format(fmt, charsmax(fmt), "%s%s^n", fmt, name)
- }
- else{
- get_user_name(i, name, charsmax(name))
- format(fmt, charsmax(fmt), "%s%s^n", fmt, name)
- }
- }
- set_hudmessage(255, 255, 255, 0.70, 0.1, 0, 1.0, 1.1)
- ShowSyncHudMsg(0, Sync2, fmt)
- copy(fmt, charsmax(fmt), "")
- for(i = 1 ; i <= iMaxPlayers ;i++ )
- {
- if(!is_user_connected(i) || !(1 <= get_user_team(i) <= 2))
- {
- continue;
- }
- if(ready[i]){
- format(fmt, charsmax(fmt), "%s - Listo^n", fmt)
- }
- else{
- format(fmt, charsmax(fmt), "%s - No Listo^n", fmt)
- }
- }
- set_hudmessage(242, 195, 43, 0.84, 0.1, 0, 1.0, 1.1)
- ShowSyncHudMsg(0, Sync3, fmt)
- }
- public plugin_natives()
- {
- register_native("pug_register_command", "native_register_command", .style=0)
- register_native("pug_get_state", "native_pug_get_state")
- register_native("pug_is_ready", "native_is_ready")
- }
- public native_is_ready(pl, pr)
- {
- new u = get_param(1)
- if(!(1 <= u <= iMaxPlayers))
- {
- return false
- }
- return ready[u]
- }
- public native_pug_get_state(pl, pr)
- {
- return pug_state;
- }
- public native_register_command(pl, pr)
- {
- new szCommand[20], szForward[32]
- get_string(1, szCommand, charsmax(szCommand))
- get_string(2, szForward, charsmax(szForward))
- pug_register_command(szCommand, szForward, pl)
- }
- public pfn_Hook_Say(id)
- {
- if(!is_user_connected(id))
- {
- return PLUGIN_CONTINUE
- }
- static said[210], name[32], type[10], team, bool:say_team, message[300]
- read_argv(0, type, charsmax(type))
- get_user_name(id, name, charsmax(name))
- read_argv(1, said, charsmax(said))
- remove_quotes(said)
- trim(said)
- trim(type)
- if(!said[0])
- {
- return PLUGIN_HANDLED_MAIN
- }
- team = get_user_team(id)
- strtolower(type)
- if(equali(type, "say_team") || team == 3 || team == 0)
- {
- say_team = true
- formatex(message, charsmax(message), "^1%s%s^3%s ^1: %s", is_user_alive(id) ? "" : "*DEAD*", team == 1 ? "(Terrorista) " : team == 2 ? "(Antiterrorista) " : "(SPEC) ", name, said)
- }
- else
- {
- say_team = false
- formatex(message, charsmax(message), "^1%s^3%s ^1: %s", is_user_alive(id) ? "" : "*DEAD* ", name, said)
- }
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(!is_user_connected(i))
- {
- continue
- }
- if(say_team)
- {
- if(get_user_team(i) == team)
- {
- client_print_color(i, id, message)
- }
- else if(team == 3 && get_user_team(i) == team)
- {
- client_print_color(i, id, message)
- }
- }
- else
- {
- client_print_color(i, id, message)
- }
- }
- if(check_command(id, said))
- {
- return PLUGIN_HANDLED
- }
- return PLUGIN_HANDLED_MAIN
- }
- check_command(id, text[])
- {
- strtolower(text)
- if(TrieKeyExists(t_Command, text))
- {
- new iPlugin, iFunc
- TrieGetCell(t_Command, text, iPlugin)
- TrieGetCell(t_Command_Plugin, text, iFunc)
- callfunc_begin_i(iFunc, iPlugin)
- callfunc_push_int(id)
- callfunc_end()
- return 1
- }
- return 0
- }
- public pfn_ready(id)
- {
- if(pug_state != NO_ALIVE || !(1 <= get_user_team(id) <= 2))
- {
- client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
- return PLUGIN_HANDLED
- }
- else if(ready[id])
- {
- client_print_color(id, 0, "%s Ya estas listo", TAG)
- return PLUGIN_HANDLED
- }
- new name[32]
- get_user_name(id, name, charsmax(name))
- client_print_color(0, 0, "%s %s Esta Listo", TAG, name)
- ready[id] = true
- ready_count ++
- if(ready_count == get_pcvar_num(pcvar_max_players))
- {
- start_vote()
- }
- return PLUGIN_HANDLED
- }
- public pfn_unready(id)
- {
- if(pug_state != NO_ALIVE)
- {
- client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
- return
- }
- else if(!ready[id])
- {
- client_print_color(id, 0, "%s Aun no estas listo", TAG)
- return
- }
- new name[32]
- get_user_name(id, name, charsmax(name))
- client_print_color(0, 0, "%s %s Dejo de estar Listo", TAG, name)
- ready[id] = false;
- ready_count --
- }
- public pfn_TextMsg(m, e, id)
- {
- static msg[23]
- get_msg_arg_string(2, msg, charsmax(msg))
- if(equal(msg, "#Game_will_restart_in"))
- {
- if(pug_state == ALIVE)
- {
- if(round_knife)
- {
- round_knife = false
- }
- RoundRestart = true
- }
- return PLUGIN_HANDLED
- }
- return PLUGIN_CONTINUE
- }
- public pfn_Hook_ChooseTeam(id, _:slot)
- {
- if(is_intermission || round_knife || round_knife_start_vote)
- {
- center_print(id, "%s No puedes elegir equipo en este momento^n^n^n^n^n", TAG)
- SetHookChainReturn(ATYPE_INTEGER, 0)
- return HC_BREAK
- }
- if(captainrun)
- {
- if(slot != 6)
- {
- SetHookChainReturn(ATYPE_INTEGER, 0)
- return HC_BREAK
- }
- return HC_CONTINUE
- }
- new players[32], count_t, count_ct
- get_players(players, count_t, "e", "TERRORIST")
- get_players(players, count_ct, "e", "CT")
- if(!(1 <= slot <= 2))
- {
- if(slot == 5)
- {
- if(count_t >= (get_pcvar_num(pcvar_max_players) / 2) && count_ct >= (get_pcvar_num(pcvar_max_players) / 2) )
- {
- client_print_color(id, id, "%s Todos los equipos se encuentran llenos", TAG)
- SetHookChainReturn(ATYPE_INTEGER, 0)
- return HC_BREAK
- }
- }
- else{
- client_print_color(id, id, "%s Modo Espectador no permitido", TAG)
- SetHookChainReturn(ATYPE_INTEGER, 0)
- return HC_BREAK
- }
- return HC_CONTINUE
- }
- else if((1 <= slot <= 2) && (1 <= get_user_team(id) <= 2) && pug_state == ALIVE)
- {
- client_print_color(id, id, "%s No puedes hacer un cambio de equipos estando una partida en curso", TAG)
- SetHookChainReturn(ATYPE_INTEGER, 0)
- return HC_BREAK
- }
- new count
- get_players(players, count, "e", slot == 1 ? "TERRORIST" : "CT")
- if(count >= (get_pcvar_num(pcvar_max_players) / 2) )
- {
- center_print(id, "%s Este Equipo esta lleno^n^n^n^n^n", TAG)
- SetHookChainReturn(ATYPE_INTEGER, 0)
- return HC_BREAK
- }
- return HC_CONTINUE
- }
- stock center_print(id, const msg[], any:...)
- {
- new arg[70]
- vformat(arg, charsmax(arg), msg, 3)
- if(id == 0)
- {
- for(new z = 1 ; z <= iMaxPlayers ; z++)
- {
- if(!is_user_connected(z))
- {
- continue
- }
- engfunc(EngFunc_ClientPrintf, z, 1, arg)
- }
- }
- else
- {
- engfunc(EngFunc_ClientPrintf, id, 1, arg)
- }
- }
- public client_putinserver(id)
- {
- if(ready[id])
- {
- ready[id] = false
- ready_count--
- }
- g_iFrags[id] = 0
- g_iDeaths[id] = 0
- fn_update_server_name(id)
- if(private && pug_state != ALIVE)
- {
- set_task(1.0, "pfn_set_team", id + 666)
- }
- }
- public pfn_set_team(id)
- {
- id -= 666
- if(!is_user_connected(id))
- return
- static _c_team, _sz__steam_id_put[32]
- get_user_authid(id, _sz__steam_id_put, charsmax(_sz__steam_id_put))
- if(TrieKeyExists(g_private, _sz__steam_id_put))
- {
- TrieGetCell(g_private, _sz__steam_id_put, _c_team)
- if(!(1<= _c_team <= 3))
- {
- return
- }
- if(_c_team == 3)
- {
- rg_join_team(id, TEAM_SPECTATOR)
- return
- }
- if(get_user_team(id) == _c_team)
- {
- return
- }
- rg_set_user_team(id, _c_team == 1 ? TEAM_TERRORIST : TEAM_CT)
- ExecuteHam(Ham_CS_RoundRespawn, id)
- }
- }
- public client_disconnected(id)
- {
- if(is_intermission)
- {
- return
- }
- if(ready[id])
- {
- ready[id] = false
- ready_count--
- }
- new team = get_user_team(id)
- if(pug_state == ALIVE && (1 <= team <= 2))
- {
- new count = 0
- for(new i = 1 ; i <= iMaxPlayers ;i++)
- {
- if(!is_user_connected(i) || i == id || get_user_team(i) != team)
- {
- continue
- }
- count++
- }
- if(count <= 2)
- {
- if(count == 0)
- {
- client_print_color(0, print_team_red, "%s Partida cancelada por ausencia de jugadores en el equipo %s", TAG, team == 1 ? "Terrorista" : "Anti-Terrorista")
- start_pregame()
- return
- }
- if(team_check_id)
- {
- return
- }
- team_check_id = team
- team_check_time = get_systime() + 180
- client_print_color(0, print_team_grey, "Esperando minimo de judadores del equipo %s", team == 1 ? "Terrorista" : "Anti-Terrorista")
- client_print_color(0, print_team_grey, "La partida se cancelara en 3 minutos")
- }
- }
- }
- public aleatorio()
- {
- new id= random_num(1,MAXPLAYERS)
- while(!is_user_connected(id)) id= random_num(1,iMaxPlayers)
- user_silentkill(id)
- }
- fn_score(id=0)
- {
- if(pug_state == NO_ALIVE)
- {
- client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
- return
- }
- if(g_iRound_team[CT] == g_iRound_team[TT])
- {
- client_print_color(0, 0, "%s La puntuacion esta empatada %i - %i", TAG, g_iRound_team[CT], g_iRound_team[TT])
- }
- else
- {
- client_print_color(0, 0, "%s %s: %i - %s: %i ", TAG, g_iRound_team[CT] > g_iRound_team[TT] ? "Anti-Terroristas" : "Terroristas", g_iRound_team[CT] > g_iRound_team[TT] ? g_iRound_team[CT] : g_iRound_team[TT], g_iRound_team[CT] < g_iRound_team[TT] ? "Anti-Terroristas" : "Terroristas", g_iRound_team[CT] < g_iRound_team[TT] ? g_iRound_team[CT] : g_iRound_team[TT] )
- }
- }
- public pfn_score(id)
- {
- fn_score(id)
- }
- public start_vote()
- {
- remove_task(TASK_HUD_READY)
- g_vote_id = 0
- next_vote()
- }
- make_hud_title(msg[], any:...)
- {
- new fmt[50]
- vformat(fmt, charsmax(fmt), msg, 2)
- set_hudmessage(0, 255, 0, -1.0, 0.0, 0, 1.0, 1.1)
- ShowSyncHudMsg(0, Sync1, fmt)
- }
- make_hud_body(msg[], any:...)
- {
- new fmt[512]
- vformat(fmt, charsmax(fmt), msg, 2)
- set_hudmessage(255, 255, 255, -1.0, 0.03, 0, 1.0, 1.1)
- ShowSyncHudMsg(0, Sync2, fmt)
- }
- public next_vote()
- {
- remove_task(TASK_HUD_VOTE)
- remove_task(TASK_END_VOTE)
- g_vote_id++
- switch(g_vote_id)
- {
- case 1 :
- {
- if(get_pcvar_num(g_pcvar_votemap) == 1)
- {
- set_task(1.0, "pfn_hud_votemap", TASK_HUD_VOTE, _, _, "b")
- set_task(11.0, "pfn_vote_map_end", TASK_END_VOTE)
- g_vote_countdown = 10
- start_vote_map()
- }
- else
- {
- set_pcvar_num(g_pcvar_votemap, 1)
- next_vote();
- }
- }
- case 2 :
- {
- set_task(1.0, "pfn_hud_vote_knife", TASK_HUD_VOTE, _, _, "b")
- set_task(11.0, "pfn_vote_knife_end", TASK_END_VOTE)
- g_vote_countdown = 10
- start_vote_knife()
- }
- default :
- {
- start_countdown()
- }
- }
- }
- public start_vote_map()
- {
- vote_map = true
- g_vote_count = 0
- make_menu_votemap()
- }
- make_menu_votemap()
- {
- g_VoteMenu = menu_create("\rVotacion de Mapa", "mh_vote_map")
- new map[32]
- new i
- for(i = 0 ; i < ArraySize(g_maps) ;i++)
- {
- ArrayGetString(g_maps, i, map, charsmax(map))
- menu_additem(g_VoteMenu, map)
- arrayset(g_votes, 0, sizeof(g_votes))
- }
- menu_setprop(g_VoteMenu, MPROP_EXIT, MEXIT_ALL)
- for(i = 1 ; i <= iMaxPlayers ;i++ )
- {
- if(!is_user_connected(i) || !( 1 <= get_user_team(i) <= 2))
- {
- continue
- }
- menu_display(i, g_VoteMenu, .page=0)
- }
- }
- public mh_vote_map(id, menu, item)
- {
- if(!vote_map)
- {
- return
- }
- if(item == MENU_EXIT)
- {
- g_votes[0]++
- fn_update_vote_map_hud()
- check_votes(vote_map);
- return
- }
- g_votes[item]++
- g_vote_count++
- fn_update_vote_map_hud()
- check_votes(vote_map);
- }
- public check_votes(bool:active)
- {
- if(!active)
- {
- return
- }
- if(g_vote_count == get_playersnum())
- {
- remove_task(TASK_HUD_VOTE)
- remove_task(TASK_END_VOTE)
- pfn_vote_map_end();
- }
- }
- public pfn_vote_map_end()
- {
- vote_map = false
- client_cmd(0, "slot10")
- menu_destroy(g_VoteMenu)
- new winner, temp
- for(new i = 0 ; i < sizeof (g_votes) ; i++)
- {
- if(temp < g_votes[i])
- {
- temp = g_votes[i]
- winner = i
- }
- }
- if(!winner)
- {
- client_print_color(0, 0, "%s Se decidio %a", TAG, ArrayGetStringHandle(g_maps, 0))
- next_vote();
- }
- else
- {
- set_pcvar_num(g_pcvar_votemap, 0)
- server_cmd("changelevel ^"%a^"", ArrayGetStringHandle(g_maps, winner))
- }
- }
- public pfn_hud_votemap()
- {
- if(g_vote_countdown-- <= 0)
- {
- g_vote_countdown = 0
- }
- fn_update_vote_map_hud()
- }
- fn_update_vote_map_hud()
- {
- make_hud_title("Votacion de Mapa: (%i)", g_vote_countdown)
- new count
- new hud[512]
- new temp
- for(new i = 0 ; i < ArraySize(g_maps) ; i++)
- {
- temp = g_votes[i]
- if(temp >= 1)
- {
- count++
- format(hud, charsmax(hud), "%s%a: %i %s^n", hud, ArrayGetStringHandle(g_maps, i), temp, temp > 1 ? "votos" : "voto")
- }
- }
- if(!count)
- {
- formatex(hud, charsmax(hud), "No hay votos")
- }
- make_hud_body(hud)
- }
- start_vote_knife()
- {
- g_vote_count = 0
- vote_knife = true
- set_task(0.1, "make_vote_knife")
- }
- public make_vote_knife()
- {
- arrayset(g_votes, 0, sizeof(g_votes))
- g_VoteMenu = menu_create("\ySorteo de Equipos", "mh_mode_vote")
- menu_additem(g_VoteMenu, "Sin Cambios")
- menu_additem(g_VoteMenu, "Torneo")
- menu_additem(g_VoteMenu, "Aleatorio")
- menu_additem(g_VoteMenu, "Capitanes")
- menu_setprop(g_VoteMenu, MPROP_EXIT, MEXIT_ALL)
- for(new i = 1 ; i <= MAXPLAYERS ; i++)
- {
- if(!is_user_connected(i) || is_user_hltv(i))
- {
- continue
- }
- if( 1 <= get_user_team(i) <= 2)
- {
- menu_display(i, g_VoteMenu)
- }
- }
- }
- public mh_mode_vote(id, menu, item)
- {
- if(item == MENU_EXIT || !vote_knife)
- {
- return
- }
- if(item > 3)
- {
- return
- }
- g_votes[item]++
- g_vote_count++
- update_knife_hud()
- if(g_vote_count >= get_playersnum())
- {
- remove_task(TASK_HUD_VOTE)
- remove_task(TASK_END_VOTE)
- pfn_vote_knife_end(TASK_END_VOTE)
- }
- }
- public pfn_vote_knife_end(task)
- {
- remove_task(task)
- new winner = 0
- for(new i = 0 ; i < 4 ; i++)
- {
- if(g_votes[i] > g_votes[winner])
- {
- winner = i
- }
- }
- switch(winner)
- {
- case 0:
- {
- EnableHamForward(PlayerSpawn)
- next_vote()
- }
- case 1:
- {
- set_cvar_num("mp_friendlyfire", 1)
- torneo_limit = true
- round_knife = true
- EnableHamForward(PlayerSpawn)
- next_vote()
- }
- case 2:
- {
- fnTeamsRandomize()
- }
- case 3:
- {
- fnCaptains()
- }
- }
- vote_knife = false
- }
- public pfn_hud_vote_knife(task)
- {
- if(g_vote_countdown-- > 0)
- {
- update_knife_hud()
- }
- else
- {
- remove_task(task)
- }
- }
- update_knife_hud()
- {
- make_hud_title("Votacion de Equipos (%i)", g_vote_countdown)
- new _hud[100],c
- for(new i = 0 ; i< sizeof g_votes ; i++)
- {
- if(g_votes[i] <= 0)
- {
- continue
- }
- switch(i)
- {
- case 0 :
- {
- format(_hud, charsmax(_hud), "%sSin Cambios: %i voto%s^n", _hud, g_votes[i], g_votes[i] > 1 ? "s" : "")
- c++
- }
- case 1 :
- {
- format(_hud, charsmax(_hud), "%sModo Torneo: %i voto%s^n", _hud, g_votes[i], g_votes[i] > 1 ? "s" : "")
- c++
- }
- case 2 :
- {
- format(_hud, charsmax(_hud), "%sAleatorio: %i voto%s^n", _hud, g_votes[i], g_votes[i] > 1 ? "s" : "")
- c++
- }
- case 3 :
- {
- format(_hud, charsmax(_hud), "%sCapitan: %i voto%s^n", _hud, g_votes[i], g_votes[i] > 1 ? "s" : "")
- c++
- }
- }
- }
- if(c>0)
- {
- make_hud_body(_hud)
- }
- else
- {
- make_hud_body("No hay votos")
- }
- }
- fnTeamsRandomize()
- {
- new iPlayers[MAX_PLAYERS],iNum;
- get_players(iPlayers,iNum);
- for(new i;i < iNum;i++)
- {
- if(!(1 <= get_user_team(iPlayers[i]) <= 2))
- {
- iPlayers[i--] = iPlayers[--iNum];
- }
- }
- new iTeam = random(2) ? 1 : 2;
- new iPlayer,iRandom;
- while(iNum)
- {
- iRandom = random(iNum);
- iPlayer = iPlayers[iRandom];
- rg_set_user_team(iPlayer, iTeam == 1 ? TEAM_TERRORIST : TEAM_CT)
- iPlayers[iRandom] = iPlayers[--iNum];
- iTeam = ((_:iTeam) % 2 + 1);
- }
- EnableHamForward(PlayerSpawn)
- next_vote()
- }
- public fnCaptains()
- {
- new p[32], count
- get_players(p, count, "h")
- if(count >= get_pcvar_num(pcvar_max_players))
- {
- set_task(1.0, "fnCaptainHud")
- client_print_color(0, 0, "%s Se iniciara elecion por capitanes.", TAG)
- set_cvar_num("sv_restart", 1)
- set_cvar_num("sv_maxspeed", 0)
- set_cvar_num("mp_forcerespawn", 0)
- set_cvar_num("mp_round_infinite", 1)
- captainrun = true
- capitan_tt = random_player(1)
- capitan_ct = random_player(2)
- make_menu_team(capitan_tt)
- }
- else
- {
- client_print_color(0, 0, "%s Son necesarios ^4%d^1 jugadores para elecion de capitanes.", TAG, get_pcvar_num(pcvar_max_players))
- set_cvar_num("sv_maxspeed", 320)
- set_cvar_num("mp_round_infinite", 0)
- EnableHamForward(PlayerSpawn)
- next_vote()
- }
- }
- make_menu_team(id)
- {
- new menu = menu_create("\rSelecciona a un jugador", "mh_menu")
- new name[32], num[3]
- new count, selec_count
- for(new i = 1 ; i <= MAXPLAYERS ; i++)
- {
- if(!is_user_connected(i) || is_user_hltv(i) || get_member(i, m_iTeam) != TEAM_SPECTATOR){
- continue
- }
- get_user_name(i, name, charsmax(name))
- num_to_str(i, num, charsmax(num))
- menu_additem(menu, name, num)
- count++
- }
- for(new i = 1 ; i <= MAXPLAYERS ; i++)
- {
- if(!is_user_connected(i) || is_user_hltv(i) || 1 <= get_member(i, m_iTeam) <=2){
- continue
- }
- selec_count++
- }
- if(count == 0 || selec_count == get_pcvar_num(pcvar_max_players))
- {
- menu_destroy(menu)
- set_cvar_num("sv_maxspeed", 320)
- set_cvar_num("mp_round_infinite", 0)
- captainrun = false
- EnableHamForward(PlayerSpawn)
- next_vote()
- team_voting = 0
- return PLUGIN_HANDLED
- }
- remove_task(TASK)
- team_voting = get_user_team(id)
- menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER);
- menu_display(id, menu)
- set_task(5.0, "pfn_end", TASK)
- return PLUGIN_HANDLED
- }
- public mh_menu(id, menu, item)
- {
- if(item == MENU_EXIT)
- {
- return
- }
- if(team_voting != get_user_team(id))
- {
- menu_destroy(menu)
- return
- }
- new num[3], a
- menu_item_getinfo(menu, item, a, num, charsmax(num), "", 0, a)
- menu_destroy(menu)
- new p = str_to_num(num)
- rg_set_user_team(p, team_voting == 1 ? TEAM_TERRORIST : TEAM_CT)
- rg_round_respawn(p)
- remove_task(TASK)
- switch(team_voting)
- {
- case 1 :
- {
- menu_cancel(capitan_tt)
- make_menu_team(capitan_ct)
- }
- case 2 :
- {
- menu_cancel(capitan_ct)
- make_menu_team(capitan_tt)
- }
- }
- }
- public pfn_end()
- {
- new p[32], count
- get_players(p, count, "he", "SPECTATOR")
- if( count > 0 )
- {
- new r = p[random(count)]
- rg_set_user_team(r, team_voting == 1 ? TEAM_TERRORIST : TEAM_CT)
- rg_round_respawn(r)
- }
- switch(team_voting)
- {
- case 1 :
- {
- menu_cancel(capitan_tt)
- make_menu_team(capitan_ct)
- }
- case 2 :
- {
- menu_cancel(capitan_ct)
- make_menu_team(capitan_tt)
- }
- }
- }
- public check_capitan()
- {
- new p[32], num
- get_players(p, num, "he", "SPECTATOR")
- if(!is_user_connected(capitan_ct))
- {
- capitan_ct = p[random(num)]
- rg_set_user_team(capitan_ct, TEAM_CT)
- set_member(capitan_ct, m_iJoiningState, 5)
- }
- if(!is_user_connected(capitan_tt))
- {
- capitan_tt = p[random(num)]
- rg_set_user_team(capitan_tt, TEAM_TERRORIST)
- set_member(capitan_tt, m_iJoiningState, 5)
- }
- }
- public fnCaptainHud()
- {
- if(captainrun) set_task(1.0, "fnCaptainHud")
- check_capitan()
- new szName[15], iTeam,fmt[33 * 33]
- set_hudmessage(0, 255, 0, 0.75, 0.07, 0, 1.0, 1.1)
- ShowSyncHudMsg(0, Sync1, "Seleccion de capitanes")
- copy(fmt, charsmax(fmt), "")
- for(new i = 1 ; i <= get_playersnum(); i++ )
- {
- if(!is_user_connected(i))
- {
- continue
- }
- iTeam = get_user_team(i)
- get_user_name(i, szName, charsmax(szName))
- if(capitan_tt == i || capitan_ct == i)
- {
- switch(iTeam)
- {
- case 1: format(fmt, charsmax(fmt), "%s (C)^n^n%s",szName, fmt)
- case 2: format(fmt, charsmax(fmt), "%s (C)^n^n%s",szName, fmt)
- }
- }
- else
- {
- switch(iTeam)
- {
- case 1: format(fmt, charsmax(fmt), "%s%s^n", fmt, szName)
- case 2: format(fmt, charsmax(fmt), "%s%s^n", fmt, szName)
- case 3: format(fmt, charsmax(fmt), "%s%s^n", fmt, szName)
- }
- }
- }
- set_hudmessage(255, 255, 255, 0.70, 0.1, 0, 1.0, 1.1)
- ShowSyncHudMsg(0, Sync2, fmt)
- copy(fmt, charsmax(fmt), "")
- for(new i = 1 ; i <= get_playersnum() ;i++ )
- {
- if(!is_user_connected(i))
- {
- continue
- }
- iTeam = get_user_team(i)
- if(capitan_tt == i || capitan_ct == i)
- {
- switch(iTeam)
- {
- case 1: format(fmt,charsmax(fmt),"- Terrorista^n^n%s", fmt)
- case 2: format(fmt,charsmax(fmt),"- Anti-Terrorista^n^n%s", fmt)
- }
- }
- else
- {
- switch(iTeam)
- {
- case 1: format(fmt,charsmax(fmt),"%s- Terrorista^n", fmt)
- case 2: format(fmt,charsmax(fmt),"%s- Anti-Terrorista^n", fmt)
- case 3: format(fmt,charsmax(fmt),"%s- En espera^n", fmt)
- }
- }
- }
- set_hudmessage(242, 195, 43, 0.84, 0.1, 1, 1.0, 1.1)
- ShowSyncHudMsg(0, Sync3, fmt)
- }
- public fnCa2ptainHud()
- {
- if(captainrun) set_task(1.0, "fnCaptainHud")
- check_capitan()
- new iPlayers[MAX_PLAYERS],iNum,iPlayer;
- get_players(iPlayers,iNum,"h");
- new szName[20],iCTs,szList[4][320],iTeam,iSpec;
- for(new i;i < iNum;i++)
- {
- iPlayer = iPlayers[i];
- get_user_name(iPlayer,szName, 14);
- if((iPlayer == capitan_tt) || (iPlayer == capitan_ct))
- {
- add(szName,charsmax(szName)," (C)");
- }
- iTeam = get_user_team(iPlayer);
- switch(iTeam)
- {
- case 2: iCTs++;
- case 3: iSpec++;
- }
- add(szName,charsmax(szName),"^n");
- add(szList[iTeam],charsmax(szList[]),szName);
- }
- for(new i = 0;i < (5 - iCTs);i++)
- {
- add(szList[2],charsmax(szList[]),"^n");
- }
- set_hudmessage(0,255,0,0.75,0.17,0,0.0,99.0,0.0,0.0,1);
- show_hudmessage(0,"Terrorostas");
- set_hudmessage(255,255,255,0.75,0.17,0,0.0,99.0,0.0,0.0,2);
- show_hudmessage(0,"^n%s",szList[1]);
- if(iSpec)
- {
- set_hudmessage(0,255,0,0.75,0.32,0,0.0,99.0,0.0,0.0,3);
- show_hudmessage(0,"Anti-Terrorostas^n^n^n^n^n^n^nEspectadores");
- set_hudmessage(255,255,255,0.75,0.32,0,0.0,99.0,0.0,0.0,4);
- show_hudmessage(0,"^n%s^n^n%s",szList[2],szList[3]);
- }
- else
- {
- set_hudmessage(0,255,0,0.75,0.32,0,0.0,99.0,0.0,0.0,3);
- show_hudmessage(0,"Anti-Terrorostas");
- set_hudmessage(255,255,255,0.75,0.32,0,0.0,99.0,0.0,0.0,4);
- show_hudmessage(0,"^n%s",szList[2]);
- }
- }
- /* STOCK de eleccion random */
- random_player(team)
- {
- if(!(1 <= team <= 2))
- {
- log_error(AMX_ERR_NATIVE, "[CAPITAN] Team incorrecto")
- return 0
- }
- new p[32], count
- get_players(p, count, "e", team == 1 ? "TERRORIST" : "CT")
- new t = p[random(count)]
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(t == i || team != get_user_team(i))
- {
- continue
- }
- cmdDirector(i, "kill")
- rg_set_user_team(i, TEAM_SPECTATOR)
- set_member(i, m_iJoiningState, 5)
- }
- return t
- }
- public start_countdown()
- {
- EnableHamForward(PlayerPostink)
- client_cmd(0, "+strafe")
- g_vote_countdown = 4
- set_task(1.0, "pfn_starting_game", TASK_HUD_READY, _, _, "b")
- pfn_starting_game(TASK_HUD_READY)
- set_pcvar_num(g_pcvar_votemap, 1)
- }
- public start_pug()
- {
- set_cvar_num("sv_restart", 1)
- for(new i = 0 ; i < sizeof(PugStartCmds) ;i++)
- {
- set_cvar_string(PugStartCmds[i][COMMAND], PugStartCmds[i][VALUE])
- }
- g_iRounds = 0;
- arrayset(g_iRound_team, 0, 2)
- arrayset(g_iFrags, 0, MAXPLAYERS)
- arrayset(g_iDeaths, 0, MAXPLAYERS)
- is_intermission = false
- DisableHamForward(DefuseKit)
- }
- public pfn_force_start_pug(id)
- {
- if(!(get_user_flags(id) & ADMIN_RCON))
- {
- client_print_color(id, 0, "%s No tienes acceso a este comando", TAG)
- return
- }
- else if(pug_state != NO_ALIVE)
- {
- client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
- return
- }
- start_vote()
- }
- public pfn_force_cancel(id)
- {
- if(!is_user_admin(id))
- {
- client_print_color(id, 0, "%s No tienes acceso a este comando", TAG)
- return
- }
- else if(pug_state != ALIVE)
- {
- client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
- return
- }
- new name[32]
- get_user_name(id, name, charsmax(name))
- client_print_color(0, 0, "%s ADMIN: %s Ha cancelado la partida", TAG, name)
- start_pregame()
- }
- public pfn_forceready(id)
- {
- if(!is_user_admin(id))
- {
- client_print_color(id, 0, "%s No tienes acceso a este comando", TAG)
- return
- }
- else if(pug_state != NO_ALIVE)
- {
- client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
- return
- }
- fn_forceready()
- }
- fn_forceready()
- {
- for(new i = 1 ; i<= iMaxPlayers ; i++)
- {
- if(!is_user_connected(i) || !(1<= get_user_team(i) <= 2) || ready[i])
- {
- continue
- }
- ready[i] = true;
- ready_count++
- if(ready_count == get_pcvar_num(pcvar_max_players))
- {
- start_vote()
- }
- }
- }
- public pfn_waiting_players(task)
- {
- new pcount = 0
- for(new i = 1 ; i <= iMaxPlayers ; i++)
- {
- if(!is_user_connected(i) || !(1 <= get_user_team(i) <= 2))
- {
- continue;
- }
- pcount++
- }
- if(g_vote_countdown -- > 0)
- {
- if(pcount == get_pcvar_num(pcvar_max_players))
- {
- center_print(0, "Calentamiento 00:%02i^n^n^n^n", g_vote_countdown)
- if(g_vote_countdown < 5)
- {
- client_cmd(0, "spk ^"%s^"", SND_COUNTER_BEEP[6])
- }
- }
- else
- {
- center_print(0, "Esperando jugadores 00:%02i^n^n^n^n", g_vote_countdown)
- }
- }
- else if(g_vote_countdown <= 0 && pcount == get_pcvar_num(pcvar_max_players))
- {
- remove_task(task)
- next_vote()
- }
- else
- {
- set_pcvar_num(g_pcvar_votemap, 1)
- remove_task(task)
- start_pregame()
- fn_forceready();
- client_print_color(0, 0, "%s Partida no iniciada por la ausencia de jugadores", TAG)
- }
- }
- public pfn_starting_game(task)
- {
- if(g_vote_countdown == 1)
- {
- start_pug()
- pug_state = COMMENCING
- }
- if(g_vote_countdown -- > 0)
- {
- center_print(0, "Empezando Partida: %i^n^n^n^n", g_vote_countdown)
- }
- else
- {
- DisableHamForward(PlayerPostink)
- client_cmd(0, "-strafe")
- remove_task(task)
- }
- }
- public plugin_precache()
- {
- precache_generic(SND_COUNTER_BEEP)
- precache_generic(SND_STINGER)
- for(new i = 0 ; i < sizeof(SND_MUSIC) ; i++)
- {
- precache_generic(SND_MUSIC[i])
- }
- }
- stock cmdDirector(id, cmd[])
- {
- message_begin(id > 0 ? MSG_ONE : MSG_ALL, SVC_DIRECTOR, _, id > 0 ? id : 0)
- write_byte(strlen(cmd) + 2)
- write_byte(10)
- write_string(cmd)
- message_end()
- }
- public pfn_Surrender(id)
- {
- if(pug_state == ALIVE && OffFreeze && !OnSurrender )
- {
- if(tryid[id] == get_pcvar_num(pcvar_max_tryid))
- {
- client_print_color(id, print_team_default, "%s Solo puedes usar este comando^4 %d ^1vez por mapa", TAG, get_pcvar_num(pcvar_max_tryid))
- return
- }
- if(c[get_member(id, m_iTeam)] > get_systime())
- {
- new msj
- msj = c[suteam]-get_systime()
- client_print_color(id, print_team_default, "%s Tu equipo debe esperar ^3%02i:%02i^1 segundos para reintentar rendirse.", TAG, msj/60, msj % 60)
- return
- }
- suteam = get_member(id, m_iTeam)
- OnSurrender = true
- //tryid[suteam]=true
- tryid[id]++
- get_user_name(id, name, charsmax(name))
- c[suteam] = get_systime()+120
- for(new i=1; i<get_maxplayers(); i++)
- {
- if(!is_user_connected(i))
- {
- continue
- }
- if(get_member(i, m_iTeam) == suteam)
- {
- client_print_color(i, id, "%s Una votacion inciara al inicio de ronda.", TAG)
- }
- else
- {
- client_print_color(i, id, "%s El equipo %s realizara una votacion para rendirse.", TAG, suteam==1?"terrorista":"anti-terrorista")
- }
- }
- }
- }
- public pfn_surren_handler(id, menu, item)
- {
- switch(item)
- {
- case 0:
- {
- g_cvotes[0]++
- }
- case 1:
- {
- g_cvotes[1]++
- }
- }
- }
- public pfn_hud_vote_surrender()
- {
- g_vote_count = 0
- g_vote_countdown = 10
- set_task(1.0, "pfn_hud_votesurrender", TASK_PUG_END, _, _, "b")
- }
- public pfn_hud_votesurrender(task)
- {
- g_vote_countdown--
- if(g_vote_countdown > 0)
- {
- for(new i = 1 ; i <= get_maxplayers() ; i++)
- {
- if(!is_user_connected(i) || get_member(i, m_iTeam) != suteam)
- {
- continue;
- }
- center_print(i, "Votacion para rendirse^n^nTermina en %i segundos^n^n^n^n", g_vote_countdown)
- }
- }
- else{
- remove_task(task)
- }
- }
- public pfn_End_FreezeTime()
- {
- OffFreeze=true
- new p[32], count
- get_players(p, count, "e", suteam == 1 ? "TERRORIST" : "CT")
- if(OnSurrender)
- {
- if(g_cvotes[0] >= count)
- {
- client_print_color(0, suteam==1?print_team_red:print_team_blue, "%s El equipo ^3%s^1 se ha rendido.", TAG, suteam==1?"Terrorista":"Anti-Terrorista")
- //pug_force_end(suteam == 1 ? 2:1)
- EnableHamForward(PlayerPostink)
- client_cmd(0, "+strafe")
- g_vote_countdown = 15
- set_task(1.0, "pfn_pug_end_countdown", TASK_PUG_END, _, _, "b")
- is_intermission = true
- ExecuteForward(g_forward, _, suteam == 1 ? 1 : suteam == 2 ? 2 : 0)
- Send_TextMsg(suteam == 1 ? "#Terrorists_Win" : suteam == 2 ? "#CTs_Win" : "")
- client_cmd(0, "mp3 play ^"%s^"", SND_MUSIC[random_num(0, charsmax(SND_MUSIC))])
- cmdDirector(0, "MP3FadeTime 0.5")
- }
- else
- {
- client_print_color(0, suteam==1?print_team_red:print_team_blue, "%s El equipo ^3%s^1 decidió que no se rendira.", TAG, suteam==1?"Terrorista":"Anti-Terrorista")
- }
- menu_destroy(menu_surrender)
- OnSurrender = false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement