This tutorial will give you much more detailed and useful information, such as checking if the origin is open and allowing you to scan continuously:
http://forums.alliedmods.net/showthread.php?t=49829
Here's some code that I wrote a while ago but which I didn't include in that tutorial:
PHP Code:
public SetRandomLocation(id,Num)
{
if(Num++ > 20)
return 0
new Float:pOrigin[3]
for(new Count;Count < 3;Count++)
// random_float seems to be broken, I dunno if it's just me
pOrigin[Count] = float(random_num(-floatround(MAP_MAX),floatround(MAP_MAX)))
new Float:Result[3],Float:End[3]
End = pOrigin
End[2] = -8000.0
engfunc(EngFunc_TraceLine,pOrigin,End,1,-1,0)
get_tr2(0,TR_vecEndPos,Result)
Result[2] += 36.1
if(EF_PointContents(Result) != CONTENTS_EMPTY)
{
new Retn = SetRandomLocation(id,Num)
return Retn
}
new TR
engfunc(EngFunc_TraceHull,Result,Result,0,HULL_HUMAN,0,TR)
if(get_tr2(TR,TraceResult:TR_StartSolid) || get_tr2(TR,TraceResult:TR_AllSolid) || !get_tr2(TR,TraceResult:TR_InOpen))
{
new Retn = SetRandomLocation(id,Num)
return Retn
}
new Ent,Classname[33]
while((Ent = engfunc(EngFunc_FindEntityInSphere,Ent,Result,25.0)) != 0)
{
pev(Ent,pev_classname,Classname,32)
if(containi(Classname,"trigger_") != -1 || containi(Classname,"func_") != -1)
{
new Retn = SetRandomLocation(id,Num)
return Retn
}
}
engfunc(EngFunc_SetOrigin,id,Result)
return PLUGIN_HANDLED
}
public CheckLocation(id)
{
new Flags = entity_get_int(id,EV_INT_flags),Num
if(Flags & FL_INWATER || Flags & FL_SWIM || Flags & FL_FLOAT)
SetRandomLocation(id,Num)
}
__________________