Raised This Month: $32 Target: $400
 8% 

Solved [H3LP] FindEntityInSphere


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 02-06-2019 , 05:47   [H3LP] FindEntityInSphere
Reply With Quote #1

Hello. Can someone show me how to use FindEntityInSphere using sdktools?
I want to search for entities in sphere of 100.0 by looping.
On AMXX it can be done this way:
PHP Code:
while((iEnt engfunc(EngFunc_FindEntityInSphereiEntfOrigin100.0)) != 0
Code:
"Games"
{
	"#default"
	{
		"Signatures"
		{
			"FindEntityInSphere"  // "    magnitude: %f"
                        {
                                "library"       "server"
                                "windows"       "\x55\x8B\xEC\x83\xEC\x0C\x53\x56\x8B\xF1\x8B\x4D\x08\x57"
                                "linux" "@_ZN17CGlobalEntityList18FindEntityInSphereEP11CBaseEntityRK6Vectorf"
                        }
		}
	}
}
Thanks !

Last edited by DarthMan; 02-11-2019 at 13:32. Reason: Solved
DarthMan is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 02-10-2019 , 13:26   Re: [H3LP] FindEntityInSphere
Reply With Quote #2

FindEntityByClassname + GetVectorDistance
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 02-10-2019 , 16:27   Re: [H3LP] FindEntityInSphere
Reply With Quote #3

Quote:
Originally Posted by Dragokas View Post
FindEntityByClassname + GetVectorDistance
Ye but that only finds by specific classname. And looping through entities is not a good practice anyways. For what I need now it could be enough, but I've other plugin where I wanna get all entities in given sphere.
DarthMan is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 02-11-2019 , 00:13   Re: [H3LP] FindEntityInSphere
Reply With Quote #4

I'm sure FindEntityInSphere() do the same looping. Devs will correct me if I'm wrong.

+ sm_count
https://forums.alliedmods.net/showthread.php?p=1729015

Code:
	for( int i = 0; i < 4096; i++ )
	{
		if( IsValidEntity(i) && IsValidEdict(i) )
		{
			GetEdictClassname(i, sTemp, sizeof(sTemp));
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 02-11-2019 at 00:15.
Dragokas is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 02-11-2019 , 00:24   Re: [H3LP] FindEntityInSphere
Reply With Quote #5

Quote:
Originally Posted by Dragokas View Post
I'm sure FindEntityInSphere() do the same looping. Devs will correct me if I'm wrong.

+ sm_count
https://forums.alliedmods.net/showthread.php?p=1729015

Code:
	for( int i = 0; i < 4096; i++ )
	{
		if( IsValidEntity(i) && IsValidEdict(i) )
		{
			GetEdictClassname(i, sTemp, sizeof(sTemp));
https://github.com/ValveSoftware/sou....cpp#L685-L711

It looks that way.

Also why loop 4096 times you don't need to
you only can have 2048 entities +1 for world spawn.
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 02-11-2019 , 01:10   Re: [H3LP] FindEntityInSphere
Reply With Quote #6

GetEntityCount is what I use for looping. I am unaware of any issues.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-11-2019 , 02:23   Re: [H3LP] FindEntityInSphere
Reply With Quote #7

Quote:
Originally Posted by Lux View Post
you only can have 2048 entities +1 for world spawn.
Worldspawn counts as one of the 2048 entities, specifically entity 0.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 02-11-2019 , 03:27   Re: [H3LP] FindEntityInSphere
Reply With Quote #8

Quote:
Originally Posted by Powerlord View Post
Worldspawn counts as one of the 2048 entities, specifically entity 0.
So for sphere it's a good idea to just start a loop from 1 to 2048 if I want to find all entities in a given distance, check if they are valid and get vector distance between player origin and entity origin? That's fine too, but using directly FindEntityInSphere from the server dll would be faster because it only makes 1 call, whereas using the mentioned method would make plenty of calls to the engine, each time it checks if the entity is valid and gets origin between the 2. Turns out that the signature is wrong, FF uses the 2006 sdk and I used IDA to search for that signature of bytes and it couldn't find any function. My plug-in also reported that the signature could not be found.

Last edited by DarthMan; 02-11-2019 at 03:28.
DarthMan is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 02-11-2019 , 04:20   Re: [H3LP] FindEntityInSphere
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
Worldspawn counts as one of the 2048 entities, specifically entity 0.
Yea dam thanks for pointing that out.

https://github.com/ValveSoftware/sou...ic/const.h#L65

Quote:
Originally Posted by DarthMan View Post
So for sphere it's a good idea to just start a loop from 1 to 2048 if I want to find all entities in a given distance, check if they are valid and get vector distance between player origin and entity origin? That's fine too, but using directly FindEntityInSphere from the server dll would be faster because it only makes 1 call, whereas using the mentioned method would make plenty of calls to the engine, each time it checks if the entity is valid and gets origin between the 2. Turns out that the signature is wrong, FF uses the 2006 sdk and I used IDA to search for that signature of bytes and it couldn't find any function. My plug-in also reported that the signature could not be found.
Yes sourcemod is slower but it's not that slow.

If your game is CSGO
you can use backup's extension

https://forums.alliedmods.net/showthread.php?t=304710

PHP Code:
 //Find entities within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
    //hscript FindInSphere(hscript, vector, float);
    
public static native HScript FindInSphere(HScript afloat[] bfloat c); 
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
psychonic

BAFFLED
Join Date: May 2008
Old 02-11-2019 , 11:19   Re: [H3LP] FindEntityInSphere
Reply With Quote #10

If you end up looping, it's probably faster to use FindEntityByClassname with a classname of "*". (It supports wildcarding the end of the string). That will just loop over all entities in the global entity list, rather than checking every possibly index.
psychonic is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode