Hello, I want to emulate a "weaponbox" drop, (like when you press the G key when holding a weapon) using a particular item.
I tried to emulate the drop function in HLSDK but I'm not good with vectors.
This is the code I tried so far.
Code:
public drop_jp(id)
{
if(g_bHasJP[id])
{
if(pev_valid(g_iWClientJP[id]))
engfunc(EngFunc_RemoveEntity, g_iWClientJP[id]);
new Float:fOrigin[3], Float:fNewOrigin[3];
new jp = create_entity("item_security");
pev(id, pev_origin, fOrigin);
global_get(glb_v_forward, fNewOrigin);
xs_vec_mul_scalar(fNewOrigin, 300.0, fNewOrigin);
xs_vec_add(fOrigin, fNewOrigin, fOrigin);
set_pev(jp, pev_origin, fOrigin);
set_pev(jp, pev_velocity, fNewOrigin)
convertToJetpack(jp)
//DispatchKeyValue(jp, "spawnflags", "384");
DispatchSpawn(jp);
}
g_bHasJP[id] = false;
return PLUGIN_HANDLED;
}
It works, but the item just pops out near player instead of dropping it like a normal weapon.
How can I achieve this?
__________________