Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#define PLUGIN "[ZP] Drop galinha"
#define VERSION "1.0"
#define AUTHOR "Biel-oGrande | Perfect Scrash"
new g_model[] = "models/chick.mdl"
new g_sound[] = "chicken.wav"
#define GALINHA_CLASSNAME "zp_galinha"
new cvar_amount
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_Touch, "fwdTouch")
register_logevent("round_start", 2, "1=Round_Start")
register_event("DeathMsg", "player_death", "a")
cvar_amount = register_cvar("zp_chicken_amount", "2")
}
public plugin_precache() {
precache_model(g_model)
precache_sound(g_sound)
}
public round_start() {
new ent = -1
while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", GALINHA_CLASSNAME)) != 0) {
engfunc(EngFunc_RemoveEntity, ent)
}
}
public player_death() {
new victim = read_data(2)
drop_galinha(victim)
}
public drop_galinha(id) {
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
new Float:origin[3]
pev(id, pev_origin, origin)
set_pev(ent, pev_origin, origin)
set_pev(ent, pev_classname, GALINHA_CLASSNAME)
engfunc(EngFunc_SetModel, ent, g_model)
set_pev(ent, pev_solid, SOLID_TRIGGER)
set_pev(ent, pev_movetype, MOVETYPE_TOSS)
engfunc(EngFunc_DropToFloor, ent)
set_pev(ent, pev_renderfx, kRenderFxGlowShell)
new Float:color[3]
color[0] = random_float(0.0, 255.0)
color[1] = random_float(0.0, 255.0)
color[2] = random_float(0.0, 255.0)
set_pev(ent, pev_rendercolor, color)
}
public fwdTouch(ent, id) {
if(!pev_valid(ent) || !is_user_alive(id)) return FMRES_IGNORED
new classname[32]
pev(ent, pev_classname, classname, charsmax(classname))
if(equali(classname, GALINHA_CLASSNAME)) {
emit_sound(id, CHAN_AUTO, g_sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
engfunc(EngFunc_RemoveEntity, ent)
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(cvar_amount))
client_printcolor(id, "!g[ZP]!y Voce pegou a !tGalinha Gift!y e Ganhou !t%d!y Ammo Packs.", get_pcvar_num(cvar_amount))
}
return FMRES_IGNORED
}
stock client_printcolor(const id, const input[], any:...) {
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!t", "^3")
replace_all(msg, 190, "!team2", "^0")
if(id)
players[0] = id;
else
get_players(players, count, "ch")
for (new i = 0; i < count; i++) {
if(is_user_connected(players[i])) {
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}