Raised This Month: $ Target: $400
 0% 

Dispenser


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yagami
Member
Join Date: Jan 2021
Old 07-29-2022 , 08:26   Dispenser
Reply With Quote #1

How do I create a cvar where the vip player can place two dispensers?

PHP Code:
public xBuyDispenser(id)
{
    if(!
is_user_alive(id))
        return 
PLUGIN_CONTINUE

    
if(!(pev(idpev_flags) & FL_ONGROUND))
    {
        
client_print_color(idprint_team_default"%s ^3Tente ficar em um chão ^1PLANO ^3para poder comprar um ^4Dispenser^3."PREFIX_CHAT)
        
client_cmd(id"spk %s"g_DispSndFail)

        return 
PLUGIN_HANDLED
    
}

    if(
g_DispPlayerCount[id] >= get_pcvar_num(g_Cvar[CVAR_LIMIT_PER_PLAYER]))
    {
        
client_print_color(idprint_team_default"%s ^3Você já atingiu o limite de ^4Dispenser ^3."PREFIX_CHAT)
        
client_cmd(id"spk %s"g_DispSndFail)

        return 
PLUGIN_HANDLED
    
}

    
/*if((xLimitGlobal[0] >= get_pcvar_num(g_Cvar[CVAR_LIMIT_GLOBAL]) && get_user_team(id) == 1) || (xLimitGlobal[1] >= get_pcvar_num(g_Cvar[CVAR_LIMIT_GLOBAL]) && get_user_team(id) == 2))
    {
        client_print_color(id, print_team_default, "%s ^3Sua equipe atingiu o limite de ^4Dispenser^3.", PREFIX_CHAT)
        client_cmd(id, "spk %s", g_DispSndFail)

        return PLUGIN_HANDLED
    }*/

    
static iMoneyiMoney cs_get_user_money(id)
    static 
iPriceDispiPriceDisp get_pcvar_num(g_Cvar[CVAR_LVL1_PRICE])

    if(
iMoney iPriceDisp)
    {
        
client_print_color(idprint_team_default"%s ^3Você não possui dinheiro suficiente! ^4$: %s^3."PREFIX_CHATxAddPoint(iPriceDisp))
        
client_cmd(id"spk %s"g_DispSndFail)

        return 
PLUGIN_HANDLED
    
}

    if(
g_PlayerMovingDisp[id])
    {
        
client_print_color(idprint_team_default"%s ^3Você já está 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(id100.0fOrigin)

            if(
xCreateDispanser(fOriginid))
            {
                
client_print_color(idprint_team_default"%s ^4Dispenser ^3plantado!"PREFIX_CHAT)
                
cs_set_user_money(idiMoney iPriceDisp)
            }
            else
            {
                
client_cmd(id"spk %s"g_DispSndFail)
            }
        }
        else
        {
            
CreateDispMoveEffect(id)
            
cs_set_user_money(idiMoney iPriceDisp)
        }
    }

    return 
PLUGIN_HANDLED
}

public 
xDestroyDispenser(id)
{
    if(!
g_DispPlayerCount[id])
    {
        
client_print_color(idprint_team_default"%s ^3Você não possui nenhum ^4Dispenser ^3para ser destruído."PREFIX_CHAT)
        
client_cmd(id"spk %s"g_DispSndFail)

        return 
PLUGIN_HANDLED
    
}

    static 
entent FM_NULLENT

    
while((ent find_ent_by_class(entdispenser_classname)))
    {
        if(
pev(entDISPENSER_OWNER) != id
            continue

        if(
pev_valid(ent)) 
        {
            static 
iLevelxGiveMoney
            iLevel 
pev(entDISPENSER_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(idcs_get_user_money(id) + xGiveMoney)
            
client_print_color(idprint_team_default"%s ^3Você obteve: ^4$: %s ^3de dinheiro por destruír seu ^4Dispenser ^3Lvl: ^4%d^3."PREFIX_CHAT,
            
xAddPoint(xGiveMoney), iLevel)
            
xRemoveEntFix(ent)
        }
    }

    return 
PLUGIN_HANDLED

yagami is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-29-2022 , 09:21   Re: Dispenser
Reply With Quote #2

So regular players limit is controlled by cvar but you want VIP hard coded at 2?
__________________
Bugsy is offline
yagami
Member
Join Date: Jan 2021
Old 07-29-2022 , 12:53   Re: Dispenser
Reply With Quote #3

There is a cvar called CVAR_LIMIT_PER_PLAYER it limits the amount of dispenser that all players can place what I want to do and create another cvar CVAR_LIMIT_VIP_PLAYER where only vip players can place two



HTML Code:
CVAR_LIMIT_PER_PLAYER = PLAYER 
CVAR_LIMIT_VIP_PLAYER = VIP, ADMINS ETC
Besides that I also want to modify dispenser values an example


PHP Code:
PLAYERS BUY MONEY 
gCvars
CVAR_COST_LV1 ] = register_cvar"disp_cost_lv1""4000" )
gCvarsCVAR_COST_LV2 ] = register_cvar"disp_cost_lv2""4000" );
gCvarsCVAR_COST_LV3 ] = register_cvar"disp_cost_lv3""4000" );
//gCvars[ CVAR_COST_LV4 ] = register_cvar( "disp_cost_lv4", "9000" );

DISPENSER PURCHASE MONEY FOR VIPSADMINS
gCvars
CVAR_VIPS_LV1 ] = register_cvar"disp_vips_lv1""2000" )
gCvarsCVAR_VIPS_LV2 ] = register_cvar"disp_vips_lv2""2000" )
gCvarsCVAR_VIPS_LV3 ] = register_cvar"disp_vips_lv3""2000" );
gCvarsCVAR_VIPS_LV4 ] = register_cvar"disp_vips_lv4""8000" ); 
yagami is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:42.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode