remove_entity
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(id, pev_flags) & FL_ONGROUND)) { client_print_color(id, print_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(id, print_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(id, print_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 iMoney; iMoney = cs_get_user_money(id) static iPriceDisp; iPriceDisp = get_pcvar_num(g_Cvar[CVAR_LVL1_PRICE])
if(iMoney < iPriceDisp) { client_print_color(id, print_team_default, "%s ^3You don't 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 ^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(id, 100.0, fOrigin)
if(xCreateDispanser(fOrigin, id)) { client_print_color(id, print_team_default, "%s ^4Dispenser ^3planted!", 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 ^3You don't have any ^4Dispenser ^3to be destroyed.", 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 ^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(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME) set_pev(ent, pev_nextthink, get_gametime() + 0.5) }
public BreakAllPlayerDispensers(id) { 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)) { //xLimitTeamAtt(id) xRemoveEntFix(ent) g_DispPlayerCount[id] -- } } }
|