/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <engine>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta_util>
#define BOXMODEL "models/hl2box.mdl"
#define BOXSOUND "debris/bustcrate1.wav"
#define BOXBLOCK "fvox/bell.wav"
#define PLUGIN "HL2 boxes"
#define VERSION "1.0"
#define AUTHOR "MaHu"
new cvar_cost
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /box","box");
register_clcmd("say_team /box","box");
register_clcmd("say /doboz","box");
register_clcmd("say_team /doboz","box");
cvar_cost = register_cvar("box_cost","5000");
RegisterHam(Ham_TakeDamage, "func_breakable", "fwdBreakableTakeDamage", 1)
}
public plugin_precache(){
precache_model(BOXMODEL)
precache_model("models/woodgibs.mdl")
precache_sound("debris/bustcrate1.wav")
precache_sound("debris/bustcrate2.wav")
precache_sound("debris/bustcrate3.wav")
precache_sound("debris/bustglass2.wav")
precache_sound(BOXSOUND)
precache_sound(BOXBLOCK)
}
public box(id,ent){
if(cs_get_user_money(id) < get_pcvar_num(cvar_cost)){
client_print(id,print_chat,"you need $%d to use box",get_pcvar_num(cvar_cost))
emit_sound(id, CHAN_ITEM, BOXBLOCK, 1.0, ATTN_NORM, 0, PITCH_NORM)
return
}
new bablo = cs_get_user_money(id)
new Float:fVelocity[3], Float:fOrigin[3]
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_breakable"))
fm_set_kvd(ent, "material", "1", "func_breakable")
dllfunc(DLLFunc_Spawn, ent)
emit_sound(id, CHAN_ITEM, BOXSOUND, 1.0, ATTN_NORM, 0, PITCH_NORM)
cs_set_user_money(id,bablo - get_pcvar_num(cvar_cost))
entity_get_vector(id, EV_VEC_origin, fOrigin)
VelocityByAim(id, 34, fVelocity)
fOrigin[0] += fVelocity[0]
fOrigin[1] += fVelocity[1]
VelocityByAim(id, 300, fVelocity)
entity_set_string(ent, EV_SZ_classname, "hl2box")
entity_set_model(ent, BOXMODEL)
entity_set_size(ent, Float:{ -10.0, -10.0, 0.0 }, Float:{ 10.0, 10.0, 25.0 })
entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_vector(ent, EV_VEC_origin, fOrigin)
entity_set_float(ent, EV_FL_health, 200.0)
entity_set_float(ent, EV_FL_takedamage, DAMAGE_AIM)
entity_set_int(ent, EV_INT_solid, SOLID_BBOX)
entity_set_int(ent, EV_INT_sequence, 0)
entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.01)
drop_to_floor(ent)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
*/