#include <amxmod>
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("Xiao J Medkit","1.0","duper/Rockell & X-man/H")
register_cvar("amx_medkit", "1")
// 掉钱捡钱的金钱数目
register_cvar("amx_money", "300")
register_event("ResetHUD", "newRound","b")
register_event("DeathMsg","deathevent","a")
}
//----------------------------------------------------------------------------------------------
public newRound()
{
new chocolate = find_ent_by_class(-1, "chocolate")
while(chocolate) {
remove_entity(chocolate)
chocolate = find_ent_by_class(chocolate, "chocolate")
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public deathevent()
{
if ( !get_cvar_num("amx_medkit") )
return PLUGIN_CONTINUE
new killer = read_data(1)
new victim = read_data(2)
if ( killer != victim )
{
createChocolate(victim)
if(cs_get_user_money(victim)>=get_cvar_num("amx_money"))
{
cs_set_user_money(victim, cs_get_user_money(victim)-get_cvar_num("amx_money"))
}
else cs_set_user_money(victim, 0)
}
if(is_user_connected(victim))
cs_reset_user_model(victim)
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public createChocolate(victim)
{
new Float:vAim[3], Float:vOrigin[3]
entity_get_vector(victim, EV_VEC_origin, vOrigin)
(victim, random_num(2, 4))
vOrigin[0] += vAim[0]
vOrigin[1] += vAim[1]
vOrigin[2] += 30.0
new Float:velo[3]
velo[0] = random_float(0.1,150.0)
velo[1] = random_float(0.1,150.0)
velo[2] = random_float(0.1,150.0)+0.0
new chocolate = create_entity("info_target")
entity_set_string(chocolate, EV_SZ_classname, "xj")
entity_set_model(chocolate, "sprites/money33.spr")
entity_set_size(chocolate, Float:{-2.5, -2.5, -1.5}, Float:{2.5, 2.5, 1.5})
entity_set_int(chocolate, EV_INT_solid, 2)
entity_set_int(chocolate, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_vector(chocolate, EV_VEC_origin, vOrigin)
entity_set_vector(chocolate, EV_VEC_velocity, velo)
}
//----------------------------------------------------------------------------------------------
public plugin_precache() {
precache_model("sprites/money33.spr")
precache_sound( "misc/killChicken.wav")
}
//----------------------------------------------------------------------------------------------
public pfn_touch(ptr, ptd){
if(!is_valid_ent(ptd) || !is_valid_ent(ptr))
return PLUGIN_CONTINUE
if(!is_user_connected(ptd) || !is_user_alive(ptd))
return PLUGIN_CONTINUE
new classname[32]
entity_get_string(ptr, EV_SZ_classname, classname, 31)
if(equal(classname, "xj"))
{
cs_set_user_money(ptd, cs_get_user_money(ptd)+get_cvar_num("amx_money"))
emit_sound(ptd,CHAN_VOICE,"misc/killChicken.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_entity(ptr)
}
return PLUGIN_CONTINUE
}
public client_death(killer, victim, wpnindex, hitplace, TK)
{
if(wpnindex == CSW_C4 && is_user_connected(victim))
cs_reset_user_model(victim)
}