Raised This Month: $ Target: $400
 0% 

remove_entity


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
yagami
Senior Member
Join Date: Jan 2021
Old 10-23-2022 , 21:05   remove_entity
Reply With Quote #1

I have a dispenser here, I just added a cvar[CVAR_VIP_LVL1_PRICE] so now the vip are able to place two dispensers but now I don't know how to remove these dispensers
because when I try to destroy, both are removed together I wanted only one at a time

How do I remove one at a time?

PHP Code:
public xBuyDispenser(id)
{
    if(!
is_user_alive(id) && is_user_connected(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_IsVip[id])
    {
      if(
g_DispPlayerCount[id] >= get_pcvar_num(g_Cvar[CVAR_LIMIT_PER_PLAYER_VIP]))
        {
        
client_print_color(idprint_team_default"%s ^3You have already reached the limit of ^4Dispenser ^3."PREFIX_CHAT)
        
client_cmd(id"spk %s"g_DispSndFail)

        return 
PLUGIN_HANDLED
        
}
    } 
    else
    {
        if(
g_DispPlayerCount[id] >= get_pcvar_num(g_Cvar[CVAR_LIMIT_PER_PLAYER]))
        {
        
client_print_color(idprint_team_default"%s ^3You have already reached the limit of ^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 ^3Your team has reached the limit of ^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 ^3You don't have enough money! ^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 ^3You already have a ^4Dispenser ^3activated, put it on to buy more."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 ^3planted!"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 ^3You don't have any ^4Dispenser ^3to be destroyed."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 ^3You got it: ^4$: %s ^3of money for destroying your ^4Dispenser ^3Lvl: ^4%d^3."PREFIX_CHAT,
            
xAddPoint(xGiveMoney), iLevel)
            
xRemoveEntFix(ent)
        }
    }

    return 
PLUGIN_HANDLED
}

/*
public xLimitTeamAtt(id)
{
    static xMyTeam; xMyTeam = get_user_team(id)

    if(xMyTeam == 1)
        xLimitGlobal[0] --
    else
        xLimitGlobal[1] --
}*/


public xRemoveEntFix(ent)
{
    
set_pev(entpev_flagspev(entpev_flags) | FL_KILLME)
    
set_pev(entpev_nextthinkget_gametime() + 0.5)
    
}

public 
BreakAllPlayerDispensers(id)
{
    static 
entent FM_NULLENT

    
while((ent find_ent_by_class(entdispenser_classname)))
    {
        if(
pev(entDISPENSER_OWNER) != id)
            continue
        
        if(
pev_valid(ent))
        {
            
//xLimitTeamAtt(id)
            
xRemoveEntFix(ent)
            
g_DispPlayerCount[id] --
        }
    }


Last edited by yagami; 10-23-2022 at 21:57.
yagami is offline
 



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 15:33.


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