PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <zp50_core>
#include <zp50_items>
#define PLUGIN "[ZP] Drop SupplyBox"
#define VERSION "1.0"
#define AUTHOR "Biel-oGrande"
#define Prefix "AddonsZM"
new g_sprite
new g_ItemZombieMadnessID
new g_model[] = "models/zombie_plague/w_supplybox.mdl"
new g_sound[] = "zombie_plague/supplybox_pickup.wav"
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")
}
public plugin_precache() {
precache_model(g_model)
precache_sound(g_sound)
g_sprite = precache_model("sprites/icon_supplybox.spr")
}
plugin_cfg()
{
g_ItemZombieMadnessID = zp_items_get_id("Zombie Madness")
}
public round_start() {
new ent = -1
while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "supplybox")) != 0) {
engfunc(EngFunc_RemoveEntity, ent)
remove_task(ent)
}
}
public player_death() {
new victim = read_data(2)
if(random_num(0, 1) == 0) {
drop_supplybox(victim)
}
return PLUGIN_CONTINUE
}
public drop_supplybox(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, "supplybox")
engfunc(EngFunc_SetModel, ent, g_model)
set_pev(ent, pev_solid, SOLID_TRIGGER)
set_pev(ent, pev_movetype, MOVETYPE_NOCLIP)
engfunc(EngFunc_DropToFloor, ent)
set_pev(ent, pev_renderfx, kRenderFxGlowShell)
set_pev(ent, pev_rendercolor, Float:{0.0,0.0,200.0})
set_pev(ent, pev_avelocity,Float:{0.0,50.0,0.0})
set_task(0.1, "icon_light", ent, _, _, "b")
}
public icon_light(ent) {
static Float:origin[3]
pev(ent, pev_origin, origin)
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
write_byte(TE_SPRITE)
engfunc(EngFunc_WriteCoord, origin[0])
engfunc(EngFunc_WriteCoord, origin[1])
engfunc(EngFunc_WriteCoord, origin[2] + 40.0)
write_short(g_sprite)
write_byte(2)
write_byte(100)
message_end()
engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, origin, 0)
write_byte(TE_DLIGHT)
engfunc(EngFunc_WriteCoord, origin[0])
engfunc(EngFunc_WriteCoord, origin[1])
engfunc(EngFunc_WriteCoord, origin[2])
write_byte(5)
write_byte(100)
write_byte(100)
write_byte(100)
write_byte(2)
write_byte(0)
message_end()
}
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, "supplybox")) {
emit_sound(id, CHAN_AUTO, g_sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
engfunc(EngFunc_RemoveEntity, ent)
remove_task(ent)
if(zp_core_is_zombie(id))
zombie_item(id)
else
human_item(id)
}
return FMRES_IGNORED
}
public human_item(id) {
new szName[32]
get_user_name(id, szName, 31)
switch (random_num(0, 10)) {
case 0..3: {
client_print_color(0, "!g[%s] !y%s !tYou Took the SupplyBox and not won anything.",Prefix, szName)
}
case 4..6: {
client_print_color(0, "!g[%s] !y%s !tYou took the SupplyBox and won !y2 !gAmmoPacks.",Prefix, szName)
zp_ammopacks_set(id, zp_ammopacks_get(id) + 2)
}
case 7, 8: {
client_print_color(0, "!g[%s] !y%s !tYou took the SupplyBox and won !ynightvision.",Prefix, szName)
cs_set_user_nvg(id, 1)
client_cmd(id, "nightvision")
}
case 9: {
client_print_color(0, "!g[%s] !y%s !tYou took the SupplyBox and won !y25 !gof health.",Prefix, szName)
set_user_health(id, get_user_health(id) + 25)
}
case 10: {
client_print_color(0, "!g[%s] !y%s !tYou took the SupplyBox and won !y10 !garmor.",Prefix, szName)
set_user_armor(id, get_user_armor(id) + 10)
}
}
}
public zombie_item(id) {
new szName[32]
get_user_name(id, szName, 31)
switch (random_num(0, 9)) {
case 0..3: {
client_print_color(0, "!g[%s] !y%s !tYou Took the SupplyBox and not won anything.",Prefix, szName)
}
case 4..6: {
client_print_color(0, "!g[%s] !y%s !tYou took the SupplyBox and won !y2 !gAmmoPacks.",Prefix, szName)
zp_ammopacks_set(id, zp_ammopacks_get(id) + 2)
}
case 7, 8: {
client_print_color(0, "!g[%s] !y%s !tYou took the SupplyBox and won !y300 !gof health.",Prefix, szName)
set_user_health(id, get_user_health(id) + 300)
}
case 9: {
client_print_color(0, "!g[%s] !y%s !tYou took the SupplyBox and won !yzombie madness.",Prefix, szName)
zp_items_force_buy(id, g_ItemZombieMadnessID, true)
}
}
}
stock client_print_color(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();
}
}
}