Esempio n. 1
0
const char *CClassInterface::FindEntityNetClass(int start, const char *classname)
{
	edict_t *current;

	for (int i = ((start != -1) ? start : 0); i < gpGlobals->maxEntities; i++)
	{
		current = engine->PEntityOfEntIndex(i);
		if (current == NULL)
		{
			continue;
		}

		IServerNetworkable *network = current->GetNetworkable();

		if (network == NULL)
		{
			continue;
		}

		if (strcmp(current->GetClassName(), classname) == 0)
		{
			ServerClass *sClass = network->GetServerClass();
			
			return sClass->GetName();
		
		}
	}

	return NULL;
}
Esempio n. 2
0
int FindEntityByNetClass(int start, const char *classname)
{
	edict_t *current;

	for (int i = ((start != -1) ? start : 0); i < gpGlobals->maxEntities; i++)
	{
		current = engine->PEntityOfEntIndex(i);
		if (current == NULL || current->IsFree())
		{
			continue;
		}

		IServerNetworkable *network = current->GetNetworkable();

		if (network == NULL)
		{
			continue;
		}

		ServerClass *sClass = network->GetServerClass();
		const char *name = sClass->GetName();
		

		if (strcmp(name, classname) == 0)
		{
			return i;
		}
	}

	return -1;
}
Esempio n. 3
0
void UTIL_FindServerClassnamePrint(const char *name_cmd)
{
	edict_t *current;

	for (int i = 0; i < gpGlobals->maxEntities; i++)
	{
		current = engine->PEntityOfEntIndex(i);
		if (current == NULL)
		{
			continue;
		}

		IServerNetworkable *network = current->GetNetworkable();

		if (network == NULL)
		{
			continue;
		}

		ServerClass *sClass = network->GetServerClass();
		const char *name = sClass->GetName();
		

		if (strcmp(name, name_cmd) == 0)
		{
			CBotGlobals::botMessage(NULL,0,"%s",current->GetClassName());
			return;
		}
	}

	CBotGlobals::botMessage(NULL,0,"Not found");
}
int CSizzPluginContext::GetEntityByClassName( const char *name, edict_t *out[], int max_out )
{
	int cur_ents = 0;
	if (name && out)
	{
		int max_ents = m_pGlobals->maxEntities;
		for (int i = 0; ((i < max_ents) && (cur_ents < max_out)); ++i)
		{
			edict_t *pEdict = EdictFromEntIndex(i);
			if (pEdict && !pEdict->IsFree())
			{
				IServerNetworkable *pNetworkable = pEdict->GetNetworkable();
				if (pNetworkable)
				{
					ServerClass *pServerClass = pNetworkable->GetServerClass();
					if (pServerClass && SCHelpers::FStrEq(pServerClass->GetName(), name))
					{
						out[cur_ents++] = pEdict;
					}
				}
			}
		}
	}
	return cur_ents;
}
Esempio n. 5
0
// http://svn.alliedmods.net/viewvc.cgi/trunk/extensions/tf2/extension.cpp?revision=2183&root=sourcemod&pathrev=2183
edict_t *CClassInterface::FindEntityByNetClass(int start, const char *classname)
{
	edict_t *current;

	for (register short int i = 0; i < MAX_ENTITIES; i++)
	{
		current = engine->PEntityOfEntIndex(i);
		if (current == NULL)
		{
			continue;
		}

		IServerNetworkable *network = current->GetNetworkable();

		if (network == NULL)
		{
			continue;
		}

		ServerClass *sClass = network->GetServerClass();
		const char *name = sClass->GetName();


		if (strcmp(name, classname) == 0)
		{
			return current;
		}
	}

	return NULL;
}
Esempio n. 6
0
const char *CClassInterface::FindEntityNetClass(int start, const char *classname)
{
	edict_t *current;

	for (register short int i = 0; i < MAX_ENTITIES; i++)
	{
		current = INDEXENT(i);
		if (current == NULL)
		{
			continue;
		}

		IServerNetworkable *network = current->GetNetworkable();

		if (network == NULL)
		{
			continue;
		}

		if (strcmp(current->GetClassName(), classname) == 0)
		{
			ServerClass *sClass = network->GetServerClass();

			return sClass->GetName();

		}
	}

	return NULL;
}
Esempio n. 7
0
void UTIL_FindServerClassnamePrint(const char *name_cmd)
{
	edict_t *current;

	register short int maxEnts = (short int)MAX_ENTITIES;
	for (register short int i = 0; i < maxEnts; i++)
	{
		current = INDEXENT(i);
		if (current == NULL)
		{
			continue;
		}

		IServerNetworkable *network = current->GetNetworkable();

		if (network == NULL)
		{
			continue;
		}

		ServerClass *sClass = network->GetServerClass();
		const char *name = sClass->GetName();


		if (strcmp(name, name_cmd) == 0)
		{
			CBotGlobals::BotMessage(NULL, 0, "%s", current->GetClassName());
			return;
		}
	}

	CBotGlobals::BotMessage(NULL, 0, "Not found");
}
Esempio n. 8
0
edict_t *CClassInterface::FindEntityByNetClassNearest(Vector vstart, const char *classname)
{
	edict_t *current;
	edict_t *pfound = NULL;
	float fMindist = 8192.0f;
	float fDist;

	for (short int i = 0; i < gpGlobals->maxEntities; i++)
	{
		current = engine->PEntityOfEntIndex(i);
		if (current == NULL)
		{
			continue;
		}
		if ( current->IsFree() )
			continue;
		if ( current->GetUnknown() == NULL )
			continue;
		
		IServerNetworkable *network = current->GetNetworkable();

		if (network == NULL)
		{
			continue;
		}

		ServerClass *sClass = network->GetServerClass();
		const char *name = sClass->GetName();
		
		if (strcmp(name, classname) == 0)
		{
			fDist = (vstart - CBotGlobals::entityOrigin(current)).Length();

			if ( !pfound  || (fDist < fMindist))
			{
				fMindist = fDist;
				pfound = current;
			}
		}
	}

	return pfound;
}
//-----------------------------------------------------------------------------
// Converts a user id to a collideable + username
//-----------------------------------------------------------------------------
void CEngineTraceServer::HandleEntityToCollideable( IHandleEntity *pHandleEntity, ICollideable **ppCollide, const char **ppDebugName )
{
	*ppCollide = StaticPropMgr()->GetStaticProp( pHandleEntity );
	if ( *ppCollide	)
	{
		*ppDebugName = "static prop";
		return;
	}

	IServerNetworkable *pServerNetworkable = static_cast<IServerNetworkable*>(pHandleEntity);
	if ( !pServerNetworkable )
	{
		*ppCollide = NULL;
		*ppDebugName = "<null>";
		return;
	}

	edict_t *pEdict = pServerNetworkable->GetEdict();
	Assert( pEdict );
	*ppCollide = pEdict->GetCollideable();
	*ppDebugName = pServerNetworkable->GetServerClass()->GetName();
}
Esempio n. 10
0
static CBaseEntity *FindEntityByNetClass(int start, const char *classname)
{
	int maxEntities = gpGlobals->maxEntities;
	for (int i = start; i < maxEntities; i++)
	{
		edict_t *current = gamehelpers->EdictOfIndex(i);
		if (current == NULL || current->IsFree())
			continue;

		IServerNetworkable *network = current->GetNetworkable();
		if (network == NULL)
			continue;

		ServerClass *sClass = network->GetServerClass();
		const char *name = sClass->GetName();

		if (!strcmp(name, classname))
			return gamehelpers->ReferenceToEntity(gamehelpers->IndexOfEdict(current));		
	}

	return NULL;
}
edict_t *CSizzPluginContext::GetEntityByClassName( const char *name, int start_ent /*= 0*/ )
{
	if (name)
	{
		int max_ents = m_pGlobals->maxEntities;
		for (int i = start_ent; i < max_ents; ++i)
		{
			edict_t *pEdict = EdictFromEntIndex(i);
			if (pEdict && !pEdict->IsFree())
			{
				IServerNetworkable *pNetworkable = pEdict->GetNetworkable();
				if (pNetworkable)
				{
					ServerClass *pServerClass = pNetworkable->GetServerClass();
					if (pServerClass && SCHelpers::FStrEq(pServerClass->GetName(), name))
					{
						return pEdict;
					}
				}
			}
		}
	}
	return nullptr;
}