Bom pessoal sera que alguem poderia fazer um tutorial , Limitando um Item Extra por Player , Ex : Vida Extra , 1 Player pode comprar 10k de HP Por Round
william escreveu:isso tem na sma do pluing tipo nela mesma tem um limite dependendo do pluing ai e so abaixar
Código:
#include < amxmodx >
#include < fun >
#include < zombieplague >
#include < cstrike >
new const item_name[] = "Vida extra"
new g_itemid_buyhp
new hpamount_z, hpamount_h
new g_fire
new const heal_effect[] = "cso/zm_heal.wav"
new const human_buy[] = "cso/hm_heal.wav"
public plugin_precache()
{
g_fire = precache_model("sprites/vida_sprits.spr")
precache_sound(heal_effect)
precache_sound(human_buy)
}
public plugin_init()
{
register_plugin("Vida extra", "1.0", "Extra Vida")
hpamount_z = register_cvar("zp_buyhp_zombie", "5000")
hpamount_h = register_cvar("zp_buyhp_human", "700")
g_itemid_buyhp = zp_register_extra_item(item_name,20, ZP_TEAM_HUMAN & ZP_TEAM_ZOMBIE)
}
public onHealth()
{
new victim=read_data(2)
new CsTeams:team=cs_get_user_team(victim)
if(team==CS_TEAM_T)
{
set_task(3.0,"fire",victim)
}
}
fire_zombie(origin[3])
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_SPRITE)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2]+=30)
write_short(g_fire)
write_byte(8)
write_byte(255)
message_end()
}
public fire(victim)
{
new origin[3]
get_user_origin(victim,origin)
fire_zombie(origin)
}
public zp_extra_item_selected(id,itemid)
{
if (!is_user_alive(id))
return PLUGIN_HANDLED;
if (itemid==g_itemid_buyhp)
{
if (zp_get_user_ammo_packs(id) < 5)
{
client_print(id, print_chat,"[ZP] Voce nao tem Ammo Packs Suficiente !!");
return PLUGIN_HANDLED;
}
if (zp_get_user_zombie(id))
{
set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount_z));
client_print(id, print_chat,"[ZP] Voce comprou 5.000 de HP !");
emit_sound(id, CHAN_ITEM, heal_effect, 0.6, ATTN_NORM, 0, PITCH_NORM)
fire(id);
}
if (!zp_get_user_zombie(id))
{
set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount_h));
client_print(id, print_chat,"[ZP] Voce comprou 700 de HP!");
emit_sound(id, CHAN_ITEM, human_buy, 0.6, ATTN_NORM, 0, PITCH_NORM)
}
}
return PLUGIN_CONTINUE;
}
Código:
#include < amxmodx >
#include < fun >
#include < zombieplague >
#include < cstrike >
new const item_name[] = "Vida extra"
new g_itemid_buyhp
new hpamount_z, hpamount_h, limite, limite_item[33]
new g_fire
new const heal_effect[] = "cso/zm_heal.wav"
new const human_buy[] = "cso/hm_heal.wav"
public plugin_precache()
{
g_fire = precache_model("sprites/vida_sprits.spr")
precache_sound(heal_effect)
precache_sound(human_buy)
}
public plugin_init()
{
register_plugin("Vida extra", "1.0", "Extra Vida")
hpamount_z = register_cvar("zp_buyhp_zombie", "5000")
hpamount_h = register_cvar("zp_buyhp_human", "700")
limite = register_cvar("zp_buyhp_limit", "3")
g_itemid_buyhp = zp_register_extra_item(item_name,20, ZP_TEAM_HUMAN & ZP_TEAM_ZOMBIE)
}
public onHealth()
{
new victim=read_data(2)
new CsTeams:team=cs_get_user_team(victim)
if(team==CS_TEAM_T)
{
set_task(3.0,"fire",victim)
}
}
fire_zombie(origin[3])
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_SPRITE)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2]+=30)
write_short(g_fire)
write_byte(8)
write_byte(255)
message_end()
}
public fire(victim)
{
new origin[3]
get_user_origin(victim,origin)
fire_zombie(origin)
}
public zp_extra_item_selected(id,itemid)
{
if (!is_user_alive(id))
return PLUGIN_HANDLED;
if (itemid==g_itemid_buyhp)
{
if (limite_item[id] >= limite)
{
client_print(id, print_chat,"[ZP] Limite de Compras Atingido !!");
return PLUGIN_HANDLED;
}
if (zp_get_user_zombie(id))
{
set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount_z));
client_print(id, print_chat,"[ZP] Voce comprou 5.000 de HP !");
emit_sound(id, CHAN_ITEM, heal_effect, 0.6, ATTN_NORM, 0, PITCH_NORM)
limite_item[id]++
fire(id);
}
if (!zp_get_user_zombie(id))
{
set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount_h));
client_print(id, print_chat,"[ZP] Voce comprou 700 de HP!");
emit_sound(id, CHAN_ITEM, human_buy, 0.6, ATTN_NORM, 0, PITCH_NORM)
limite_item[id]++
}
}
return PLUGIN_CONTINUE;
}
|
|