I made a plugin can drop money when user's weapon is knife !
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <chatcolor>
#define PLUGIN_NAME "Drop Money"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "K.K.Lv"
new bool:pickup[33]
new pMoneydrop, pMoneycount, pMaxmoney
new iDropcount, iEnt
new iMoneymodel[] = "models/money/Lvmoney.mdl"
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_logevent("New_round", 2, "1=Round_Start")
register_touch("MoneyDrop", "player", "hook_touch")
register_clcmd("drop", "hookdrop")
pMoneydrop = register_cvar("money_drop", "1")
pMoneycount = register_cvar("money_count", "5000")
pMaxmoney = register_cvar("amx_maxmoney", "9999999")
}
public plugin_precache()
{
precache_model(iMoneymodel)
}
public hookdrop(id)
{
if ((get_user_weapon(id) == CSW_KNIFE) && get_pcvar_num(pMoneydrop))
{
new Float:velocity[3], Float:playervelocity[3], Float:origin[3], iMoneydrop = random_num(3000, 5000)
new iMoney = cs_get_user_money(id)
if (iMoney > get_pcvar_num(pMoneycount))
{
iDropcount++
cs_set_user_money(id, iMoney - iMoneydrop)
pickup[id] = false
entity_get_vector(id, EV_VEC_origin, origin)
entity_get_vector(id, EV_VEC_velocity, playervelocity)
velocity_by_aim(id, 450, velocity)
velocity[0] += playervelocity[0]
velocity[1] += playervelocity[1]
velocity[2] = 200
velocity[0] += random_float(0, 200)
velocity[1] += random_float(0, 200)
iEnt = create_entity("info_target")
entity_set_string(iEnt, EV_SZ_classname, "MoneyDrop")
entity_set_model(iEnt, iMoneymodel)
entity_set_origin(iEnt, origin)
entity_set_int(iEnt, EV_INT_solid, SOLID_TRIGGER)
entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_TOSS)
entity_set_edict(iEnt, EV_ENT_owner, id)
entity_set_float(iEnt, EV_FL_fuser1, get_gametime())
entity_set_int(iEnt, EV_INT_iuser3, iMoneydrop)
new Float:maxa[3], Float:mina[3]
maxa[0] = 15.0
maxa[1] = 15.0
maxa[2] = 15.0
mina[0] = -15.0
mina[1] = -15.0
mina[2] = -15.0
entity_set_size(iEnt, mina, maxa)
}
}
}
public New_round()
{
while((iEnt = find_ent_by_class(iEnt, "MoneyDrop")) !=0)
{
remove_entity(iEnt)
iDropcount--
}
}
public hook_touch(ptr, ptid)
{
if (is_user_alive(ptid) && cs_get_user_money(ptid) < get_pcvar_num(pMaxmoney))
{
new iMoneypick = entity_get_int(ptr, EV_INT_iuser3)
new iMoney = cs_get_user_money(ptid)
cs_set_user_money(ptid, iMoney + iMoneypick)
remove_entity(ptr)
iDropcount--
new iName[32], iMsg[128]
get_user_name(ptid, iName, charsmax(iName))
format(iMsg, charsmax(iMsg), "^x03%s ^x01pick up ^x03%d ^x01money", iName, iMoneypick)
client_print_color(0, Grey, iMsg)
}
}