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

FindByClassnameWithin()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-30-2018 , 06:36   FindByClassnameWithin()
Reply With Quote #1

Question for wizards.

I was looking through CSGO VScript files and find this kind function "FindByClassnameWithin".
- Is this only for CSGO game ?
- Could this add in SourceMod or is it just waste of time, because you can do familiar function in plugin code anyway...


- And this sound stupid, but is there chance, to execute VScript functions by SourceMod ?
Or maybe creating entity and setting Vscript in there would be better option.

Code:
function ScareOtherNearbyBirds()
{
	if ( m_bIsAlerted == true )
		return;

	m_bIsAlerted = true;

	ent <- null;
	local nDistance = 128;
	while( ( ent = Entities.FindByClassnameWithin( null, "logic_script", EntityGroup[0].GetOrigin(), nDistance ) ) != null )
	{
		if ( ent && ent.GetScriptScope() )
		{
			//printl( "^^ Found ScriptScope!!!! ("+ent.GetName()+")" );
			local scope = ent.GetScriptScope();

			if ( scope.m_bIsBirdScript == true && scope.m_bIsAlerted != true )
			{
				local nRandomDelay = RandomInt(0,5);
				local flDelay = nRandomDelay/10.0;
				scope.m_bPlaySound = false;
				scope.FlyAwayAfterDelay( flDelay );
				//printl( "^^ FlyAwayAfterDelay!!!! ("+flDelay+")" );
			}
			return;
		}
	}
}
Bacardi is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-30-2018 , 07:36   Re: FindByClassnameWithin()
Reply With Quote #2

https://forums.alliedmods.net/showth...hlight=vscript
__________________
Ilusion9 is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 12-30-2018 , 08:07   Re: FindByClassnameWithin()
Reply With Quote #3

You can create an SDKCall to CGlobalEntityList::FindEntityByClassnameWithin(), provided you can get the signatures.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-30-2018 , 08:25   Re: FindByClassnameWithin()
Reply With Quote #4

Nice, thank you.
Bacardi is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 12-30-2018 , 09:43   Re: FindByClassnameWithin()
Reply With Quote #5

Personally wouldn't bother with SDKCalls or an extension just for this since you can make this stock function easily.
hmmmmm is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-30-2018 , 10:00   Re: FindByClassnameWithin()
Reply With Quote #6

True, every game update broke usually signatures and offsets
Bacardi is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 12-30-2018 , 14:16   Re: FindByClassnameWithin()
Reply With Quote #7

This is just a distance check right? Easier to just rewrite it in pawn and make it more specific to the entities you're looking for or something
Mitchell is offline
Reply



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 06:52.


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