Thanks for your input, VEN.
I'm wondering, when should I execute that code? FM_SetOrigin?
EDIT:
I tried doing something similar on my own, checking for an entity in the sphere around the weapon that was dropped. However, it seems the weapon that was dropped is not assigned an origin until it collides with something. FM_SetOrigin is called on the dropped weapon when it hits a wall or touches the floor.
Here's what I'm doing:
Code:
public VEN_function(ent)
{
static Float:origin[3]
pev(ent, pev_origin, origin)
server_print("ent origin: %f %f %f", origin[0], origin[1], origin[2])
new x = FM_NULLENT
while ((x = engfunc(EngFunc_FindEntityInSphere, x, origin, 16.0)))
{
server_print("x: %i", x)
if (!(g_client_start_index <= x <= g_max_clients))
continue
server_print("x is valid")
static Float:v1[3], Float:v2[3]
pev(x, pev_origin, v1)
pev(x, pev_angles, v2)
server_print("x origin: %f %f %f", v1[0], v1[1] ,v1[2])
server_print("x angles: %f %f %f", v2[0], v2[1], v2[2])
engfunc(EngFunc_MakeVectors, v2)
global_get(glb_v_forward, v2)
xs_vec_mul_scalar(v2, 10.0, v2)
xs_vec_add(v1, v2, v1)
server_print("modified v1: %f %f %f", v1[0], v1[1] ,v1[2])
if (!xs_vec_equal(v1, origin))
continue
server_print("WeaponOwnerClientIndex: %d", x)
break
}
}
public forward_SetModel(ent, model[])
{
if(equal(model, "models/w_katana.mdl"))
{
VEN_function(ent)
}
return FMRES_IGNORED
}
Here is the output from my debug messages:
Code:
ent origin: 0.000000 0.000000 0.000000
x: 12
x: 13
x: 14
x: 15
x: 249
x: 250
(This is on a 10 slot server, g_client_start_index is set to 1)
__________________