Heres the problem, I cannot get this entity to appear when I execute this function. I know it spawns the item because it does not display the error message I have in here. Any suggestions on how to get this to work? I have already precached the model just for your info.
Code:
public spawn_item(itemid,amount,origin[3]) {
new targetname[64], Float:forigin[3]
formatex(targetname,63,"%i|%i",itemid,amount)
new Float:minsx[3] = { -2.5, -2.5, -2.5 }
new Float:maxsx[3] = { 2.5, 2.5, -2.5 }
new Float:angles[3] = { 0.0, 0.0, 0.0 }
forigin[0] = float(origin[0])
forigin[1] = float(origin[1])
forigin[2] = float(origin[2])
angles[1] = float(random_num(0,360))
new item = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if(!item) {
log_amx("ERROR: Item failed to spawn.")
return PLUGIN_HANDLED
}
set_pev(item,pev_targetname,targetname)
set_pev(item,pev_classname,"dropped_item")
set_pev(item,pev_mins,minsx)
set_pev(item,pev_maxs,maxsx)
set_pev(item,pev_angles,angles)
set_pev(item,pev_dmg,0.0)
set_pev(item,pev_dmg_take,0.0)
set_pev(item,pev_max_health,50000.0)
set_pev(item,pev_health,50000.0)
set_pev(item,pev_solid,SOLID_TRIGGER)
set_pev(item,pev_movetype,MOVETYPE_TOSS)
set_pev(item,pev_model,"models/roleplay/w_backpack.mdl")
set_pev(item,pev_origin,forigin)
return PLUGIN_HANDLED
}