Try fake_touch() in engine module. Only downside is it will pick up the gun in the order that find_ent_in_sphere() identifies the entity. So if I drop a glock and deagle, and the glock is returned first when I execute the code, it will pick up the glock and ignore the deagle since I have the glock in pistol slot. You could make this smarter by identifying all nearby weapons, and prioritize which gets touched/picked up based on how good they are.
Your current code works fine for me:
PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
public plugin_init()
{
register_clcmd( "say a" , "asdas" );
}
public asdas( id )
{
new a , Float:fOrigin[ 3 ] , classname[ 32 ];
pev( id , pev_origin , fOrigin );
while((a = find_ent_in_sphere(a, fOrigin, 5000.0)) != 0)
{
if(is_user_connected(a))continue
pev(a,pev_classname,classname,charsmax(classname))
if(!equal(classname,"weaponbox"))continue
//client_print(1, print_chat, "Ent: [%i] [%s]",a, classname)
//dllfunc(DLLFunc_Touch,a,id)
fake_touch(a,id)
break;
}
}
__________________