Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.85 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. //#include <pug>
  5.  
  6. native PugNextVote()
  7. native RemoveTask1()
  8.  
  9. #define TASK_MENUCLOSE 9001
  10. #define TASK_PLAYERSLIST 9002
  11.  
  12. #define MinPlayers 10
  13.  
  14. new const TAG[] = "^4[^1Reen eSports^4]^1"
  15.  
  16. new RandomPlayer1
  17. new RandomPlayer2
  18.  
  19. new bool:CaptainSort
  20.  
  21. public plugin_init()
  22. {
  23. register_plugin("Captain Sorting", "1.0", "kramesa")
  24.  
  25. register_clcmd("chooseteam", "Block")
  26. register_clcmd("jointeam", "Block")
  27. }
  28.  
  29. public plugin_natives()
  30. {
  31. register_native("Capitan", "pugcapitan")
  32. register_native("CaptainSort", "pugcapitan2")
  33. register_native("RemoveCaptain", "native_remove_captain")
  34. }
  35.  
  36. public pugcapitan(pl, pr)
  37. return Captain()
  38.  
  39. public native_remove_captain(pl, pr)
  40. return CaptainSort = false
  41.  
  42. public pugcapitan2(pl, pr)
  43. return CaptainSort
  44.  
  45. public Block(id)
  46. {
  47. if(CaptainSort == true)
  48. {
  49. client_print_color(id, id, "%s Espera a que los capitanes eligan a sus jugadores", TAG);
  50. return PLUGIN_HANDLED
  51. }
  52. return PLUGIN_CONTINUE
  53. }
  54. public client_disconnected(id)
  55. {
  56. if(RandomPlayer1 && CaptainSort)
  57. {
  58. RandomPlayer1 = id
  59.  
  60. new First_Captain[35]; get_user_name(RandomPlayer1, First_Captain, charsmax(First_Captain))
  61. client_print_color(0, print_team_grey, "%s El nuevo capitan de los CT es: ^3%s", TAG, First_Captain)
  62. return PLUGIN_HANDLED
  63. }
  64. if(RandomPlayer2 && CaptainSort)
  65. {
  66. RandomPlayer2 = id
  67.  
  68. new Second_Captain[35]; get_user_name(RandomPlayer2, Second_Captain, charsmax(Second_Captain))
  69. client_print_color(0, print_team_grey, "%s El nuevo capitan de los TT es: ^3%s", TAG, Second_Captain)
  70. return PLUGIN_HANDLED
  71. }
  72. return PLUGIN_HANDLED
  73. }
  74. public Captain()
  75. {
  76. new iPlayers[32], iNum
  77. get_players(iPlayers, iNum, "ch")
  78.  
  79. if(iNum < MinPlayers)
  80. {
  81. client_print_color(0, 0, "%s Necesitas tener mas de ^4%d ^1jugadores para la eleccion de capitanes", TAG, (MinPlayers))
  82. return PLUGIN_HANDLED
  83. }
  84. for(new i; i < iNum; i++)
  85. {
  86. user_silentkill(iPlayers[i])
  87. cs_set_user_team(iPlayers[i], CS_TEAM_SPECTATOR)
  88. }
  89. RandomPlayer1 = iPlayers[random(iNum)]
  90. RandomPlayer2 = iPlayers[random(iNum)]
  91.  
  92. while(RandomPlayer1 == RandomPlayer2)
  93. RandomPlayer2 = iPlayers[random(iNum)]
  94.  
  95. cs_set_user_team(RandomPlayer1, CS_TEAM_CT)
  96. cs_set_user_team(RandomPlayer2, CS_TEAM_T)
  97.  
  98. new First_Captain[35], Second_Captain[35]
  99.  
  100. get_user_name(RandomPlayer1, First_Captain, charsmax(First_Captain))
  101. get_user_name(RandomPlayer2, Second_Captain, charsmax(Second_Captain))
  102.  
  103. client_print_color(0, print_team_grey, "%s Los capitanes son: ^3%s ^4(^1TT^4) ^1y ^3%s ^4(^1CT^4)", TAG, First_Captain, Second_Captain)
  104. client_print_color(0, 0, "%s Si no eligen un jugador en^4 10 ^1segundos un jugador sera elegido aleatoriamente", TAG)
  105.  
  106. set_cvar_num("sv_restartround", 1)
  107.  
  108. new First = random(2)
  109.  
  110. set_task(1.5, "captain_menu", First ? RandomPlayer1 : RandomPlayer2)
  111. set_task(0.2, "PlayersList", TASK_PLAYERSLIST, _, _, "b")
  112.  
  113. CaptainSort = true
  114. RemoveTask1()
  115. return PLUGIN_CONTINUE
  116. }
  117.  
  118. public captain_menu(id)
  119. {
  120. new menu = menu_create("\ySelecciona un Jugador", "captainmenu_handler")
  121.  
  122. set_task(11.5, "menu_task", id + TASK_MENUCLOSE)
  123.  
  124. new players[32], pnum, tempid
  125. new szName[32], szTempid[10]
  126.  
  127. get_players(players, pnum, "ch")
  128.  
  129. if(pnum == 0)
  130. {
  131. remove_task(id+TASK_MENUCLOSE)
  132. remove_task(TASK_PLAYERSLIST)
  133. CaptainSort = false
  134.  
  135. client_print_color(0, 0, "%s Modo capitan cancelado, jugadores desaparecidos", TAG)
  136. return PLUGIN_HANDLED
  137. }
  138. for(new i; i<pnum; i++)
  139. {
  140. tempid = players[i]
  141.  
  142. if(cs_get_user_team(tempid) != CS_TEAM_SPECTATOR) continue
  143.  
  144. get_user_name(tempid, szName, charsmax(szName))
  145. num_to_str(tempid, szTempid, charsmax(szTempid))
  146.  
  147. menu_additem(menu, szName, szTempid,0)
  148. }
  149. menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER)
  150.  
  151. menu_display(id, menu, 0)
  152. return PLUGIN_HANDLED;
  153. }
  154.  
  155. public captainmenu_handler(id,menu,item)
  156. {
  157. if(item == MENU_EXIT)
  158. return PLUGIN_HANDLED
  159.  
  160. new data[6], szName[64]
  161. new Access, callback
  162. menu_item_getinfo(menu, item, Access, data, charsmax(data), szName, charsmax(szName), callback)
  163.  
  164. new tempid = str_to_num(data)
  165.  
  166. new name[35], namec[35]
  167. get_user_name(tempid, name, charsmax(name))
  168. get_user_name(id, namec, charsmax(namec))
  169.  
  170. cs_set_user_team(tempid, cs_get_user_team(id))
  171. client_print_color(0, print_team_grey, "%s ^3%s ^1elige al jugador ^3%s", TAG, namec, name)
  172.  
  173. set_cvar_num("sv_restart",1)
  174.  
  175. remove_task(id+TASK_MENUCLOSE)
  176.  
  177. new iPlayers[32], pnum
  178. get_players(iPlayers,pnum,"h")
  179.  
  180. if(is_user_connected(RandomPlayer1) && is_user_connected(RandomPlayer2))
  181. set_task(1.5,"captain_menu",id == RandomPlayer1 ? RandomPlayer2 : RandomPlayer1)
  182. else
  183. set_task(5.0,"CheckCaptainJoin",id == RandomPlayer1 ? RandomPlayer1 : RandomPlayer2)
  184.  
  185. menu_destroy(menu)
  186. return PLUGIN_HANDLED
  187. }
  188.  
  189. public menu_task(id)
  190. {
  191. id -= TASK_MENUCLOSE
  192.  
  193. new players[32], pnum
  194. get_players(players, pnum, "ch")
  195.  
  196. new randomnum = random(pnum)
  197. new bool:has_spec
  198.  
  199. for(new i; i < pnum; i++)
  200. {
  201. if(cs_get_user_team(players[i]) == CS_TEAM_SPECTATOR)
  202. has_spec = true
  203. }
  204. if(!has_spec)
  205. {
  206. remove_task(TASK_PLAYERSLIST)
  207. PugNextVote()
  208. CaptainSort = false
  209. return;
  210. }
  211. while(cs_get_user_team(players[randomnum]) != CS_TEAM_SPECTATOR)
  212. randomnum = random(pnum)
  213.  
  214. if(is_user_connected(id))
  215. {
  216. set_cvar_num("sv_restart",1)
  217. cs_set_user_team(players[randomnum],cs_get_user_team(id))
  218.  
  219. set_task(1.5, "captain_menu", id == RandomPlayer1 ? RandomPlayer2 : RandomPlayer1)
  220. }
  221. else
  222. {
  223. set_task(5.0, "CheckCaptainJoin", id == RandomPlayer1 ? RandomPlayer2 : RandomPlayer1)
  224. client_print_color(0, 0, "%s Esperando un nuevo capitan", TAG)
  225. }
  226. show_menu(id, 0, "^n", 1);
  227. }
  228.  
  229. public CheckCaptainJoin(NextCaptainMenu)
  230. {
  231. if(is_user_connected(RandomPlayer1) && is_user_connected(RandomPlayer2))
  232. set_task(1.5, "captain_menu", NextCaptainMenu)
  233. else
  234. set_task(5.0, "CheckCaptainJoin", NextCaptainMenu)
  235. }
  236.  
  237. public PlayersList()
  238. {
  239. new iPlayers[32], iNum
  240. get_players(iPlayers, iNum, "ch")
  241.  
  242. new posTR, posCT, posSPEC
  243. new HudTextTR[512], HudTextCT[512], HudTextSPEC[512]
  244. new szName[38], name[38]
  245.  
  246. for(new i; i < iNum; i++)
  247. {
  248. get_user_name(iPlayers[i], szName, charsmax(szName))
  249.  
  250. if(iPlayers[i] == RandomPlayer1 || iPlayers[i] == RandomPlayer2)
  251. formatex(name, charsmax(name), "%s (C)", szName)
  252. else
  253. name = szName
  254.  
  255. if(cs_get_user_team(iPlayers[i]) == CS_TEAM_T)
  256. posTR += formatex(HudTextTR[posTR], 511-posTR,"%s^n", name)
  257.  
  258. else if(cs_get_user_team(iPlayers[i]) == CS_TEAM_CT)
  259. posCT += formatex(HudTextCT[posCT], 511-posCT, "%s^n", name)
  260.  
  261. else
  262. posSPEC += formatex(HudTextSPEC[posSPEC], 511-posSPEC, "%s^n", name)
  263. }
  264. set_hudmessage(255, 0, 0, 0.69, 0.16, 0, 0.0, 1.1, 0.0, 0.0, 1)
  265. show_hudmessage(iPlayers[i], "%s", HudTextTR ? "Terroristas" ? "AntiTerroristas")
  266. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement