View Single Post
hebusletroll
Senior Member
Join Date: Apr 2006
Old 09-20-2008 , 12:10   Re: [BUG - RESOLVED] Infinite loop EngFunc_FindEntityInSphere for some maps
Reply With Quote #6

It crash where the screenshot was made.

OK i will fix it by creating a Stock :

Code:
stock get_entities_near_origin(Float:origin[3],entitylist[],Float:radius)
{
	new entitycount, index, entityid
	while((entityid=engfunc(EngFunc_FindEntityInSphere,entityid,origin,radius))!=0)
	{
		for(index=0;index<entitycount;index++)
			if(entityid==entitylist[index])
				return entitycount
		entitylist[entitycount]=entityid
		entitycount+=1
	}
	return entitycount
}
You just need to create an array and use the stock like this :

Code:
new entitylist[512], victim
for(victim=0;victim<get_entities_near_origin(origin,entitylist,700.0);victim++)
{
    // Make your code here !
}
Now, it's work fine ! No more bug !

Yeah !
__________________
Boring about playing same weapons ? PowerWeapons is available !
PowerWeapon v1.0 released !
Play up to 70 new weapons and create your own weapons !
Tested on Windows Server 2003, 2008/R2, 2012 and Linux Ubuntu 10.x and CentOs 6.x

Last edited by hebusletroll; 09-20-2008 at 12:13. Reason: Updated code
hebusletroll is offline