VIP-диспенсер

Сообщения
3
Реакции
0
У меня есть дозатор, в который я пытаюсь внести некоторые изменения.
В основном я хочу, чтобы VIP игроки могли поставить два диспенсера и больше Я не могу сделать это правильным способом попробую выложить код

в настоящее время codigo esta assim


PHP:
public xBuyDispenser( id )
{
    // não está vivo, ignore
    if ( !is_user_alive( id ) )
    {
        return PLUGIN_CONTINUE
    }

    // não está no chão, ignore
    if (!( pev(id, pev_flags) & FL_ONGROUND))
    {
        client_print_color(id, print_team_default, "%s ^3Tente ficar em um chao ^1PLANO ^3para poder comprar um ^4Dispenser^3.", PREFIX_CHAT)
        client_cmd(id, "spk %s", g_DispSndFail)

        return PLUGIN_HANDLED
    }

    // maximum dispenser limit
    new const limit_per_player = get_pcvar_num(g_Cvar[CVAR_LIMIT_PER_PLAYER])
    new const limit_per_vip    = get_pcvar_num(g_Cvar[CVAR_LIMIT_PER_VIP])

    // check if the 'id' is a VIP
    new const is_vip = g_IsVip[id]

    // how many dispensers the player has
    new const dispenser_count = g_DispPlayerCount[id]

    // reached the maximum dispenser limit
    new const reached_limit = (is_vip ? dispenser_count >= limit_per_vip : dispenser_count >= limit_per_player)

    // can't buy more, ignore
    if (reached_limit)
    {
        client_print_color(id, print_team_default, "%s ^3You have already reached the ^4Dispenser ^3.", PREFIX_CHAT)
        client_cmd(id, "spk %s", g_DispSndFail)

        return PLUGIN_HANDLED
    }
    
    static iMoney; iMoney = cs_get_user_money(id)
    static iPriceDisp; iPriceDisp = get_pcvar_num(g_Cvar[CVAR_LVL1_PRICE])
    static isPriceDisp; isPriceDisp = get_pcvar_num(g_Cvar[CVAR_VIP_LVL1_PRICE])

  

    if(is_vip)
    {
        if(iMoney < isPriceDisp)
        {
            
            client_print_color(id, print_team_default, "%s ^3You do not have enough money! ^4$: %s^3.", PREFIX_CHAT, xAddPoint(isPriceDisp))
            client_cmd(id, "spk %s", g_DispSndFail)
            
            
            
            return PLUGIN_HANDLED

        }
    }
    else
    {
        if(iMoney < iPriceDisp)
        {
            client_print_color(id, print_team_default, "%s ^3You do not have enough money! ^4$: %s^3.", PREFIX_CHAT, xAddPoint(iPriceDisp))
            client_cmd(id, "spk %s", g_DispSndFail)

            return PLUGIN_HANDLED
        }
    }
    
    
    if(g_PlayerMovingDisp[id])
    {
        client_print_color(id, print_team_default, "%s ^3Voce ja esta com um ^4Dispenser ^3ativado, coloque-o para comprar mais.", PREFIX_CHAT)
        client_cmd(id, "spk %s", g_DispSndFail)

        return PLUGIN_HANDLED
    }
    
    else
    {
        if(get_pcvar_num(g_Cvar[CVAR_INSTANT_PLANT]))
        {
            static Float:fOrigin[3]
            get_origin_from_dist_player(id, 100.0, fOrigin)

            if(xCreateDispanser(fOrigin, id))
            {
                client_print_color(id, print_team_default, "%s ^4Dispenser ^3plantado!", PREFIX_CHAT)
                cs_set_user_money(id, iMoney - iPriceDisp)
            }
            else
            {
                client_cmd(id, "spk %s", g_DispSndFail)
            }
        }
        else
        {
            CreateDispMoveEffect(id)
            cs_set_user_money(id, iMoney - iPriceDisp)
        }
    }
    
    
    return PLUGIN_HANDLED
}

public xDestroyDispenser(id)
{
    if(!g_DispPlayerCount[id])
    {
        client_print_color(id, print_team_default, "%s ^3Voce nao possui nenhum ^4Dispenser ^3para ser destruído.", PREFIX_CHAT)
        client_cmd(id, "spk %s", g_DispSndFail)

        return PLUGIN_HANDLED
    }

    static ent; ent = FM_NULLENT

    while((ent = find_ent_by_class(ent, dispenser_classname)))
    {
        if(pev(ent, DISPENSER_OWNER) != id)
            continue

        if(pev_valid(ent))
        {
            static iLevel, xGiveMoney
            iLevel = pev(ent, DISPENSER_LEVEL)

            xGiveMoney = 0

            switch(iLevel)
            {
                case 1: { xGiveMoney = (get_pcvar_num(g_Cvar[CVAR_LVL1_PRICE])) / 2; }
                case 2: { xGiveMoney = (get_pcvar_num(g_Cvar[CVAR_LVL2_PRICE])) / 2; }
                case 3: { xGiveMoney = (get_pcvar_num(g_Cvar[CVAR_LVL3_PRICE])) / 2; }
                case 4: { xGiveMoney = (get_pcvar_num(g_Cvar[CVAR_LVL4_PRICE])) / 2; }
            }

            g_DispPlayerCount[id] --
            //xLimitTeamAtt(id)

            cs_set_user_money(id, cs_get_user_money(id) + xGiveMoney)
            client_print_color(id, print_team_default, "%s ^3Voce obteve: ^4$: %s ^3de dinheiro por destruír seu ^4Dispenser ^3Lvl: ^4%d^3.", PREFIX_CHAT,
            xAddPoint(xGiveMoney), iLevel)
            xRemoveEntFix(ent)
        }
    }

    return PLUGIN_HANDLED
}
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу