Advertisement
Sugisaki

[AMXX] PUG ChooseTeam Hook

Oct 7th, 2017
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.72 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <reapi>
  3.  
  4. #define PLUGIN  "LEL"
  5. #define VERSION "1.0"
  6. #define AUTHOR  "Sugisaki"
  7.  
  8. new g_iTeam[33]
  9.  
  10. public plugin_init()
  11. {
  12.     register_plugin(PLUGIN, VERSION, AUTHOR)
  13.     RegisterHookChain(RG_HandleMenu_ChooseTeam, "pfn_ChooseTeam_Hook")
  14. }
  15. public pfn_ChooseTeam_Hook(id, _:slot)
  16. {
  17.     if(slot == 5)
  18.     {
  19.         new count_t, count_ct
  20.         count_player(5, count_t, count_ct)
  21.         if(count_t == 5 && count_ct == 5)
  22.         {
  23.             client_print(id, print_chat, "Equipo lleno")
  24.             SetHookChainReturn(ATYPE_INTEGER, 0)
  25.             return HC_BREAK
  26.         }
  27.         if(count_t > count_ct)
  28.         {
  29.             rg_internal_cmd(id, "jointeam", "2")
  30.             g_iTeam[id] = 2
  31.         }
  32.         else
  33.         {
  34.             rg_internal_cmd(id, "jointeam", "1")
  35.             g_iTeam[id] = 1
  36.         }
  37.         SetHookChainReturn(ATYPE_INTEGER, 1)
  38.         return HC_SUPERCEDE
  39.     }
  40.     if(slot == 6)
  41.     {
  42.         if(1 <= g_iTeam[id] <= 2)
  43.         {
  44.             client_print(id, print_chat, "No puedes Entrar a espectador mientras la partia esta en proceso")
  45.             SetHookChainReturn(ATYPE_INTEGER, 0)
  46.             return HC_BREAK
  47.         }
  48.         g_iTeam[id] = slot
  49.         return HC_CONTINUE
  50.     }
  51.     if(1 <= slot <= 2)
  52.     {
  53.        
  54.         if(count_player(slot) >= 5)
  55.         {
  56.             client_print(id, print_chat, "Equipo lleno")
  57.             SetHookChainReturn(ATYPE_INTEGER, 0)
  58.             return HC_BREAK
  59.         }
  60.         g_iTeam[id] = slot
  61.     }
  62.     return HC_CONTINUE
  63. }
  64. public client_putinserver(id)
  65. {
  66.     g_iTeam[id] = 0
  67. }
  68. count_player(slot, &count_t=0, &count_ct=0)
  69. {
  70.     new count
  71.     for(new i = 1 ; i <= get_maxplayers() ; i++)
  72.     {
  73.         if(!is_user_connected(i))
  74.         {
  75.             continue
  76.         }
  77.         if(slot == 5)
  78.         {
  79.             if(g_iTeam[i] == 1)
  80.             {
  81.                 count_t += 1
  82.             }
  83.             else if(g_iTeam[i] == 2)
  84.             {
  85.                 count_ct += 1
  86.             }
  87.         }
  88.         else
  89.         {
  90.             if(g_iTeam[i] == slot)
  91.             {
  92.                 count += 1
  93.             }
  94.         }
  95.        
  96.     }
  97.     return count
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement