AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Dispenser Money + Dispenser Destry (https://forums.alliedmods.net/showthread.php?t=338685)

yagami 07-20-2022 20:28

Dispenser Money + Dispenser Destry
 
Within the dispenser was crianda a new function for vip can put 2 dispenser more how do I change their value?


Code:

enum _:g_MaxCvars
{
        CVAR_VLVL1_PRICE,
        CVAR_VLVL2_PRICE,
        CVAR_VLVL3_PRICE,
        CVAR_VLVL4_PRICE,
}

PHP Code:

public xBuyDispenserid )
{
    
// is not alive, ignore
    
if ( !is_user_aliveid ) )
    {
        return 
PLUGIN_CONTINUE
    
}

    
// is not on the floor, ignore
    
if (!( pev(idpev_flags) & FL_ONGROUND))
    {
        
client_print_color(idprint_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])

    
// verifique se o 'id' é de um 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(idprint_team_default"%s ^3Voce ja atingiu o limite de ^4Dispenser ^3."PREFIX_CHAT)
        
client_cmd(id"spk %s"g_DispSndFail)

        return 
PLUGIN_HANDLED
    
}

    
// daqui para baixo não mudei nada
    
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 ^3Voce nao 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 ^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(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


Besides I can't get the destroy function dispenser to work right
it is destroying both dispensers at the same time

PHP Code:

public xDestroyDispenser(id)
{
    if(!
g_DispPlayerCount[id])
    {
        
client_print_color(idprint_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 
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 ^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




All times are GMT -4. The time now is 15:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.