SHARE
TWEET

Untitled

a guest May 25th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. #include <csx>
  5. #include <hamsandwich>
  6. #include <fakemeta>
  7. #include <reapi>
  8. #include <celltrie>
  9.  
  10. #define PLUGIN  "RE-PUG"
  11. #define VERSION "1.35"
  12. #define AUTHOR  "Sugisaki & Flys"
  13.  
  14. #define END_ROUND_KNIFE_FIX
  15.  
  16. #define MAXPLAYERS 15
  17.  
  18. #define get_user_team(%i) get_member(%i, m_iTeam)
  19.  
  20. new TASK_HUD_READY = 552214
  21. new TASK_HUD_VOTE = 996541
  22. new TASK_END_VOTE = 441017
  23. new TASK_PUG_END = 778745
  24. new TASK_HUD_MONEY = 55414
  25.  
  26. new const TAG[] = "^4[CBP]^1"
  27. new const GameName[] = "Hola soy tu gamename"
  28.  
  29. enum _:PUGSTATE
  30. {
  31.     NO_ALIVE = 0,
  32.     ALIVE,
  33.     COMMENCING
  34. }
  35.  
  36. enum _:PUG_ROUND
  37. {
  38.     TT = 0,
  39.     CT
  40. }
  41.  
  42. new bool:RoundRestart
  43. new Trie:t_Command
  44. new Trie:t_Command_Plugin
  45. new pug_state
  46. new g_PluginId
  47. new iMaxPlayers
  48. new bool:ready[MAXPLAYERS]
  49. new ready_count
  50. new HamHook:SpawnWeapon
  51. new HamHook:DefuseKit
  52. new HamHook:PlayerPostink
  53. new HamHook:PlayerSpawn
  54. new bool:vote_map
  55. new bool:vote_knife
  56. new g_vote_id
  57. new g_pcvar_votemap
  58. new g_vote_countdown
  59. new bool:private
  60. new Trie:g_private
  61. new bool:round_knife
  62. new bool:half_time
  63. new team_check_id
  64. new team_check_time
  65. new Float:last_damage[MAXPLAYERS][MAXPLAYERS]
  66. new bool:round_start
  67. new g_forward
  68. new g_forward_round_end
  69.  
  70. new bool:round_knife_start_vote    
  71. new bool:torneo_limit
  72. new bool:captainrun
  73.  
  74. new TASK = 41454
  75. new capitan_ct
  76. new capitan_tt
  77. new team_voting
  78.  
  79. new Sync1
  80. new Sync2
  81. new Sync3
  82. new pcvar_max_players
  83.  
  84. new g_iDmg[MAXPLAYERS][MAXPLAYERS]
  85. new g_iHits[MAXPLAYERS][MAXPLAYERS]
  86. new Array:g_maps
  87. new g_votes[32]
  88. new g_iRound_team[2]
  89. new g_iRounds
  90. new g_iFrags[MAXPLAYERS]
  91. new g_iDeaths[MAXPLAYERS]
  92.  
  93. new g_vote_count
  94.  
  95. new g_VoteMenu
  96.  
  97. new gMsgStatusIcon
  98. new gMsgRegisterStatusIcon
  99.  
  100. new gMsgServerName
  101. new gMsgTextMsg
  102. new gMsgScoreInfo
  103. new gMsgTeamScore
  104.  
  105. new bool:is_intermission
  106.  
  107. new bool:OnSurrender, bool:OffFreeze, menu_surrender, g_cvotes[2], suteam
  108. new name[32], tryid[33], c[33]
  109. new pcvar_max_tryid
  110.  
  111. new SND_MUSIC[][] =
  112. {
  113.     "sound/pug/music1.mp3"
  114. }
  115. new SND_COUNTER_BEEP[] = "sound/UI/buttonrollover.wav"
  116. new SND_STINGER[] = "sound/pug/cs_stinger.wav"
  117.  
  118. enum _:CMDS
  119. {
  120.     COMMAND[40],
  121.     VALUE[10]
  122. }
  123.  
  124. new Pregame_Cmds[][CMDS] =
  125. {
  126.     {"mp_forcerespawn", "1"},
  127.     {"mp_round_infinite", "acdefg"},
  128.     {"mp_auto_reload_weapons", "1"},
  129.     {"mp_auto_join_team", "0"},
  130.     {"mp_autoteambalance", "0"},
  131.     {"mp_limitteams", "1"},
  132.     {"mp_freezetime", "0"},
  133.     {"mp_timelimit", "0"},
  134.     {"mp_refill_bpammo_weapons", "3"},
  135.     {"mp_startmoney", "16000"},
  136.     {"sv_alltalk", "1"},
  137.     {"mp_buytime", "-1"},
  138.     {"mp_consistency", "1"},    
  139.     {"mp_flashlight", "0"},
  140.     {"mp_forcechasecam", "0"},
  141.     {"mp_forcecamera", "0"},
  142.     {"mp_item_staytime", "0"},
  143.     {"mp_roundtime", "9"},
  144.     {"allow_spectators", "1"},
  145.     {"mp_friendlyfire", "0"},
  146.     {"mp_respawn_immunitytime", "5"},
  147.     {"mp_roundrespawn_time", "0"},
  148.     {"sv_timeout", "20"},
  149.     {"sv_rehlds_stringcmdrate_burst_punish", "-1"},
  150.     {"sv_rehlds_stringcmdrate_avg_punish ", "-1"},
  151.     {"sv_rehlds_movecmdrate_burst_punish", "-1"},
  152.     {"sv_rehlds_movecmdrate_avg_punish", "-1"},
  153.     {"sv_rehlds_force_dlmax", "1"}
  154. }
  155.  
  156. new PugStartCmds[][CMDS] =
  157. {
  158.     {"mp_forcerespawn", "0"},
  159.     {"mp_startmoney", "800"},
  160.     {"mp_freezetime", "6"},
  161.     {"sv_alltalk", "2"},
  162.     {"mp_limitteams", "0"},
  163.     {"mp_refill_bpammo_weapons", "0"},
  164.     {"mp_buytime", ".25"},
  165.     {"mp_forcechasecam", "2"},
  166.     {"mp_item_staytime", "300"},
  167.     {"mp_forcecamera", "2"},
  168.     {"mp_freezetime", "11"},
  169.     {"mp_roundtime", "1.75"},
  170.     {"mp_respawn_immunitytime", "0"},
  171.     {"mp_roundrespawn_time", "10"},
  172.     {"mp_auto_join_team", "0"}
  173. }
  174.  
  175. public plugin_init()
  176. {
  177.     g_PluginId = register_plugin(PLUGIN, VERSION, AUTHOR)
  178.    
  179.     pug_state = NO_ALIVE
  180.    
  181.     register_clcmd("say", "pfn_Hook_Say")
  182.     register_clcmd("say_team", "pfn_Hook_Say")
  183.    
  184.     pcvar_max_players = register_cvar("pug_players", "10")
  185.     g_pcvar_votemap = register_cvar("pug_votemap", "1")
  186.     pcvar_max_tryid = register_cvar("pug_rendirse", "2")
  187.    
  188.     SpawnWeapon = RegisterHam(Ham_Spawn, "weaponbox", "pfn_remove_weapon", 1)
  189.     PlayerPostink = RegisterHam(Ham_Player_PostThink, "player", "pfn_postink", 1)
  190.     PlayerSpawn = RegisterHam(Ham_Spawn, "player", "pfn_player_spawn", 1)
  191.     DefuseKit = RegisterHam(Ham_Spawn, "item_thighpack", "pfn_remove_weapon", 1)
  192.     DisableHamForward(PlayerSpawn)
  193.     DisableHamForward(PlayerPostink)
  194.     register_forward( FM_GetGameDescription, "GameDesc" )
  195.    
  196.     register_event("DeathMsg", "pfn_PlayerDeath", "a")
  197.     register_event("Money", "pfn_money", "b")
  198.     register_event("Damage", "pfn_EVENT_damage", "b")
  199.     register_event("HLTV", "EV_new_round", "a", "1=0", "2=0")
  200.    
  201.     g_maps = ArrayCreate(32)
  202.     g_private = TrieCreate()
  203.     t_Command = TrieCreate()
  204.     t_Command_Plugin = TrieCreate()
  205.     iMaxPlayers = get_maxplayers();
  206.     Sync1 = CreateHudSyncObj()
  207.     Sync2 = CreateHudSyncObj()
  208.     Sync3 = CreateHudSyncObj()
  209.     gMsgStatusIcon = get_user_msgid("StatusIcon")
  210.     gMsgServerName = get_user_msgid("ServerName")
  211.     gMsgTextMsg = get_user_msgid("TextMsg")
  212.     gMsgScoreInfo = get_user_msgid("ScoreInfo")
  213.     gMsgTeamScore = get_user_msgid("TeamScore")
  214.     g_forward = CreateMultiForward("pug_end", ET_STOP, FP_CELL)
  215.     g_forward_round_end = CreateMultiForward("pug_round_end", ET_STOP, FP_CELL)
  216.    
  217.     register_message(gMsgTeamScore, "pfn_TeamScore")
  218.    
  219.     RegisterHookChain(RG_RoundEnd, "pfn_Round_End_Hook")
  220.     RegisterHookChain(RG_HandleMenu_ChooseTeam, "pfn_Hook_ChooseTeam")
  221.     RegisterHookChain(RG_CSGameRules_OnRoundFreezeEnd, "pfn_End_FreezeTime", true)
  222.    
  223.     register_message(gMsgTextMsg, "pfn_TextMsg")
  224.     register_message(gMsgScoreInfo, "pfn_ScoreInfo")
  225.     register_message(get_user_msgid("SendAudio"), "pfnSendAudioHook")
  226.    
  227.     pug_register_command(".ready", "pfn_ready", g_PluginId)
  228.     pug_register_command(".notready", "pfn_unready", g_PluginId)
  229.     pug_register_command(".score", "pfn_score", g_PluginId)
  230.    
  231.     pug_register_command(".start", "pfn_force_start_pug", g_PluginId)
  232.     pug_register_command(".forceready", "pfn_forceready", g_PluginId)
  233.     pug_register_command(".cancel", "pfn_force_cancel", g_PluginId)
  234.    
  235.     pug_register_command(".dmg", "cmd_dmg", g_PluginId)
  236.     pug_register_command(".rdmg", "cmd_rdmg", g_PluginId)
  237.     pug_register_command(".hp", "cmds_vidas", g_PluginId)
  238.     pug_register_command(".hpteam", "cmds_vidas_team", g_PluginId)
  239.  
  240.     pug_register_command(".rendirse", "pfn_Surrender", g_PluginId)
  241.    
  242.     set_task(5.0, "start_pregame")
  243.     read_maps()
  244. }
  245.  
  246. public pfnSendAudioHook(m, e, id)
  247. {
  248.     new sz[20]
  249.     get_msg_arg_string(2, sz, charsmax(sz))
  250.     if(equal(sz, "%!MRAD_ctwin") || equal(sz, "%!MRAD_terwin") || equal(sz, "%!MRAD_BOMBDEF"))
  251.     {
  252.         return PLUGIN_HANDLED
  253.     }
  254.     return PLUGIN_CONTINUE
  255. }
  256.  
  257. public pfn_player_spawn(id)
  258. {
  259.     if(!is_user_alive(id))
  260.     {
  261.         return
  262.     }
  263.     if(round_knife)
  264.     {
  265.         rg_remove_all_items(id)
  266.         rg_give_item(id, "weapon_knife")
  267.         set_member(id, m_iAccount, 1)
  268.     }
  269. }
  270.  
  271. public pfn_money(id)
  272. {
  273.     if(round_knife)
  274.     {
  275.         set_member(id, m_iAccount, 1)
  276.         return
  277.     }
  278.     if(pug_state == ALIVE)
  279.     {
  280.         if(get_member_game(m_bFreezePeriod))
  281.         {
  282.             update_team_money(get_user_team(id))
  283.         }
  284.         return
  285.     }
  286.     set_member(id, m_iAccount, 25000)
  287. }
  288.  
  289. public pfn_PlayerDeath()
  290. {
  291.     if(pug_state == ALIVE && !is_intermission && !round_knife )
  292.     {
  293.         new v = read_data(2)
  294.         new k = read_data(1)
  295.         if(!(1<= k <= iMaxPlayers) || v == k)
  296.         {
  297.             g_iDeaths[v]++
  298.             g_iFrags[v]--
  299.         }
  300.         else
  301.         {
  302.             g_iFrags[k]++
  303.             g_iDeaths[v]++
  304.         }
  305.         new dteam = get_user_team(v)
  306.         new name1[32]
  307.         new name2[32]
  308.         new name3[32]
  309.         get_user_name(k, name1, 31)
  310.         get_user_name(v, name2, 31)
  311.  
  312.         new u, b
  313.         get_user_aiming(v, u, b)
  314.  
  315.         for(new i = 1 ; i <= iMaxPlayers ; i++)
  316.         {
  317.             if(!is_user_alive(i) || get_user_team(i) == dteam || i == k )
  318.             {
  319.                 continue
  320.             }
  321.             if(last_damage[v][i] > get_gametime() || u == i )
  322.             {
  323.                 client_print_color(i, 0, "^4*** %s Te Ha salvado matando a %s ***", name1, name2)
  324.                 get_user_name(i, name3, 31)
  325.                 client_print_color(k, 0, "^4*** Has salvado a %s ***", name3)
  326.             }
  327.         }
  328.         if(!torneo_limit){
  329.             cmd_dmg(v)
  330.         }
  331.     }
  332. }
  333.  
  334. public pfn_ScoreInfo(m, s, id)
  335. {
  336.     static _score_player_id
  337.     _score_player_id = get_msg_arg_int(1)
  338.     if(pug_state == ALIVE && !round_knife)
  339.     {
  340.         set_msg_arg_int(2, ARG_SHORT, g_iFrags[_score_player_id])
  341.         set_msg_arg_int(3, ARG_SHORT, g_iDeaths[_score_player_id])
  342.     }
  343. }
  344.  
  345. public cmds_vidas(id)
  346. {
  347.     if(pug_state != ALIVE || is_user_alive(id))
  348.     {
  349.         client_print_color(id, id, " Accion no permitida en este momento", TAG)
  350.         return
  351.     }
  352.     if(torneo_limit){
  353.         client_print_color(id, id, "%s Accion no permitida en modo torneo", TAG)
  354.         return;
  355.     }
  356.     new team = get_user_team(id)
  357.     new name[32]
  358.     for(new i = 1 ; i <= iMaxPlayers ; i++)
  359.     {
  360.         if(team == get_user_team(i) || !is_user_alive(i)) continue
  361.  
  362.         get_user_name(i, name, 32)
  363.         client_print_color(id, i, "%s %s HP: %i", TAG, name, get_user_health(i))
  364.     }
  365. }
  366.  
  367. public cmds_vidas_team(id)
  368. {
  369.     if(pug_state != ALIVE || (is_user_alive(id) && round_start))
  370.     {
  371.         client_print_color(id, id, "%s Accion no permitida en este momento", TAG)
  372.         return
  373.     }
  374.     new team = get_user_team(id)
  375.     new name[32]
  376.     for(new i = 1 ; i <= iMaxPlayers ; i++)
  377.     {
  378.         if(team != get_user_team(i) || 1 <= get_user_team(i) <= 2 || !is_user_alive(i))    continue
  379.         get_user_name(i, name, 32)
  380.         client_print_color(id, i, "%s %s HP: %i", TAG, name, get_user_health(i))
  381.     }
  382. }
  383.  
  384. public pfn_EVENT_damage(id)
  385. {
  386.     new a = get_user_attacker(id)
  387.     new damage = read_data(2)
  388.  
  389.     if(pug_state != ALIVE || !is_user_alive(a) || !(1 <= a <= iMaxPlayers) || a == id || damage <= 0)
  390.     {
  391.         return
  392.     }
  393.    
  394.     g_iDmg[id][a] += damage
  395.     g_iHits[id][a] += 1
  396.     last_damage[id][a] = get_gametime() + 0.5
  397. }
  398.  
  399. public cmd_dmg(id)
  400. {
  401.     if(pug_state != ALIVE || (is_user_alive(id) && round_start))
  402.     {
  403.         client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
  404.         return
  405.     }
  406.     if(torneo_limit){
  407.         client_print_color(id, id, "%s Accion no permitida en modo torneo", TAG)
  408.         return
  409.     }
  410.     new tmp_name[32], count
  411.     client_print(id, print_console, "===========[ DMG ]===========")
  412.     for(new i = 0 ; i <= MAXPLAYERS ; i++)
  413.     {
  414.         if(!is_user_connected(i))
  415.         {
  416.             continue;
  417.         }
  418.        
  419.         if(g_iHits[i][id] > 0)
  420.         {
  421.            
  422.             get_user_name(i, tmp_name, charsmax(tmp_name))
  423.  
  424.             client_print_color(id, 0, "%s | %s | Dmg: %i | Hits: %i ", TAG, tmp_name, g_iDmg[i][id], g_iHits[i][id])
  425.             client_print(id, print_console, "| %s | Dmg: %i | Hits: %i ", tmp_name, g_iDmg[i][id], g_iHits[i][id])
  426.  
  427.             count++
  428.         }
  429.     }
  430.    
  431.     if(!count)
  432.     {
  433.         client_print_color(id, 0, "%s No Le diste a nadie en esta ronda", TAG)
  434.         console_print(id, "%s No Le diste a nadie en esta ronda", TAG)
  435.     }
  436.     client_print(id, print_console, "=============================")
  437. }
  438.  
  439. public cmd_rdmg(id)
  440. {
  441.     if(pug_state != ALIVE || (is_user_alive(id) && round_start))
  442.     {
  443.         client_print_color(id, id, "%s Accion no permitida en este momento", TAG)
  444.         return
  445.     }
  446.     new tmp_name[32], count
  447.     client_print(id, print_console, "===========[ RDMG ]===========")
  448.     for(new i = 0 ; i <= MAXPLAYERS ; i++)
  449.     {
  450.         if(!is_user_connected(i))
  451.         {
  452.             continue;
  453.         }
  454.         if(g_iHits[id][i] > 0)
  455.         {  
  456.             get_user_name(i, tmp_name, charsmax(tmp_name))
  457.  
  458.             client_print_color(id, id, "%s | %s | RDmg: %i | Hits: %i ", TAG, tmp_name, g_iDmg[id][i], g_iHits[id][i])
  459.             client_print(id, print_console, "| %s | Dmg: %i | Hits: %i ", tmp_name, g_iDmg[id][i], g_iHits[id][i])
  460.             count++
  461.         }
  462.     }
  463.     if(!count)
  464.     {
  465.         client_print_color(id, id, "%s No recibiste daño esta ronda", TAG)
  466.     }
  467.     client_print(id, print_console, "=============================")
  468. }
  469.  
  470. public bomb_explode(id)
  471. {
  472.     g_iFrags[id] += 3
  473. }
  474.  
  475. public bomb_defused(id)
  476. {
  477.     g_iFrags[id] += 3
  478. }
  479.  
  480. public pfn_TeamScore(m, e, id)
  481. {
  482.     static _____team_score[2]
  483.     get_msg_arg_string(1, _____team_score, charsmax(_____team_score))
  484.     switch(_____team_score[0])
  485.     {
  486.         case 'T' : set_msg_arg_int(2, ARG_SHORT, g_iRound_team[TT])
  487.         case 'C' : set_msg_arg_int(2, ARG_SHORT, g_iRound_team[CT])
  488.     }
  489. }
  490.  
  491. public newRound(id)
  492. {
  493.     fn_update_server_name(id)
  494. }
  495.  
  496. public pfn_Round_End_Hook(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
  497. {
  498.     if(pug_state == NO_ALIVE || event == ROUND_GAME_RESTART || event == ROUND_GAME_COMMENCE || status == WINSTATUS_DRAW)
  499.     {
  500.         return HC_CONTINUE
  501.     }
  502.     else if(is_intermission)
  503.     {
  504.         SetHookChainReturn(ATYPE_INTEGER, 1)
  505.         return HC_SUPERCEDE
  506.     }
  507.     if(round_knife)
  508.     {
  509.         client_print_color(0, 0, "%s Ronda cuchillo finalizada, elegiran equipo los %s", TAG, status == WINSTATUS_CTS ? "Anti-Terroristas" : "Terroristas")
  510.        
  511.         round_knife = false
  512.         #if defined END_ROUND_KNIFE_FIX
  513.         set_cvar_num(Pregame_Cmds[1][COMMAND], 1)
  514.         #endif
  515.         DisableHamForward(PlayerSpawn)
  516.  
  517.         Send_TextMsg(status == WINSTATUS_TERRORISTS ? "#Terrorists_Win" : status == WINSTATUS_CTS ? "#CTs_Win" : "")
  518.  
  519.         start_vote_win_team_knife(status == WINSTATUS_TERRORISTS ? 1 : 2)
  520.  
  521.         DisableHamForward(SpawnWeapon)
  522.         unregister_message(gMsgStatusIcon, gMsgRegisterStatusIcon)
  523.         rg_send_audio(0, status == WINSTATUS_TERRORISTS ? "%!MRAD_terwin" : status == WINSTATUS_CTS ? "%!MRAD_ctwin" : "%!MRAD_rounddraw", PITCH_NORM)
  524.         SetHookChainReturn(ATYPE_INTEGER, 1)
  525.         return HC_SUPERCEDE
  526.     }
  527.     round_start = false
  528.     if(status == WINSTATUS_CTS)
  529.     {
  530.         g_iRound_team[CT]++
  531.         emessage_begin(MSG_ALL, gMsgTeamScore)
  532.         ewrite_string("CT")
  533.         ewrite_short(g_iRound_team[CT])
  534.         emessage_end()
  535.         if(event == ROUND_BOMB_DEFUSED)
  536.         {
  537.             client_cmd(0, "spk ^"radio/bombdef ctwin^"")
  538.         }
  539.         else
  540.         {
  541.             client_cmd(0, "spk radio/ctwin")
  542.         }
  543.         ExecuteForward(g_forward_round_end, _, 2)
  544.     }
  545.     else if(status == WINSTATUS_TERRORISTS)
  546.     {
  547.         client_cmd(0, "spk radio/terwin")
  548.         g_iRound_team[TT]++
  549.         emessage_begin(MSG_ALL, gMsgTeamScore)
  550.         ewrite_string("TERRORIST")
  551.         ewrite_short(g_iRound_team[TT])
  552.         emessage_end()
  553.         ExecuteForward(g_forward_round_end, _, 1)
  554.     }
  555.     fn_update_server_name(0)
  556.  
  557.     set_task(0.1, "end_dmg")
  558.  
  559.     if(g_iRounds == 15 && !half_time)
  560.     {
  561.         EnableHamForward(PlayerPostink)
  562.         client_cmd(0, "+strafe")
  563.         g_vote_countdown = 11
  564.         set_task(1.0, "pfn_intermission_count", TASK_HUD_READY, _, _, "b")
  565.         rg_round_end(float(g_vote_countdown) + 0.5, WINSTATUS_DRAW, ROUND_NONE, "", "")
  566.         is_intermission = true
  567.         half_time = true
  568.  
  569.         Send_TextMsg(status == WINSTATUS_TERRORISTS ? "#Terrorists_Win" : status == WINSTATUS_CTS ? "#CTs_Win" : "")
  570.         client_cmd(0, "mp3 play ^"%s^"", SND_MUSIC[random_num(0, charsmax(SND_MUSIC))])
  571.         cmdDirector(0, "MP3FadeTime 0.5")
  572.         SetHookChainReturn(ATYPE_INTEGER, 1)
  573.         return HC_SUPERCEDE
  574.     }
  575.     else if(g_iRounds == 30 || g_iRound_team[CT] >= 16 || g_iRound_team[TT] >= 16)
  576.     {
  577.         EnableHamForward(PlayerPostink)
  578.         client_cmd(0, "+strafe")
  579.         g_vote_countdown = 15
  580.         set_task(1.0, "pfn_pug_end_countdown", TASK_PUG_END, _, _, "b")
  581.         is_intermission = true
  582.  
  583.         ExecuteForward(g_forward, _, status == WINSTATUS_TERRORISTS ? 1 : status == WINSTATUS_CTS ? 2 : 0)
  584.         Send_TextMsg(status == WINSTATUS_TERRORISTS ? "#Terrorists_Win" : status == WINSTATUS_CTS ? "#CTs_Win" : "")
  585.         client_cmd(0, "mp3 play ^"%s^"", SND_MUSIC[random_num(0, charsmax(SND_MUSIC))])
  586.         cmdDirector(0, "MP3FadeTime 0.5")
  587.         SetHookChainReturn(ATYPE_INTEGER, 1)
  588.         return HC_SUPERCEDE
  589.     }
  590.     return HC_CONTINUE
  591. }
  592.  
  593. public start_vote_win_team_knife(team)
  594. {
  595.     arrayset(g_votes, 0, sizeof(g_votes))
  596.     g_vote_count = 0
  597.     set_task(5.0, "end_vote_team_win_knife", TASK_END_VOTE)
  598.     for(new i = 1 ; i <= iMaxPlayers ; i++)
  599.     {
  600.         if(get_user_team(i) == team)
  601.         {
  602.             make_vote_win_team_knife(i);
  603.         }
  604.     }
  605. }
  606.  
  607. make_vote_win_team_knife(id)
  608. {
  609.     round_knife_start_vote = true
  610.     new menu = menu_create("\r¿Cambiar el equipo actual?", "mh_vote_team_win_knife")
  611.     menu_additem(menu, "Si")
  612.     menu_additem(menu, "No")
  613.     menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER)
  614.     menu_display(id, menu, 0, 5)
  615. }
  616.  
  617. public mh_vote_team_win_knife(id, menu, item)
  618. {
  619.     if(item == MENU_EXIT || !round_knife_start_vote)
  620.     {
  621.         menu_destroy(menu)
  622.         return
  623.     }
  624.     menu_destroy(menu)
  625.     if(item > 2)
  626.     {
  627.         return
  628.     }
  629.     g_votes[item] += 1
  630.     g_vote_count += 1
  631.     if(g_vote_count >= get_team_num(get_user_team(id)))
  632.     {
  633.         end_vote_team_win_knife(TASK_END_VOTE)
  634.     }
  635.     return
  636. }
  637.  
  638. public end_vote_team_win_knife(task)
  639. {
  640.     remove_task(task)
  641.     new w = 0;
  642.     for(new i = 0 ; i < sizeof (g_votes) ; i++)
  643.     {
  644.         if(g_votes[w] > g_votes[i])
  645.         {
  646.             w = i
  647.         }
  648.     }
  649.     if(g_vote_count <= 0)
  650.     {
  651.         w = 0;
  652.     }
  653.     if(w)
  654.     {
  655.         for(new i = 1 ; i <= get_pcvar_num(pcvar_max_players) ; i++)
  656.         {
  657.             if(!is_user_connected(i))
  658.             {
  659.                 continue;
  660.             }
  661.             rg_switch_team(i)
  662.         }
  663.     }
  664.     arrayset(g_votes, 0, sizeof(g_votes))
  665.     g_vote_count = 0;
  666.     round_knife_start_vote = false
  667.     set_cvar_num("sv_restart", 1)
  668. }
  669.  
  670. get_team_num(team)
  671. {
  672.     new count = 0
  673.     for(new i = 1 ; i <= get_playersnum() ;i++)
  674.     {
  675.         if(!is_user_connected(i))
  676.         {
  677.             continue
  678.         }
  679.         if(get_user_team(i) == team)
  680.         {
  681.             count += 1
  682.         }
  683.     }
  684.     return count
  685. }
  686.  
  687. public end_dmg()
  688. {
  689.     for(new i = 1; i <= get_playersnum() ; i++)
  690.     {
  691.         if(is_user_alive(i) && !torneo_limit)
  692.         {
  693.             cmd_dmg(i);
  694.         }
  695.     }
  696. }
  697.  
  698. stock Send_TextMsg(msg[])
  699. {
  700.     message_begin(MSG_BROADCAST, gMsgTextMsg)
  701.     write_byte(4)
  702.     write_string(msg)
  703.     message_end()
  704. }
  705.  
  706. public pfn_pug_end_countdown(task)
  707. {
  708.     g_vote_countdown--
  709.     if(g_vote_countdown > 0)
  710.     {
  711.         if(suteam)
  712.         if(g_iRound_team[CT] == g_iRound_team[TT])
  713.         {
  714.             send_server_name(0, "Empate 00:%02i", g_vote_countdown)
  715.         }
  716.         else if(g_iRound_team[CT] >= g_iRound_team[TT])
  717.         {
  718.             send_server_name(0, "Anti-Terroristas Ganan 00:%02i", g_vote_countdown)
  719.         }
  720.         else
  721.         {
  722.             send_server_name(0, "Los Terroristas Ganan 00:%02i", g_vote_countdown)
  723.         }
  724.     }
  725.     else
  726.     {
  727.         DisableHamForward(PlayerPostink)
  728.         client_cmd(0, "-strafe")
  729.         remove_task(task)
  730.         start_pregame()
  731.         client_cmd(0, "-showscores")
  732.         cmdDirector(0, "MP3FadeTime 0.5")
  733.         cmdDirector(0, "cd fadeout")
  734.         fn_update_server_name(0)
  735.     }
  736. }
  737.  
  738. send_server_name(id, msg[], any:...)
  739. {
  740.     new fmt[33]
  741.     vformat(fmt, charsmax(fmt), msg, 3)
  742.     message_begin(id ? MSG_ONE_UNRELIABLE : MSG_ALL, gMsgServerName, _, id)
  743.     write_string(fmt)
  744.     message_end()
  745.  
  746.     message_begin(MSG_ALL, gMsgScoreInfo)
  747.     write_byte(33)
  748.     write_short(0)
  749.     write_short(0)
  750.     write_short(0)
  751.     write_short(0)
  752.     message_end()
  753. }
  754.  
  755. public pfn_intermission_count(task)
  756. {
  757.     g_vote_countdown--
  758.     if(g_vote_countdown > 0)
  759.     {
  760.         send_server_name(0, "Cambio de equipos 00:%02i", g_vote_countdown)
  761.     }
  762.     else
  763.     {
  764.         cmdDirector(0, "MP3FadeTime 0.5")
  765.         cmdDirector(0, "cd fadeout")
  766.         remove_task(task)
  767.         DisableHamForward(PlayerPostink)
  768.         client_cmd(0, "-strafe")
  769.         new temp = g_iRound_team[CT]
  770.         g_iRound_team[CT] = g_iRound_team[TT]
  771.         g_iRound_team[TT] = temp
  772.         for(new i = 1 ; i<= iMaxPlayers ;i++)
  773.         {
  774.             if(!is_user_connected(i) || !(1<= get_user_team(i) <= 2))
  775.             {
  776.                 continue
  777.             }
  778.             rg_switch_team(i)
  779.             set_member(i, m_iAccount, 800);
  780.             if(is_user_alive(i))
  781.             {
  782.                 rg_set_user_armor(i, 0, ARMOR_NONE)
  783.                 rg_give_default_items(i)
  784.                 if(get_member(i, m_bHasC4))
  785.                 {
  786.                     rg_give_item(i, "weapon_c4", GT_REPLACE)
  787.                 }
  788.             }
  789.         }
  790.         fn_update_server_name(0)
  791.         client_cmd(0, "-showscores")
  792.     }
  793. }
  794.  
  795. fn_update_server_name(id)
  796. {
  797.     new szFmt[40]
  798.     if(round_knife)
  799.     {
  800.         formatex(szFmt, charsmax(szFmt), "Ronda de cuchillos")
  801.     }
  802.     else if(pug_state != NO_ALIVE)
  803.     {
  804.         if(g_iRound_team[CT] == g_iRound_team[TT])
  805.         {
  806.             formatex(szFmt, charsmax(szFmt), "Ronda: %i | Empate: %i - %i", g_iRounds, g_iRound_team[CT], g_iRound_team[TT])
  807.         }
  808.         else if(g_iRound_team[CT] > g_iRound_team[TT])
  809.         {
  810.             formatex(szFmt, charsmax(szFmt), "Ronda: %i | CT: %i | TT: %i", g_iRounds, g_iRound_team[CT], g_iRound_team[TT])
  811.         }
  812.         else
  813.         {
  814.             formatex(szFmt, charsmax(szFmt), "Ronda: %i | TT: %i | CT: %i", g_iRounds, g_iRound_team[TT], g_iRound_team[CT])
  815.         }
  816.     }
  817.     else
  818.     {
  819.         formatex(szFmt, charsmax(szFmt), "Esperando Jugadores")
  820.     }
  821.     send_server_name(id, szFmt)
  822.     new nTAG[20]
  823.  
  824.     format(nTAG, charsmax(nTAG), "%s", TAG)
  825.  
  826.  
  827.     replace_all(nTAG, charsmax(nTAG), "^4", "")
  828.     replace_all(nTAG, charsmax(nTAG), "^1", "")
  829.  
  830.     if(pug_state != NO_ALIVE)
  831.     {
  832.         if(round_knife)
  833.         {
  834.             formatex(szFmt, charsmax(szFmt), "Ronda de cuchillos")
  835.         }
  836.         else if(g_iRound_team[CT] == g_iRound_team[TT])
  837.         {
  838.             formatex(szFmt, charsmax(szFmt), "%s: TT: %i vs CT: %i", nTAG, g_iRound_team[CT], g_iRound_team[TT])
  839.         }
  840.         else if(g_iRound_team[CT] > g_iRound_team[TT])
  841.         {
  842.             formatex(szFmt, charsmax(szFmt), "%s: CT: %i vs TT: %i", nTAG, g_iRound_team[CT], g_iRound_team[TT])
  843.         }
  844.         else
  845.         {
  846.             formatex(szFmt, charsmax(szFmt), "%s: TT: %i vs CT: %i", nTAG, g_iRound_team[TT], g_iRound_team[CT])
  847.         }
  848.         set_member_game(m_GameDesc, szFmt)
  849.     }
  850.     else
  851.     {
  852.         set_member_game(m_GameDesc, GameName)
  853.     }
  854. }
  855.  
  856. public pfn_show_money(tid)
  857. {
  858.     update_team_money(1)
  859.     update_team_money(2)
  860. }
  861.  
  862. update_team_money(team)
  863. {
  864.     new hud[256], name[32]
  865.     for(new i = 1 ; i <= iMaxPlayers ; i++)
  866.     {
  867.         if(!is_user_connected(i) || get_user_team(i) != team)
  868.         {
  869.             continue
  870.         }
  871.         get_user_name(i, name, 31)
  872.         format(hud, charsmax(hud), "%s%s - $%i^n", hud, name, get_member(i, m_iAccount))
  873.     }
  874.    
  875.     for(new i = 1 ; i <= iMaxPlayers ; i++)
  876.     {
  877.         if(!is_user_connected(i) || get_user_team(i) != team)
  878.         {
  879.             continue
  880.         }
  881.         set_hudmessage(0, 255, 0, 0.6, 0.0, 0, 1.0, 1.1, 0.1, 0.2, 1)
  882.         show_hudmessage(i, team == 1 ? "Terrorista:" : "Anti-Terrorista:")
  883.  
  884.         set_hudmessage(255, 255, 255, 0.6, 0.03, 0, 1.0, 1.1, 0.1, 0.2, 2)
  885.         show_hudmessage(i, hud)
  886.     }
  887. }
  888.  
  889. public EV_new_round()
  890. {
  891.     if(pug_state == NO_ALIVE)
  892.     {
  893.         return
  894.     }
  895.     else if(pug_state == COMMENCING)
  896.     {
  897.         set_cvar_num("mp_round_infinite", 0);
  898.         pug_state = ALIVE;
  899.     }
  900.  
  901.     if(is_intermission)
  902.     {
  903.         is_intermission = false
  904.         g_iRounds += 1
  905.     }
  906.     else if(!RoundRestart)
  907.     {
  908.         g_iRounds += 1
  909.     }
  910.     else
  911.     {
  912.         if(g_iRounds < 13){
  913.             g_iRounds = 1
  914.             g_iRound_team[TT] = 0
  915.             g_iRound_team[CT] = 0
  916.         }
  917.         RoundRestart = false
  918.     }
  919.    
  920.     round_start = true
  921.    
  922.     OffFreeze=false
  923.     if(OnSurrender)
  924.     {
  925.         for(new i=1; i<get_maxplayers(); i++)
  926.         {
  927.             if(!is_user_connected(i))
  928.             {
  929.                 continue
  930.             }
  931.             if(get_member(i, m_iTeam) == suteam)
  932.             {
  933.                 client_print_color(i, suteam==1?print_team_red:print_team_blue, "%s Jugador ^3%s^1 solicita rendirse.", TAG, name)
  934.             }
  935.         }
  936.         for(new i=1; i<get_maxplayers(); i++)
  937.         {
  938.             if(!is_user_connected(i))
  939.             {
  940.                 continue
  941.             }
  942.             menu_surrender = menu_create("\rPUG\w Elige una opcion", "pfn_surren_handler")
  943.             menu_additem(menu_surrender, "Si, Elijo rendirme")
  944.             menu_additem(menu_surrender, "No, Aun no me rendire")
  945.  
  946.             new item1[100], name[32]
  947.             get_user_name(i, name, 31)
  948.             formatex(item1, charsmax(item1), "^n\dHecha por:\y %s",name)
  949.  
  950.             menu_addtext(menu_surrender, item1)
  951.             menu_addtext(menu_surrender, "^n\rNOTA:\w Se necesitan 4 votos a^nfavor para rendirse.")
  952.  
  953.             menu_setprop(menu_surrender, MPROP_EXIT, MEXIT_NEVER)
  954.         }
  955.         arrayset(g_cvotes, 0, sizeof g_cvotes)
  956.         for(new i = 1 ; i <= get_maxplayers() ; i++)
  957.         {
  958.             if(!is_user_connected(i) || get_member(i, m_iTeam) != suteam)
  959.             {
  960.                 continue;
  961.             }
  962.             menu_display(i, menu_surrender)
  963.             client_cmd(i, "spk Gman/Gman_Choose2")
  964.             pfn_hud_vote_surrender()
  965.         }
  966.     }
  967.    
  968.     if(round_knife)
  969.     {
  970.         fn_update_server_name(0)
  971.         client_print_color(0, 0, "%s Ronda cuchillo, el equipo ganador elegira equipo.", TAG)
  972.         return
  973.     }
  974.  
  975.     if(team_check_id > 0)
  976.     {
  977.         new count = 0
  978.         for(new i = 1 ; i <= iMaxPlayers ; i++)
  979.         {
  980.             if(!is_user_connected(i) ||get_user_team(i) != team_check_id)
  981.             {
  982.                 continue
  983.             }
  984.             count++
  985.         }
  986.         if(count <= 2)
  987.         {
  988.             if(get_systime() >= team_check_time)
  989.             {
  990.                 client_print_color(0, print_team_grey, "^3Partida cancelada por falta de jugadores")
  991.                 client_print_color(0, print_team_grey, "^3En el equipo %s", team_check_id == 1 ? "Terrorista" : "Anti-Terrorista")
  992.                 team_check_id = 0
  993.                 start_pregame()
  994.                 return
  995.             }
  996.             else
  997.             {
  998.                 new p_time = ((team_check_time - get_systime()) / 60) + 1
  999.                 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")
  1000.                 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" : "")
  1001.             }
  1002.         }
  1003.         else
  1004.         {
  1005.             team_check_id = 0
  1006.         }
  1007.     }
  1008.     if(team_check_id == 0)
  1009.     {
  1010.         new t_count = 0
  1011.         new ct_count = 0
  1012.         for(new i = 1 ; i <= iMaxPlayers ; i++)
  1013.         {
  1014.             if(!is_user_connected(i))
  1015.             {
  1016.                 continue;
  1017.             }
  1018.             switch(get_user_team(i))
  1019.             {
  1020.                 case 1 : t_count++
  1021.                 case 2 : ct_count++
  1022.             }
  1023.         }
  1024.         if(t_count <= 2 || ct_count <= 2)
  1025.         {
  1026.             team_check_id = t_count <= 2 ? 1 : 2
  1027.             team_check_time = get_systime() + 180
  1028.             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")
  1029.             client_print_color(0, team_check_id == 1 ? print_team_red : print_team_blue, "^3La partida se cancelara en 3 minutos")
  1030.         }
  1031.     }
  1032.    
  1033.     set_task(1.0, "pfn_show_money", TASK_HUD_MONEY, "", 0, "a", get_cvar_num("mp_freezetime"))
  1034.    
  1035.     #if defined END_ROUND_KNIFE_FIX
  1036.     if(g_iRounds == 1)
  1037.     {
  1038.         set_cvar_num(Pregame_Cmds[1][COMMAND], 0)
  1039.         arrayset(g_iFrags, 0, MAXPLAYERS)
  1040.         arrayset(g_iDeaths, 0, MAXPLAYERS)
  1041.     }
  1042.     #endif
  1043.  
  1044.     if(g_iRounds == 15 || g_iRound_team[CT] == 15 || g_iRound_team[TT] == 15)
  1045.     {
  1046.         client_cmd(0, "spk ^"%s^"; spk ^"%s^"", SND_STINGER[6], SND_STINGER[6])
  1047.         set_dhudmessage(255, 255, 255, -1.0, 0.3, 0, 1.0, 1.5)
  1048.         if(g_iRounds == 30)
  1049.         {
  1050.             show_dhudmessage(0, "Ronda Final")
  1051.         }
  1052.         else
  1053.         {
  1054.             show_dhudmessage(0, "Punto de partido")
  1055.         }
  1056.     }
  1057.  
  1058.     fn_update_server_name(0)
  1059.     fn_score(0)
  1060.  
  1061.     for(new i = 1 ; i <= iMaxPlayers ; i++)
  1062.     {
  1063.         if(!is_user_connected(i)){
  1064.             continue
  1065.         }
  1066.         arrayset(g_iDmg[i], 0, MAXPLAYERS)
  1067.         arrayset(g_iHits[i], 0, MAXPLAYERS)
  1068.     }
  1069.     return
  1070. }
  1071.  
  1072. public plugin_end()
  1073. {
  1074.     TrieDestroy(t_Command)
  1075.     TrieDestroy(t_Command_Plugin)
  1076.     ArrayDestroy(g_maps)
  1077. }
  1078.  
  1079. read_maps()
  1080. {
  1081.     new file[32]
  1082.     new curmap[32]
  1083.     ArrayPushString(g_maps, "Jugar Este Mapa")
  1084.     get_mapname(curmap, charsmax(curmap))
  1085.     if(!file_exists("mapcycle.txt"))
  1086.     {
  1087.         log_amx("%s Mapcycle.txt no existe", TAG)
  1088.         return
  1089.     }
  1090.     new fh = fopen("mapcycle.txt", "r")
  1091.     if(!fh)
  1092.     {
  1093.         log_amx("%s error con Mapcycle.txt", TAG)
  1094.         return
  1095.     }
  1096.     while(!feof(fh))
  1097.     {
  1098.         fgets(fh, file, charsmax(file))
  1099.         trim(file)
  1100.         if(!file[0] || file[0] == ';' || equali(curmap, file))
  1101.         {
  1102.             continue;
  1103.         }
  1104.         ArrayPushString(g_maps, file)
  1105.     }
  1106.     fclose(fh)
  1107.  
  1108. }
  1109. stock bool:check_bsp_file(file[])
  1110. {
  1111.     if(equal(file[strlen(file)-4], ".bsp"))
  1112.     {
  1113.         return true
  1114.     }
  1115.  
  1116.     return false
  1117. }
  1118.  
  1119. public pfn_postink(id)
  1120. {
  1121.     if(!(1 <= get_user_team(id) <= 2))
  1122.     {
  1123.         return
  1124.     }
  1125.     set_pev(id, pev_maxspeed, 0.1)
  1126.     if(pug_state == ALIVE)
  1127.     {
  1128.         client_cmd(id, "+showscores")
  1129.     }
  1130.     if(is_user_alive(id))
  1131.     {
  1132.         new ent = get_member(id, m_pActiveItem)
  1133.         set_member(ent, m_Weapon_flNextPrimaryAttack, 2.0)
  1134.         set_member(ent, m_Weapon_flNextSecondaryAttack, 2.0)
  1135.     }
  1136. }
  1137.  
  1138. public pfn_remove_weapon(ent)
  1139. {
  1140.     if(pug_state == ALIVE && !round_knife)
  1141.     {
  1142.         DisableHamForward(SpawnWeapon)
  1143.         return
  1144.     }
  1145.     set_pev(ent, pev_flags, FL_KILLME)
  1146. }
  1147.  
  1148. reset_user_vars()
  1149. {
  1150.     arrayset(ready, false, sizeof(ready))
  1151.     arrayset(tryid, false, (sizeof tryid)-1)
  1152.     arrayset(c, false, (sizeof c)-1)
  1153.     ready_count = 0
  1154.     g_vote_id = 0;
  1155.     round_knife = false
  1156.     half_time = false
  1157.     RoundRestart = false
  1158.     g_iRound_team[TT] = 0
  1159.     g_iRound_team[CT] = 0
  1160.     arrayset(g_iFrags, 0, MAXPLAYERS)
  1161.     arrayset(g_iDeaths, 0, MAXPLAYERS)
  1162. }
  1163.  
  1164. stock pug_register_command(Command[], Function[], Plugin)
  1165. {
  1166.     new funcid = get_func_id(Function, Plugin)
  1167.     if(!funcid)
  1168.     {
  1169.         server_print("Funcion: ^"%s^" No encontrada", Function)
  1170.         return
  1171.     }
  1172.     else if(TrieKeyExists(t_Command, Command))
  1173.     {
  1174.         server_print("Funcion ^"%s^" ya existente", Command)
  1175.         return
  1176.     }
  1177.  
  1178.     TrieSetCell(t_Command, Command, Plugin)
  1179.     TrieSetCell(t_Command_Plugin, Command, funcid)
  1180. }
  1181.  
  1182. public start_pregame()
  1183. {
  1184.     for(new i = 0 ; i < sizeof(Pregame_Cmds) ; i++)
  1185.     {
  1186.         set_cvar_string(Pregame_Cmds[i][COMMAND], Pregame_Cmds[i][VALUE])
  1187.     }
  1188.     torneo_limit = false
  1189.     is_intermission = false
  1190.     pug_state = NO_ALIVE
  1191.     gMsgRegisterStatusIcon = register_message(gMsgStatusIcon, "pfn_StatusIcon")
  1192.     set_cvar_num("sv_restart", 1)
  1193.     EnableHamForward(SpawnWeapon)
  1194.     EnableHamForward(DefuseKit)
  1195.     reset_user_vars()
  1196.     fn_update_server_name(0)
  1197.     if(get_pcvar_num(g_pcvar_votemap) == 1)
  1198.     {
  1199.         set_task(1.0, "pfn_Hud_Ready", TASK_HUD_READY, _, _, "b")
  1200.     }
  1201.     else
  1202.     {
  1203.         g_vote_countdown = 60
  1204.         set_task(1.0, "pfn_waiting_players", TASK_HUD_READY, _, _, "b")
  1205.     }
  1206.  
  1207.     if(private)
  1208.     {
  1209.         set_cvar_string(Pregame_Cmds[3][COMMAND], "0")
  1210.     }
  1211. }
  1212.  
  1213. public pfn_StatusIcon(m, e, id)
  1214. {
  1215.     if(pug_state == ALIVE && !round_knife)
  1216.     {
  1217.         unregister_message(gMsgStatusIcon, gMsgRegisterStatusIcon)
  1218.         return PLUGIN_CONTINUE
  1219.     }
  1220.     new arg[4]
  1221.     get_msg_arg_string(2, arg, charsmax(arg))
  1222.     if(equal(arg, "c4"))
  1223.     {
  1224.         client_cmd(id, "drop weapon_c4")
  1225.     }
  1226.     return PLUGIN_CONTINUE
  1227. }
  1228.  
  1229. public pfn_Hud_Ready()
  1230. {
  1231.     set_hudmessage(0, 255, 0, 0.75, 0.07, 0, 1.0, 1.1)
  1232.     new i;
  1233.     new __pcount = 0
  1234.     for(i = 1 ; i <= iMaxPlayers ;i++ )
  1235.     {
  1236.         if(!is_user_connected(i) || !(1 <= get_user_team(i) <= 2))
  1237.         {
  1238.             continue;
  1239.         }
  1240.         __pcount += 1
  1241.     }
  1242.     ShowSyncHudMsg(0, Sync1, "Jugadores: ( %i / %i ) ", __pcount , get_pcvar_num(pcvar_max_players))
  1243.     new fmt[33 * 33], name[16]
  1244.  
  1245.     copy(fmt, charsmax(fmt), "")
  1246.     for(i = 1 ; i <= iMaxPlayers ;i++ )
  1247.     {
  1248.         if(!is_user_connected(i) || !(1 <= get_user_team(i) <= 2))
  1249.         {
  1250.             continue;
  1251.         }
  1252.         if(ready[i]){
  1253.             get_user_name(i, name, charsmax(name))
  1254.             format(fmt, charsmax(fmt), "%s%s^n", fmt, name)
  1255.         }
  1256.         else{
  1257.             get_user_name(i, name, charsmax(name))
  1258.             format(fmt, charsmax(fmt), "%s%s^n", fmt, name)
  1259.         }
  1260.     }
  1261.     set_hudmessage(255, 255, 255, 0.70, 0.1, 0, 1.0, 1.1)
  1262.     ShowSyncHudMsg(0, Sync2, fmt)
  1263.  
  1264.     copy(fmt, charsmax(fmt), "")
  1265.     for(i = 1 ; i <= iMaxPlayers ;i++ )
  1266.     {
  1267.         if(!is_user_connected(i) || !(1 <= get_user_team(i) <= 2))
  1268.         {
  1269.             continue;
  1270.         }
  1271.         if(ready[i]){
  1272.             format(fmt, charsmax(fmt), "%s - Listo^n", fmt)
  1273.         }
  1274.         else{
  1275.             format(fmt, charsmax(fmt), "%s - No Listo^n", fmt)
  1276.         }
  1277.     }
  1278.     set_hudmessage(242, 195, 43, 0.84, 0.1, 0, 1.0, 1.1)
  1279.     ShowSyncHudMsg(0, Sync3, fmt)
  1280. }
  1281.  
  1282. public plugin_natives()
  1283. {
  1284.     register_native("pug_register_command", "native_register_command", .style=0)
  1285.     register_native("pug_get_state", "native_pug_get_state")
  1286.     register_native("pug_is_ready", "native_is_ready")
  1287. }
  1288.  
  1289. public native_is_ready(pl, pr)
  1290. {
  1291.     new u = get_param(1)
  1292.     if(!(1 <= u <= iMaxPlayers))
  1293.     {
  1294.         return false
  1295.     }
  1296.     return ready[u]
  1297. }
  1298.  
  1299. public native_pug_get_state(pl, pr)
  1300. {
  1301.     return pug_state;
  1302. }
  1303.  
  1304. public native_register_command(pl, pr)
  1305. {
  1306.     new szCommand[20], szForward[32]
  1307.     get_string(1, szCommand, charsmax(szCommand))
  1308.     get_string(2, szForward, charsmax(szForward))
  1309.     pug_register_command(szCommand, szForward, pl)
  1310. }
  1311.  
  1312. public pfn_Hook_Say(id)
  1313. {
  1314.     if(!is_user_connected(id))
  1315.     {
  1316.         return PLUGIN_CONTINUE
  1317.     }
  1318.     static said[210], name[32], type[10], team, bool:say_team, message[300]
  1319.     read_argv(0, type, charsmax(type))
  1320.     get_user_name(id, name, charsmax(name))
  1321.     read_argv(1, said, charsmax(said))
  1322.     remove_quotes(said)
  1323.     trim(said)
  1324.     trim(type)
  1325.     if(!said[0])
  1326.     {
  1327.         return PLUGIN_HANDLED_MAIN
  1328.     }
  1329.     team = get_user_team(id)
  1330.     strtolower(type)
  1331.     if(equali(type, "say_team") || team == 3 || team == 0)
  1332.     {
  1333.         say_team = true
  1334.         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)
  1335.     }
  1336.     else
  1337.     {
  1338.         say_team = false
  1339.         formatex(message, charsmax(message), "^1%s^3%s ^1: %s", is_user_alive(id) ? "" : "*DEAD* ", name, said)
  1340.     }
  1341.  
  1342.     for(new i = 1 ; i <= iMaxPlayers ; i++)
  1343.     {
  1344.         if(!is_user_connected(i))
  1345.         {
  1346.             continue
  1347.         }
  1348.         if(say_team)
  1349.         {
  1350.             if(get_user_team(i) == team)
  1351.             {
  1352.                 client_print_color(i, id, message)
  1353.             }
  1354.             else if(team == 3 && get_user_team(i) == team)
  1355.             {
  1356.                 client_print_color(i, id, message)
  1357.             }
  1358.         }
  1359.         else
  1360.         {
  1361.             client_print_color(i, id, message)
  1362.         }
  1363.     }
  1364.     if(check_command(id, said))
  1365.     {
  1366.         return PLUGIN_HANDLED
  1367.     }
  1368.     return PLUGIN_HANDLED_MAIN
  1369. }
  1370.  
  1371. check_command(id, text[])
  1372. {
  1373.     strtolower(text)
  1374.     if(TrieKeyExists(t_Command, text))
  1375.     {
  1376.         new iPlugin, iFunc
  1377.         TrieGetCell(t_Command, text, iPlugin)
  1378.         TrieGetCell(t_Command_Plugin, text, iFunc)
  1379.         callfunc_begin_i(iFunc, iPlugin)
  1380.         callfunc_push_int(id)
  1381.         callfunc_end()
  1382.         return 1
  1383.     }
  1384.     return 0
  1385. }
  1386.  
  1387. public pfn_ready(id)
  1388. {
  1389.     if(pug_state != NO_ALIVE || !(1 <= get_user_team(id) <= 2))
  1390.     {
  1391.         client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
  1392.         return PLUGIN_HANDLED
  1393.     }
  1394.     else if(ready[id])
  1395.     {
  1396.         client_print_color(id, 0, "%s Ya estas listo", TAG)
  1397.         return PLUGIN_HANDLED
  1398.     }
  1399.     new name[32]
  1400.     get_user_name(id, name, charsmax(name))
  1401.     client_print_color(0, 0, "%s %s Esta Listo", TAG, name)
  1402.     ready[id] = true
  1403.     ready_count ++
  1404.     if(ready_count == get_pcvar_num(pcvar_max_players))
  1405.     {
  1406.         start_vote()
  1407.     }
  1408.     return  PLUGIN_HANDLED
  1409. }
  1410.  
  1411. public pfn_unready(id)
  1412. {
  1413.     if(pug_state != NO_ALIVE)
  1414.     {
  1415.         client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
  1416.         return
  1417.     }
  1418.     else if(!ready[id])
  1419.     {
  1420.         client_print_color(id, 0, "%s Aun no estas listo", TAG)
  1421.         return
  1422.     }
  1423.     new name[32]
  1424.     get_user_name(id, name, charsmax(name))
  1425.     client_print_color(0, 0, "%s %s Dejo de estar Listo", TAG, name)
  1426.     ready[id] = false;
  1427.     ready_count --
  1428. }
  1429.  
  1430. public pfn_TextMsg(m, e, id)
  1431. {
  1432.     static msg[23]
  1433.     get_msg_arg_string(2, msg, charsmax(msg))
  1434.     if(equal(msg, "#Game_will_restart_in"))
  1435.     {
  1436.         if(pug_state == ALIVE)
  1437.         {
  1438.             if(round_knife)
  1439.             {
  1440.                 round_knife = false
  1441.             }
  1442.             RoundRestart = true
  1443.  
  1444.         }
  1445.         return PLUGIN_HANDLED
  1446.     }
  1447.     return PLUGIN_CONTINUE
  1448. }
  1449.  
  1450.  
  1451. public pfn_Hook_ChooseTeam(id, _:slot)
  1452. {
  1453.     if(is_intermission || round_knife || round_knife_start_vote)
  1454.     {
  1455.         center_print(id, "%s No puedes elegir equipo en este momento^n^n^n^n^n", TAG)
  1456.         SetHookChainReturn(ATYPE_INTEGER, 0)
  1457.         return HC_BREAK
  1458.     }
  1459.     if(captainrun)
  1460.     {
  1461.         if(slot != 6)
  1462.         {
  1463.             SetHookChainReturn(ATYPE_INTEGER, 0)
  1464.             return HC_BREAK
  1465.         }
  1466.         return HC_CONTINUE
  1467.     }
  1468.     new players[32], count_t, count_ct
  1469.     get_players(players, count_t, "e", "TERRORIST")
  1470.     get_players(players, count_ct, "e", "CT")
  1471.  
  1472.     if(!(1 <= slot <= 2))
  1473.     {
  1474.         if(slot == 5)
  1475.         {
  1476.             if(count_t >= (get_pcvar_num(pcvar_max_players) / 2) && count_ct >= (get_pcvar_num(pcvar_max_players) / 2) )
  1477.             {
  1478.                 client_print_color(id, id, "%s Todos los equipos se encuentran llenos", TAG)
  1479.                 SetHookChainReturn(ATYPE_INTEGER, 0)
  1480.                 return HC_BREAK
  1481.             }
  1482.         }
  1483.         else{
  1484.             client_print_color(id, id, "%s Modo Espectador no permitido", TAG)
  1485.             SetHookChainReturn(ATYPE_INTEGER, 0)
  1486.             return HC_BREAK
  1487.         }
  1488.         return HC_CONTINUE
  1489.     }
  1490.    
  1491.     else if((1 <= slot <= 2) && (1 <= get_user_team(id) <= 2) && pug_state == ALIVE)
  1492.     {
  1493.         client_print_color(id, id, "%s No puedes hacer un cambio de equipos estando una partida en curso", TAG)
  1494.         SetHookChainReturn(ATYPE_INTEGER, 0)
  1495.         return HC_BREAK
  1496.     }
  1497.    
  1498.     new count
  1499.     get_players(players, count, "e", slot == 1 ? "TERRORIST" : "CT")
  1500.  
  1501.     if(count >= (get_pcvar_num(pcvar_max_players) / 2) )
  1502.     {
  1503.         center_print(id, "%s Este Equipo esta lleno^n^n^n^n^n", TAG)
  1504.         SetHookChainReturn(ATYPE_INTEGER, 0)
  1505.         return HC_BREAK
  1506.     }
  1507.     return HC_CONTINUE
  1508. }
  1509.  
  1510. stock center_print(id, const msg[], any:...)
  1511. {
  1512.     new arg[70]
  1513.     vformat(arg, charsmax(arg), msg, 3)
  1514.     if(id == 0)
  1515.     {
  1516.         for(new z = 1 ; z <= iMaxPlayers ; z++)
  1517.         {
  1518.             if(!is_user_connected(z))
  1519.             {
  1520.                 continue
  1521.             }
  1522.             engfunc(EngFunc_ClientPrintf, z, 1, arg)
  1523.         }
  1524.     }
  1525.     else
  1526.     {
  1527.         engfunc(EngFunc_ClientPrintf, id, 1, arg)
  1528.     }
  1529. }
  1530.  
  1531. public client_putinserver(id)
  1532. {
  1533.     if(ready[id])
  1534.     {
  1535.         ready[id] = false
  1536.         ready_count--
  1537.     }
  1538.     g_iFrags[id] = 0
  1539.     g_iDeaths[id] = 0
  1540.     fn_update_server_name(id)
  1541.     if(private && pug_state != ALIVE)
  1542.     {
  1543.         set_task(1.0, "pfn_set_team", id + 666)
  1544.     }
  1545. }
  1546.  
  1547. public pfn_set_team(id)
  1548. {
  1549.     id -= 666
  1550.     if(!is_user_connected(id))
  1551.     return
  1552.     static _c_team, _sz__steam_id_put[32]
  1553.     get_user_authid(id, _sz__steam_id_put, charsmax(_sz__steam_id_put))
  1554.     if(TrieKeyExists(g_private, _sz__steam_id_put))
  1555.     {
  1556.         TrieGetCell(g_private, _sz__steam_id_put, _c_team)
  1557.         if(!(1<= _c_team <= 3))
  1558.         {
  1559.             return
  1560.         }
  1561.         if(_c_team == 3)
  1562.         {
  1563.             rg_join_team(id, TEAM_SPECTATOR)
  1564.             return
  1565.         }
  1566.         if(get_user_team(id) == _c_team)
  1567.         {
  1568.             return
  1569.         }
  1570.         rg_set_user_team(id, _c_team == 1 ? TEAM_TERRORIST : TEAM_CT)
  1571.         ExecuteHam(Ham_CS_RoundRespawn, id)
  1572.     }
  1573. }
  1574.  
  1575. public client_disconnected(id)
  1576. {
  1577.     if(is_intermission)
  1578.     {
  1579.         return
  1580.     }
  1581.     if(ready[id])
  1582.     {
  1583.         ready[id] = false
  1584.         ready_count--
  1585.     }
  1586.     new team = get_user_team(id)
  1587.  
  1588.     if(pug_state == ALIVE && (1 <= team <= 2))
  1589.     {
  1590.         new count = 0
  1591.  
  1592.         for(new i = 1 ; i <= iMaxPlayers ;i++)
  1593.         {
  1594.             if(!is_user_connected(i) || i == id || get_user_team(i) != team)
  1595.             {
  1596.                 continue
  1597.             }
  1598.             count++
  1599.         }
  1600.         if(count <= 2)
  1601.         {
  1602.             if(count == 0)
  1603.             {
  1604.                 client_print_color(0, print_team_red, "%s Partida cancelada por ausencia de jugadores en el equipo %s", TAG, team == 1 ? "Terrorista" : "Anti-Terrorista")
  1605.                 start_pregame()
  1606.                 return
  1607.             }
  1608.  
  1609.             if(team_check_id)
  1610.             {
  1611.                 return
  1612.             }
  1613.             team_check_id = team
  1614.             team_check_time = get_systime() + 180
  1615.             client_print_color(0, print_team_grey, "Esperando minimo de judadores del equipo %s", team == 1 ? "Terrorista" : "Anti-Terrorista")
  1616.             client_print_color(0, print_team_grey, "La partida se cancelara en 3 minutos")
  1617.         }
  1618.     }
  1619. }
  1620. public aleatorio()
  1621. {
  1622.     new id= random_num(1,MAXPLAYERS)
  1623.     while(!is_user_connected(id)) id= random_num(1,iMaxPlayers)
  1624.  
  1625.     user_silentkill(id)
  1626. }
  1627. fn_score(id=0)
  1628. {
  1629.     if(pug_state == NO_ALIVE)
  1630.     {
  1631.         client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
  1632.         return
  1633.     }
  1634.     if(g_iRound_team[CT] == g_iRound_team[TT])
  1635.     {
  1636.         client_print_color(0, 0, "%s La puntuacion esta empatada %i - %i", TAG, g_iRound_team[CT], g_iRound_team[TT])
  1637.     }
  1638.     else
  1639.     {
  1640.         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] )
  1641.     }
  1642. }
  1643.  
  1644. public pfn_score(id)
  1645. {
  1646.     fn_score(id)
  1647. }
  1648.  
  1649. public start_vote()
  1650. {
  1651.     remove_task(TASK_HUD_READY)
  1652.     g_vote_id = 0
  1653.     next_vote()
  1654. }
  1655.  
  1656. make_hud_title(msg[], any:...)
  1657. {
  1658.     new fmt[50]
  1659.     vformat(fmt, charsmax(fmt), msg, 2)
  1660.     set_hudmessage(0, 255, 0, -1.0, 0.0, 0, 1.0, 1.1)
  1661.     ShowSyncHudMsg(0, Sync1, fmt)
  1662. }
  1663.  
  1664. make_hud_body(msg[], any:...)
  1665. {
  1666.     new fmt[512]
  1667.     vformat(fmt, charsmax(fmt), msg, 2)
  1668.     set_hudmessage(255, 255, 255, -1.0, 0.03, 0, 1.0, 1.1)
  1669.     ShowSyncHudMsg(0, Sync2, fmt)
  1670. }
  1671.  
  1672. public next_vote()
  1673. {
  1674.     remove_task(TASK_HUD_VOTE)
  1675.     remove_task(TASK_END_VOTE)
  1676.     g_vote_id++
  1677.     switch(g_vote_id)
  1678.     {
  1679.         case 1 :
  1680.         {
  1681.             if(get_pcvar_num(g_pcvar_votemap) == 1)
  1682.             {
  1683.                 set_task(1.0, "pfn_hud_votemap", TASK_HUD_VOTE, _, _, "b")
  1684.                 set_task(11.0, "pfn_vote_map_end", TASK_END_VOTE)
  1685.                 g_vote_countdown = 10
  1686.                 start_vote_map()
  1687.             }
  1688.             else
  1689.             {
  1690.                 set_pcvar_num(g_pcvar_votemap, 1)
  1691.                 next_vote();
  1692.             }
  1693.         }
  1694.         case 2 :
  1695.         {
  1696.             set_task(1.0, "pfn_hud_vote_knife", TASK_HUD_VOTE, _, _, "b")
  1697.             set_task(11.0, "pfn_vote_knife_end", TASK_END_VOTE)
  1698.             g_vote_countdown = 10
  1699.             start_vote_knife()
  1700.         }
  1701.         default :
  1702.         {
  1703.             start_countdown()
  1704.         }
  1705.     }
  1706. }
  1707.  
  1708. public start_vote_map()
  1709. {
  1710.     vote_map = true
  1711.     g_vote_count = 0
  1712.     make_menu_votemap()
  1713. }
  1714.  
  1715. make_menu_votemap()
  1716. {
  1717.     g_VoteMenu = menu_create("\rVotacion de Mapa", "mh_vote_map")
  1718.     new map[32]
  1719.     new i
  1720.     for(i = 0 ; i < ArraySize(g_maps) ;i++)
  1721.     {
  1722.         ArrayGetString(g_maps, i, map, charsmax(map))
  1723.         menu_additem(g_VoteMenu, map)
  1724.         arrayset(g_votes, 0, sizeof(g_votes))
  1725.     }
  1726.     menu_setprop(g_VoteMenu, MPROP_EXIT, MEXIT_ALL)
  1727.  
  1728.     for(i = 1 ; i <= iMaxPlayers ;i++ )
  1729.     {
  1730.         if(!is_user_connected(i) || !( 1 <= get_user_team(i) <= 2))
  1731.         {
  1732.             continue
  1733.         }
  1734.         menu_display(i, g_VoteMenu, .page=0)
  1735.     }
  1736. }
  1737.  
  1738. public mh_vote_map(id, menu, item)
  1739. {
  1740.     if(!vote_map)
  1741.     {
  1742.         return
  1743.     }
  1744.     if(item == MENU_EXIT)
  1745.     {
  1746.         g_votes[0]++
  1747.         fn_update_vote_map_hud()
  1748.         check_votes(vote_map);
  1749.         return
  1750.     }
  1751.     g_votes[item]++
  1752.     g_vote_count++
  1753.     fn_update_vote_map_hud()
  1754.     check_votes(vote_map);
  1755. }
  1756.  
  1757. public check_votes(bool:active)
  1758. {
  1759.     if(!active)
  1760.     {
  1761.         return
  1762.     }
  1763.     if(g_vote_count == get_playersnum())
  1764.     {
  1765.         remove_task(TASK_HUD_VOTE)
  1766.         remove_task(TASK_END_VOTE)
  1767.         pfn_vote_map_end();
  1768.     }
  1769. }
  1770.  
  1771. public pfn_vote_map_end()
  1772. {
  1773.     vote_map = false
  1774.     client_cmd(0, "slot10")
  1775.     menu_destroy(g_VoteMenu)
  1776.  
  1777.     new winner, temp
  1778.     for(new i = 0 ; i < sizeof (g_votes) ; i++)
  1779.     {
  1780.         if(temp < g_votes[i])
  1781.         {
  1782.             temp = g_votes[i]
  1783.             winner = i
  1784.         }
  1785.     }
  1786.  
  1787.     if(!winner)
  1788.     {
  1789.         client_print_color(0, 0, "%s Se decidio %a", TAG, ArrayGetStringHandle(g_maps, 0))
  1790.         next_vote();
  1791.     }
  1792.     else
  1793.     {
  1794.         set_pcvar_num(g_pcvar_votemap, 0)
  1795.         server_cmd("changelevel ^"%a^"", ArrayGetStringHandle(g_maps, winner))
  1796.     }
  1797. }
  1798.  
  1799. public pfn_hud_votemap()
  1800. {
  1801.     if(g_vote_countdown-- <= 0)
  1802.     {
  1803.         g_vote_countdown = 0
  1804.     }
  1805.     fn_update_vote_map_hud()
  1806. }
  1807.  
  1808. fn_update_vote_map_hud()
  1809. {
  1810.     make_hud_title("Votacion de Mapa: (%i)", g_vote_countdown)
  1811.     new count
  1812.     new hud[512]
  1813.     new temp
  1814.     for(new i = 0 ; i < ArraySize(g_maps) ; i++)
  1815.     {
  1816.  
  1817.         temp = g_votes[i]
  1818.         if(temp >= 1)
  1819.         {
  1820.             count++
  1821.             format(hud, charsmax(hud), "%s%a: %i %s^n", hud, ArrayGetStringHandle(g_maps, i), temp, temp > 1 ? "votos" : "voto")
  1822.         }  
  1823.     }
  1824.  
  1825.     if(!count)
  1826.     {
  1827.         formatex(hud, charsmax(hud), "No hay votos")
  1828.     }
  1829.     make_hud_body(hud)
  1830. }
  1831.  
  1832. start_vote_knife()
  1833. {
  1834.     g_vote_count = 0
  1835.     vote_knife = true
  1836.     set_task(0.1, "make_vote_knife")
  1837. }
  1838.  
  1839. public make_vote_knife()
  1840. {
  1841.     arrayset(g_votes, 0, sizeof(g_votes))
  1842.     g_VoteMenu = menu_create("\ySorteo de Equipos", "mh_mode_vote")
  1843.     menu_additem(g_VoteMenu, "Sin Cambios")
  1844.     menu_additem(g_VoteMenu, "Torneo")
  1845.     menu_additem(g_VoteMenu, "Aleatorio")
  1846.     menu_additem(g_VoteMenu, "Capitanes")
  1847.  
  1848.     menu_setprop(g_VoteMenu, MPROP_EXIT, MEXIT_ALL)
  1849.     for(new i = 1 ; i <= MAXPLAYERS ; i++)
  1850.     {
  1851.         if(!is_user_connected(i) || is_user_hltv(i))
  1852.         {
  1853.             continue
  1854.         }
  1855.         if( 1 <= get_user_team(i) <= 2)
  1856.         {
  1857.             menu_display(i, g_VoteMenu)
  1858.         }
  1859.     }
  1860. }
  1861.  
  1862. public mh_mode_vote(id, menu, item)
  1863. {
  1864.     if(item == MENU_EXIT || !vote_knife)
  1865.     {
  1866.         return
  1867.     }
  1868.     if(item > 3)
  1869.     {
  1870.         return
  1871.     }
  1872.     g_votes[item]++
  1873.     g_vote_count++
  1874.     update_knife_hud()
  1875.     if(g_vote_count >= get_playersnum())
  1876.     {
  1877.         remove_task(TASK_HUD_VOTE)
  1878.         remove_task(TASK_END_VOTE)
  1879.         pfn_vote_knife_end(TASK_END_VOTE)
  1880.     }
  1881. }
  1882.  
  1883. public pfn_vote_knife_end(task)
  1884. {
  1885.     remove_task(task)
  1886.     new winner = 0
  1887.     for(new i = 0 ; i < 4 ; i++)
  1888.     {
  1889.         if(g_votes[i] > g_votes[winner])
  1890.         {
  1891.             winner = i
  1892.         }
  1893.     }
  1894.  
  1895.     switch(winner)
  1896.     {
  1897.         case 0:
  1898.         {
  1899.             EnableHamForward(PlayerSpawn)
  1900.             next_vote()
  1901.         }
  1902.         case 1:
  1903.         {
  1904.             set_cvar_num("mp_friendlyfire", 1)
  1905.             torneo_limit = true    
  1906.             round_knife = true
  1907.             EnableHamForward(PlayerSpawn)
  1908.             next_vote()
  1909.         }
  1910.         case 2:
  1911.         {
  1912.             fnTeamsRandomize()
  1913.         }
  1914.         case 3:
  1915.         {
  1916.             fnCaptains()
  1917.         }
  1918.     }
  1919.     vote_knife = false
  1920. }
  1921.  
  1922. public pfn_hud_vote_knife(task)
  1923. {
  1924.     if(g_vote_countdown-- > 0)
  1925.     {
  1926.         update_knife_hud()
  1927.     }
  1928.     else
  1929.     {
  1930.         remove_task(task)
  1931.     }
  1932. }
  1933.  
  1934. update_knife_hud()
  1935. {
  1936.     make_hud_title("Votacion de Equipos (%i)", g_vote_countdown)
  1937.     new _hud[100],c
  1938.     for(new i = 0 ; i< sizeof g_votes ; i++)
  1939.     {
  1940.         if(g_votes[i] <= 0)
  1941.         {
  1942.             continue
  1943.         }
  1944.         switch(i)
  1945.         {
  1946.             case 0 :
  1947.             {
  1948.                 format(_hud, charsmax(_hud), "%sSin Cambios: %i voto%s^n", _hud, g_votes[i], g_votes[i] > 1 ? "s" : "")
  1949.                 c++
  1950.             }
  1951.             case 1 :
  1952.             {
  1953.                 format(_hud, charsmax(_hud), "%sModo Torneo: %i voto%s^n", _hud, g_votes[i], g_votes[i] > 1 ? "s" : "")
  1954.                 c++
  1955.             }
  1956.             case 2 :
  1957.             {
  1958.                 format(_hud, charsmax(_hud), "%sAleatorio: %i voto%s^n", _hud, g_votes[i], g_votes[i] > 1 ? "s" : "")
  1959.                 c++
  1960.             }
  1961.             case 3 :
  1962.             {
  1963.                 format(_hud, charsmax(_hud), "%sCapitan: %i voto%s^n", _hud, g_votes[i], g_votes[i] > 1 ? "s" : "")
  1964.                 c++
  1965.             }
  1966.         }
  1967.     }
  1968.     if(c>0)
  1969.     {
  1970.         make_hud_body(_hud)
  1971.     }
  1972.     else
  1973.     {
  1974.         make_hud_body("No hay votos")
  1975.     }
  1976. }
  1977.  
  1978. fnTeamsRandomize()
  1979. {
  1980.     new iPlayers[MAX_PLAYERS],iNum;
  1981.     get_players(iPlayers,iNum);
  1982.  
  1983.     for(new i;i < iNum;i++)
  1984.     {
  1985.         if(!(1 <= get_user_team(iPlayers[i]) <= 2))
  1986.         {
  1987.             iPlayers[i--] = iPlayers[--iNum];
  1988.         }
  1989.     }
  1990.  
  1991.     new iTeam = random(2) ? 1 : 2;
  1992.  
  1993.     new iPlayer,iRandom;
  1994.  
  1995.     while(iNum)
  1996.     {
  1997.         iRandom = random(iNum);
  1998.  
  1999.         iPlayer = iPlayers[iRandom];
  2000.  
  2001.         rg_set_user_team(iPlayer, iTeam == 1 ? TEAM_TERRORIST : TEAM_CT)
  2002.  
  2003.         iPlayers[iRandom] = iPlayers[--iNum];
  2004.  
  2005.         iTeam = ((_:iTeam) % 2 + 1);
  2006.     }
  2007.     EnableHamForward(PlayerSpawn)
  2008.     next_vote()
  2009. }
  2010.  
  2011. public fnCaptains()
  2012. {
  2013.     new p[32], count
  2014.     get_players(p, count, "h")
  2015.     if(count >= get_pcvar_num(pcvar_max_players))
  2016.     {
  2017.         set_task(1.0, "fnCaptainHud")
  2018.  
  2019.         client_print_color(0, 0, "%s Se iniciara elecion por capitanes.", TAG)
  2020.  
  2021.         set_cvar_num("sv_restart", 1)
  2022.         set_cvar_num("sv_maxspeed", 0)
  2023.         set_cvar_num("mp_forcerespawn", 0)
  2024.         set_cvar_num("mp_round_infinite", 1)
  2025.         captainrun = true
  2026.  
  2027.         capitan_tt = random_player(1)
  2028.         capitan_ct = random_player(2)
  2029.  
  2030.         make_menu_team(capitan_tt)
  2031.     }
  2032.     else
  2033.     {
  2034.         client_print_color(0, 0, "%s Son necesarios ^4%d^1 jugadores para elecion de capitanes.", TAG, get_pcvar_num(pcvar_max_players))
  2035.         set_cvar_num("sv_maxspeed", 320)
  2036.         set_cvar_num("mp_round_infinite", 0)
  2037.         EnableHamForward(PlayerSpawn)
  2038.         next_vote()
  2039.     }
  2040. }
  2041.  
  2042. make_menu_team(id)
  2043. {
  2044.     new menu = menu_create("\rSelecciona a un jugador", "mh_menu")
  2045.     new name[32], num[3]
  2046.  
  2047.     new count, selec_count
  2048.  
  2049.     for(new i = 1 ; i <= MAXPLAYERS ; i++)
  2050.     {
  2051.         if(!is_user_connected(i) || is_user_hltv(i) || get_member(i, m_iTeam) != TEAM_SPECTATOR){
  2052.             continue
  2053.         }
  2054.         get_user_name(i, name, charsmax(name))
  2055.         num_to_str(i, num, charsmax(num))
  2056.         menu_additem(menu, name, num)
  2057.         count++
  2058.     }
  2059.     for(new i = 1 ; i <= MAXPLAYERS ; i++)
  2060.     {
  2061.         if(!is_user_connected(i) || is_user_hltv(i) || 1 <= get_member(i, m_iTeam) <=2){
  2062.             continue
  2063.         }
  2064.         selec_count++
  2065.     }
  2066.     if(count == 0 || selec_count == get_pcvar_num(pcvar_max_players))
  2067.     {
  2068.         menu_destroy(menu)
  2069.         set_cvar_num("sv_maxspeed", 320)
  2070.         set_cvar_num("mp_round_infinite", 0)
  2071.         captainrun = false
  2072.         EnableHamForward(PlayerSpawn)
  2073.         next_vote()
  2074.  
  2075.         team_voting = 0
  2076.         return PLUGIN_HANDLED
  2077.     }
  2078.     remove_task(TASK)
  2079.     team_voting = get_user_team(id)
  2080.     menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER);
  2081.     menu_display(id, menu)
  2082.     set_task(5.0, "pfn_end", TASK)
  2083.  
  2084.     return PLUGIN_HANDLED
  2085. }
  2086.  
  2087. public mh_menu(id, menu, item)
  2088. {
  2089.     if(item == MENU_EXIT)
  2090.     {
  2091.         return
  2092.     }
  2093.     if(team_voting != get_user_team(id))
  2094.     {
  2095.         menu_destroy(menu)
  2096.         return
  2097.     }
  2098.  
  2099.     new num[3], a
  2100.     menu_item_getinfo(menu, item, a, num, charsmax(num), "", 0, a)
  2101.     menu_destroy(menu)
  2102.     new p = str_to_num(num)
  2103.     rg_set_user_team(p, team_voting == 1 ? TEAM_TERRORIST : TEAM_CT)
  2104.     rg_round_respawn(p)
  2105.     remove_task(TASK)
  2106.  
  2107.     switch(team_voting)
  2108.     {
  2109.         case 1 :
  2110.         {
  2111.             menu_cancel(capitan_tt)
  2112.             make_menu_team(capitan_ct)
  2113.  
  2114.         }
  2115.         case 2 :
  2116.         {
  2117.  
  2118.             menu_cancel(capitan_ct)
  2119.             make_menu_team(capitan_tt)
  2120.         }
  2121.     }
  2122. }
  2123.  
  2124. public pfn_end()
  2125. {
  2126.     new p[32], count
  2127.     get_players(p, count, "he", "SPECTATOR")
  2128.     if( count > 0 )
  2129.     {
  2130.         new r = p[random(count)]
  2131.         rg_set_user_team(r, team_voting == 1 ? TEAM_TERRORIST : TEAM_CT)
  2132.         rg_round_respawn(r)
  2133.  
  2134.     }
  2135.  
  2136.     switch(team_voting)
  2137.     {
  2138.         case 1 :
  2139.         {
  2140.             menu_cancel(capitan_tt)
  2141.             make_menu_team(capitan_ct)
  2142.  
  2143.         }
  2144.         case 2 :
  2145.         {
  2146.  
  2147.             menu_cancel(capitan_ct)
  2148.             make_menu_team(capitan_tt)
  2149.         }
  2150.     }
  2151. }
  2152. public check_capitan()
  2153. {
  2154.     new p[32], num
  2155.     get_players(p, num, "he", "SPECTATOR")
  2156.     if(!is_user_connected(capitan_ct))
  2157.     {
  2158.         capitan_ct = p[random(num)]
  2159.         rg_set_user_team(capitan_ct, TEAM_CT)
  2160.         set_member(capitan_ct, m_iJoiningState, 5)
  2161.     }
  2162.     if(!is_user_connected(capitan_tt))
  2163.     {
  2164.         capitan_tt = p[random(num)]
  2165.         rg_set_user_team(capitan_tt, TEAM_TERRORIST)
  2166.         set_member(capitan_tt, m_iJoiningState, 5)
  2167.     }
  2168. }
  2169.  
  2170. public fnCaptainHud()
  2171. {
  2172.     if(captainrun) set_task(1.0, "fnCaptainHud")
  2173.     check_capitan()
  2174.     new szName[15], iTeam,fmt[33 * 33]
  2175.  
  2176.     set_hudmessage(0, 255, 0, 0.75, 0.07, 0, 1.0, 1.1)
  2177.     ShowSyncHudMsg(0, Sync1, "Seleccion de capitanes")
  2178.  
  2179.     copy(fmt, charsmax(fmt), "")
  2180.     for(new i = 1 ; i <= get_playersnum(); i++ )
  2181.     {
  2182.         if(!is_user_connected(i))
  2183.         {
  2184.             continue
  2185.         }
  2186.         iTeam = get_user_team(i)
  2187.         get_user_name(i, szName, charsmax(szName))
  2188.  
  2189.         if(capitan_tt == i || capitan_ct == i)
  2190.         {
  2191.             switch(iTeam)
  2192.             {
  2193.                 case 1: format(fmt, charsmax(fmt), "%s (C)^n^n%s",szName, fmt)
  2194.                 case 2: format(fmt, charsmax(fmt), "%s (C)^n^n%s",szName, fmt)
  2195.             }
  2196.         }
  2197.         else
  2198.         {
  2199.             switch(iTeam)
  2200.             {
  2201.                 case 1: format(fmt, charsmax(fmt), "%s%s^n", fmt, szName)
  2202.                 case 2: format(fmt, charsmax(fmt), "%s%s^n", fmt, szName)
  2203.                 case 3: format(fmt, charsmax(fmt), "%s%s^n", fmt, szName)
  2204.             }
  2205.         }
  2206.     }
  2207.     set_hudmessage(255, 255, 255, 0.70, 0.1, 0, 1.0, 1.1)
  2208.     ShowSyncHudMsg(0, Sync2, fmt)
  2209.  
  2210.     copy(fmt, charsmax(fmt), "")
  2211.     for(new i = 1 ; i <= get_playersnum() ;i++ )
  2212.     {
  2213.         if(!is_user_connected(i))
  2214.         {
  2215.             continue
  2216.         }
  2217.         iTeam = get_user_team(i)
  2218.  
  2219.         if(capitan_tt == i || capitan_ct == i)
  2220.         {
  2221.             switch(iTeam)
  2222.             {
  2223.                 case 1: format(fmt,charsmax(fmt),"- Terrorista^n^n%s", fmt)
  2224.                 case 2: format(fmt,charsmax(fmt),"- Anti-Terrorista^n^n%s", fmt)
  2225.             }
  2226.         }
  2227.         else
  2228.         {
  2229.             switch(iTeam)
  2230.             {
  2231.                 case 1: format(fmt,charsmax(fmt),"%s- Terrorista^n", fmt)
  2232.                 case 2: format(fmt,charsmax(fmt),"%s- Anti-Terrorista^n", fmt)
  2233.                 case 3: format(fmt,charsmax(fmt),"%s- En espera^n", fmt)
  2234.             }
  2235.         }
  2236.     }
  2237.     set_hudmessage(242, 195, 43, 0.84, 0.1, 1, 1.0, 1.1)
  2238.     ShowSyncHudMsg(0, Sync3, fmt)
  2239. }
  2240.  
  2241. public fnCa2ptainHud()
  2242. {
  2243.     if(captainrun) set_task(1.0, "fnCaptainHud")
  2244.     check_capitan()
  2245.     new iPlayers[MAX_PLAYERS],iNum,iPlayer;
  2246.     get_players(iPlayers,iNum,"h");
  2247.  
  2248.     new szName[20],iCTs,szList[4][320],iTeam,iSpec;
  2249.  
  2250.     for(new i;i < iNum;i++)
  2251.     {
  2252.         iPlayer = iPlayers[i];
  2253.  
  2254.         get_user_name(iPlayer,szName, 14);
  2255.  
  2256.         if((iPlayer == capitan_tt) || (iPlayer == capitan_ct))
  2257.         {
  2258.             add(szName,charsmax(szName)," (C)");
  2259.         }
  2260.  
  2261.         iTeam = get_user_team(iPlayer);
  2262.  
  2263.         switch(iTeam)
  2264.         {
  2265.             case 2: iCTs++;
  2266.             case 3: iSpec++;
  2267.         }
  2268.  
  2269.         add(szName,charsmax(szName),"^n");
  2270.         add(szList[iTeam],charsmax(szList[]),szName);
  2271.     }
  2272.  
  2273.     for(new i = 0;i < (5 - iCTs);i++)
  2274.     {
  2275.         add(szList[2],charsmax(szList[]),"^n");
  2276.     }
  2277.  
  2278.     set_hudmessage(0,255,0,0.75,0.17,0,0.0,99.0,0.0,0.0,1);
  2279.     show_hudmessage(0,"Terrorostas");
  2280.  
  2281.     set_hudmessage(255,255,255,0.75,0.17,0,0.0,99.0,0.0,0.0,2);
  2282.     show_hudmessage(0,"^n%s",szList[1]);
  2283.  
  2284.     if(iSpec)
  2285.     {
  2286.         set_hudmessage(0,255,0,0.75,0.32,0,0.0,99.0,0.0,0.0,3);
  2287.         show_hudmessage(0,"Anti-Terrorostas^n^n^n^n^n^n^nEspectadores");
  2288.  
  2289.         set_hudmessage(255,255,255,0.75,0.32,0,0.0,99.0,0.0,0.0,4);
  2290.         show_hudmessage(0,"^n%s^n^n%s",szList[2],szList[3]);
  2291.     }
  2292.     else
  2293.     {
  2294.         set_hudmessage(0,255,0,0.75,0.32,0,0.0,99.0,0.0,0.0,3);
  2295.         show_hudmessage(0,"Anti-Terrorostas");
  2296.  
  2297.         set_hudmessage(255,255,255,0.75,0.32,0,0.0,99.0,0.0,0.0,4);
  2298.         show_hudmessage(0,"^n%s",szList[2]);
  2299.     }
  2300. }
  2301. /* STOCK de eleccion random */
  2302. random_player(team)
  2303. {
  2304.     if(!(1 <= team <= 2))
  2305.     {
  2306.         log_error(AMX_ERR_NATIVE, "[CAPITAN] Team incorrecto")
  2307.         return 0
  2308.     }
  2309.     new p[32], count
  2310.     get_players(p, count, "e", team == 1 ? "TERRORIST" : "CT")
  2311.  
  2312.     new t = p[random(count)]
  2313.     for(new i = 1 ; i <= iMaxPlayers ; i++)
  2314.     {
  2315.         if(t == i || team != get_user_team(i))
  2316.         {
  2317.             continue
  2318.         }
  2319.         cmdDirector(i, "kill")
  2320.         rg_set_user_team(i, TEAM_SPECTATOR)
  2321.         set_member(i, m_iJoiningState, 5)
  2322.     }
  2323.     return t
  2324. }
  2325.  
  2326. public start_countdown()
  2327. {
  2328.     EnableHamForward(PlayerPostink)
  2329.     client_cmd(0, "+strafe")
  2330.     g_vote_countdown = 4
  2331.     set_task(1.0, "pfn_starting_game", TASK_HUD_READY, _, _, "b")
  2332.     pfn_starting_game(TASK_HUD_READY)
  2333.     set_pcvar_num(g_pcvar_votemap, 1)
  2334. }
  2335.  
  2336. public start_pug()
  2337. {
  2338.     set_cvar_num("sv_restart", 1)
  2339.     for(new i = 0 ; i < sizeof(PugStartCmds) ;i++)
  2340.     {
  2341.         set_cvar_string(PugStartCmds[i][COMMAND], PugStartCmds[i][VALUE])
  2342.     }
  2343.     g_iRounds = 0;
  2344.     arrayset(g_iRound_team, 0, 2)
  2345.     arrayset(g_iFrags, 0, MAXPLAYERS)
  2346.     arrayset(g_iDeaths, 0, MAXPLAYERS)
  2347.     is_intermission = false
  2348.     DisableHamForward(DefuseKit)
  2349. }
  2350.  
  2351. public pfn_force_start_pug(id)
  2352. {
  2353.     if(!(get_user_flags(id) & ADMIN_RCON))
  2354.     {
  2355.         client_print_color(id, 0, "%s No tienes acceso a este comando", TAG)
  2356.         return
  2357.     }
  2358.     else if(pug_state != NO_ALIVE)
  2359.     {
  2360.         client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
  2361.         return
  2362.     }
  2363.     start_vote()
  2364. }
  2365.  
  2366. public pfn_force_cancel(id)
  2367. {
  2368.     if(!is_user_admin(id))
  2369.     {
  2370.         client_print_color(id, 0, "%s No tienes acceso a este comando", TAG)
  2371.         return
  2372.     }
  2373.     else if(pug_state != ALIVE)
  2374.     {
  2375.         client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
  2376.         return
  2377.     }
  2378.     new name[32]
  2379.     get_user_name(id, name, charsmax(name))
  2380.     client_print_color(0, 0, "%s ADMIN: %s Ha cancelado la partida", TAG, name)
  2381.     start_pregame()
  2382. }
  2383.  
  2384. public pfn_forceready(id)
  2385. {
  2386.     if(!is_user_admin(id))
  2387.     {
  2388.         client_print_color(id, 0, "%s No tienes acceso a este comando", TAG)
  2389.         return
  2390.     }
  2391.     else if(pug_state != NO_ALIVE)
  2392.     {
  2393.         client_print_color(id, 0, "%s Accion no permitida en este momento", TAG)
  2394.         return
  2395.     }
  2396.     fn_forceready()
  2397. }
  2398.  
  2399. fn_forceready()
  2400. {
  2401.     for(new i = 1 ; i<= iMaxPlayers ; i++)
  2402.     {
  2403.         if(!is_user_connected(i) || !(1<= get_user_team(i) <= 2) || ready[i])
  2404.         {
  2405.             continue
  2406.         }
  2407.         ready[i] = true;
  2408.         ready_count++
  2409.         if(ready_count == get_pcvar_num(pcvar_max_players))
  2410.         {
  2411.             start_vote()
  2412.         }
  2413.     }
  2414. }
  2415.  
  2416. public pfn_waiting_players(task)
  2417. {
  2418.     new pcount = 0
  2419.     for(new i = 1 ; i <= iMaxPlayers ; i++)
  2420.     {
  2421.         if(!is_user_connected(i) || !(1 <= get_user_team(i) <= 2))
  2422.         {
  2423.             continue;
  2424.         }
  2425.         pcount++
  2426.     }
  2427.     if(g_vote_countdown -- > 0)
  2428.     {
  2429.  
  2430.         if(pcount == get_pcvar_num(pcvar_max_players))
  2431.         {
  2432.             center_print(0, "Calentamiento 00:%02i^n^n^n^n", g_vote_countdown)
  2433.             if(g_vote_countdown < 5)
  2434.             {
  2435.                 client_cmd(0, "spk ^"%s^"", SND_COUNTER_BEEP[6])
  2436.             }
  2437.         }
  2438.         else
  2439.         {
  2440.             center_print(0, "Esperando jugadores 00:%02i^n^n^n^n", g_vote_countdown)
  2441.         }
  2442.     }
  2443.     else if(g_vote_countdown <= 0 && pcount == get_pcvar_num(pcvar_max_players))
  2444.     {
  2445.         remove_task(task)
  2446.         next_vote()
  2447.     }
  2448.     else
  2449.     {
  2450.         set_pcvar_num(g_pcvar_votemap, 1)
  2451.         remove_task(task)
  2452.         start_pregame()
  2453.         fn_forceready();
  2454.         client_print_color(0, 0, "%s Partida no iniciada por la ausencia de jugadores", TAG)
  2455.     }
  2456. }
  2457.  
  2458. public pfn_starting_game(task)
  2459. {
  2460.     if(g_vote_countdown == 1)
  2461.     {
  2462.         start_pug()
  2463.         pug_state = COMMENCING
  2464.     }
  2465.  
  2466.     if(g_vote_countdown -- > 0)
  2467.     {
  2468.         center_print(0, "Empezando Partida: %i^n^n^n^n", g_vote_countdown)
  2469.  
  2470.     }
  2471.     else
  2472.     {
  2473.         DisableHamForward(PlayerPostink)
  2474.         client_cmd(0, "-strafe")
  2475.         remove_task(task)
  2476.     }
  2477. }
  2478.  
  2479. public plugin_precache()
  2480. {
  2481.     precache_generic(SND_COUNTER_BEEP)
  2482.     precache_generic(SND_STINGER)
  2483.     for(new i = 0 ; i < sizeof(SND_MUSIC) ; i++)
  2484.     {
  2485.         precache_generic(SND_MUSIC[i])
  2486.     }
  2487. }
  2488.  
  2489. stock cmdDirector(id, cmd[])
  2490. {
  2491.     message_begin(id > 0 ? MSG_ONE : MSG_ALL, SVC_DIRECTOR, _, id > 0 ? id : 0)
  2492.     write_byte(strlen(cmd) + 2)
  2493.     write_byte(10)
  2494.     write_string(cmd)
  2495.     message_end()
  2496. }
  2497.  
  2498. public pfn_Surrender(id)
  2499. {
  2500.     if(pug_state == ALIVE && OffFreeze && !OnSurrender )
  2501.     {
  2502.         if(tryid[id] == get_pcvar_num(pcvar_max_tryid))
  2503.         {
  2504.             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))
  2505.             return
  2506.         }
  2507.         if(c[get_member(id, m_iTeam)] > get_systime())
  2508.         {
  2509.             new msj
  2510.             msj = c[suteam]-get_systime()
  2511.             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)
  2512.             return
  2513.         }
  2514.         suteam = get_member(id, m_iTeam)
  2515.         OnSurrender = true
  2516.         //tryid[suteam]=true
  2517.         tryid[id]++
  2518.         get_user_name(id, name, charsmax(name))
  2519.         c[suteam] = get_systime()+120
  2520.        
  2521.         for(new i=1; i<get_maxplayers(); i++)
  2522.         {
  2523.             if(!is_user_connected(i))
  2524.             {
  2525.                 continue
  2526.             }
  2527.             if(get_member(i, m_iTeam) == suteam)
  2528.             {
  2529.                 client_print_color(i, id, "%s Una votacion inciara al inicio de ronda.", TAG)
  2530.             }
  2531.             else
  2532.             {
  2533.                 client_print_color(i, id, "%s El equipo %s realizara una votacion para rendirse.", TAG, suteam==1?"terrorista":"anti-terrorista")
  2534.             }
  2535.         }
  2536.     }
  2537. }
  2538.  
  2539. public pfn_surren_handler(id, menu, item)
  2540. {
  2541.     switch(item)
  2542.     {
  2543.         case 0:
  2544.         {
  2545.             g_cvotes[0]++
  2546.         }
  2547.         case 1:
  2548.         {
  2549.             g_cvotes[1]++
  2550.         }
  2551.     }
  2552.    
  2553. }
  2554.  
  2555. public pfn_hud_vote_surrender()
  2556. {
  2557.     g_vote_count = 0
  2558.     g_vote_countdown = 10
  2559.     set_task(1.0, "pfn_hud_votesurrender", TASK_PUG_END, _, _, "b")
  2560. }
  2561.  
  2562. public pfn_hud_votesurrender(task)
  2563. {
  2564.     g_vote_countdown--
  2565.     if(g_vote_countdown > 0)
  2566.     {
  2567.         for(new i = 1 ; i <= get_maxplayers() ; i++)
  2568.         {
  2569.             if(!is_user_connected(i) || get_member(i, m_iTeam) != suteam)
  2570.             {
  2571.                 continue;
  2572.             }
  2573.             center_print(i, "Votacion para rendirse^n^nTermina en %i segundos^n^n^n^n", g_vote_countdown)
  2574.         }
  2575.     }
  2576.     else{
  2577.         remove_task(task)
  2578.     }
  2579. }
  2580.  
  2581. public pfn_End_FreezeTime()
  2582. {
  2583.     OffFreeze=true
  2584.     new p[32], count
  2585.     get_players(p, count, "e", suteam == 1 ? "TERRORIST" : "CT")
  2586.    
  2587.     if(OnSurrender)
  2588.     {
  2589.         if(g_cvotes[0] >= count)
  2590.         {
  2591.             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")
  2592.             //pug_force_end(suteam == 1 ? 2:1)
  2593.             EnableHamForward(PlayerPostink)
  2594.             client_cmd(0, "+strafe")
  2595.             g_vote_countdown = 15
  2596.             set_task(1.0, "pfn_pug_end_countdown", TASK_PUG_END, _, _, "b")
  2597.             is_intermission = true
  2598.            
  2599.             ExecuteForward(g_forward, _, suteam == 1 ? 1 : suteam == 2 ? 2 : 0)
  2600.             Send_TextMsg(suteam == 1 ? "#Terrorists_Win" : suteam == 2 ? "#CTs_Win" : "")
  2601.             client_cmd(0, "mp3 play ^"%s^"", SND_MUSIC[random_num(0, charsmax(SND_MUSIC))])
  2602.             cmdDirector(0, "MP3FadeTime 0.5")
  2603.         }
  2604.         else
  2605.         {
  2606.             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")
  2607.         }
  2608.         menu_destroy(menu_surrender)
  2609.         OnSurrender = false
  2610.     }
  2611. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top