Code:
#include <amxmodx>
#include <amxmisc>
public plugin_init()
{
register_plugin("DeathPlugin", "0.01", "W33ck4")
register_event("DeathMsg", "EventDeath", "b")
}
public EventDeath(id)
{
new victim = read_data(2)
user_drop_money(victim)
return PLUGIN_HANDLED
}
public user_drop_money(id)
{
new origin[3], authid[32], query[256], wallet, Float:forigin[3]
get_user_origin(id,origin)
get_user_authid(id,authid,31)
format(query,255,"SELECT wallet FROM money")
result = dbi_query( dbc, query)
if( dbi_nextrow( result ) <= 0 ) {
dbi_free_result(result)
return PLUGIN_HANDLED
}
wallet = dbi_field(result,1)
dbi_free_result(result)
new amount = wallet
new ent = create_entity("info_target")
if(!ent) return PLUGIN_HANDLED
IVecFVec(origin,forigin)
new Float:minbox[3] = { -2.5, -2.5, -2.5 }
new Float:maxbox[3] = { 2.5, 2.5, -2.5 }
new Float:angles[3] = { 0.0, 0.0, 0.0 }
angles[1] = float(random_num(0,270))
entity_set_vector(ent,EV_VEC_mins,minbox)
entity_set_vector(ent,EV_VEC_maxs,maxbox)
entity_set_vector(ent,EV_VEC_angles,angles)
entity_set_int(ent,EV_INT_solid,SOLID_TRIGGER)
entity_set_int(ent,EV_INT_movetype,MOVETYPE_TOSS)
new moneystr[32]
num_to_str(amount,moneystr,31)
entity_set_string(ent,EV_SZ_targetname,moneystr)
entity_set_string(ent,EV_SZ_classname,"money_pile")
entity_set_model(ent,"models/hwrp/money.mdl")
entity_set_origin(ent,forigin)
g_delay_ent[id] = 2
edit_value(id,"money","wallet","-",amount)
client_print(id,print_chat,"[EconomyMod] You dropped $%i on the ground",amount)
return PLUGIN_HANDLED
}
I think this should work... And I guess it would be more intresting, that money amount would be equal to money which player had before death. Also, that dead player's money could be set to 0