1. vnuk Пользователь

    Регистрация:
    11.12.15
    Сообщения:
    12
    Симпатии:
    0
    Пол:
    Мужской
    Подскажите пожалуйста, как сделать чтобы после 5 ослеплений своих тимов, игроку было запрещено покупать флеш гранату на протяжении 3-х раундов?
    Код:
    #include <amxmodx>
    #include <fakemeta>
    #include <colorchat>
    
    #define TEMPENTITY   "23"
    #define BLINDED_FULLY   255
    #define BLINDED_PARTLY   200
    new Float:FLASH_TIMER = 1.52   // Time from throwing a FB to the bang (1.52 seconds?)
    new g_flasher = 0      // id of the flasher
    new g_flash_mon[33] = {0, ...}
    new pcvar, limit
    public plugin_init()
    {
       register_plugin("Team Flash", "1.0", "Admin")
       register_event("ScreenFade", "event_blinded", "be", "4=255", "5=255", "6=255", "7>199")
       register_event(TEMPENTITY, "event_flashsmokepuff", "a", "1=5", "6=25", "7=6")
       register_forward(FM_SetModel, "forward_setmodel")
       
       pcvar = register_cvar("amx_limit", "5") // Лимит ослепления, после которого последует наказание.
       limit = get_pcvar_num(pcvar)
    }
    public plugin_natives()
    {
       register_native("get_counter", "native_get_counter", 1)
       register_native("set_counter", "native_set_counter", 1)
    }
    public native_get_counter(id)
    {
       return g_flash_mon[id]
    }
    public native_set_counter(id, quantity)
    {
       g_flash_mon[id] = quantity
       return 1
    }
    public event_blinded(const ID)
    {
       new alpha = read_data(7)
       if(alpha != BLINDED_FULLY && alpha != BLINDED_PARTLY || !is_user_alive(ID))
          return PLUGIN_CONTINUE
       
       if(get_user_team(ID) == get_user_team(g_flasher) && ID != g_flasher) {
          new flasher[32], name[32]
          get_user_name(g_flasher, flasher, 31)
          get_user_name(ID, name, 31)
           
          ColorChat (ID, RED, "^1Вас ослепил игрок по команде %s", flasher)
          ColorChat (g_flasher, RED, "^1Вы ослепили игрока по команде %s", name)
       }
       
       g_flash_mon[g_flasher] += 1
       
       if(g_flash_mon[g_flasher] >= limit && alpha == BLINDED_FULLY) {
          if(get_user_flags(g_flasher) & ADMIN_IMMUNITY) {
             return PLUGIN_HANDLED
          }
          else {
             new ban[32]
             get_user_name(g_flasher, ban, 31)
             server_cmd("amx_ban ^"5^" ^"%s^" ^"Team Flash^"", ban)
          }
       }
       return PLUGIN_CONTINUE
    }
    public event_flashsmokepuff()
    {
       set_task(0.05, "reset_flasher")
       return PLUGIN_CONTINUE
    }
    public reset_flasher()
    {
       g_flasher = 0
    }
    public get_flasher(id)
    {
       g_flasher = (id - 524627)
    }
    public forward_setmodel(const ENTITY, model[])
    {
       if(!equal(model, "models/w_flashbang.mdl"))
          return FMRES_IGNORED
       new owner = pev(ENTITY, pev_owner)
       if (owner == 0)
          return FMRES_IGNORED
       set_task(FLASH_TIMER, "get_flasher", 524627+owner)
       return FMRES_IGNORED
    }
    
    stock print_col_chat(const id, const input[], any:...)
    {
        new count = 1, players[32];
        static msg[191];
        vformat(msg, 190, input, 3);
        replace_all(msg, 190, "!g", "^4"); // Green Color
        replace_all(msg, 190, "!y", "^1"); // Default Color
        replace_all(msg, 190, "!t", "^3"); // Team Color
        if (id) players[0] = id; else get_players(players, count, "ch");
        {
            for ( new i = 0; i < count; i++ )
            {
                if ( is_user_connected(players[i]) )
                {
                    message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);
                    write_byte(players[i]);
                    write_string(msg);
                    message_end();
                }
            }
        }
    }