View Single Post
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