Run
GetBomsitesIndexes() only after the first player connected to the server (
OnClientConnected for example).
Thanks to
Usurpus for allowing to publish this private code.
PHP Code:
new g_BombsiteA = -1;
new g_BombsiteB = -1;
GetBomsitesIndexes()
{
new index = -1;
new Float:vecBombsiteCenterA[3];
new Float:vecBombsiteCenterB[3];
index = FindEntityByClassname(index, "cs_player_manager");
if (index != -1)
{
GetEntPropVector(index, Prop_Send, "m_bombsiteCenterA", vecBombsiteCenterA);
GetEntPropVector(index, Prop_Send, "m_bombsiteCenterB", vecBombsiteCenterB);
}
index = -1;
while ((index = FindEntityByClassname(index, "func_bomb_target")) != -1)
{
new Float:vecBombsiteMin[3];
new Float:vecBombsiteMax[3];
GetEntPropVector(index, Prop_Send, "m_vecMins", vecBombsiteMin);
GetEntPropVector(index, Prop_Send, "m_vecMaxs", vecBombsiteMax);
if (IsVecBetween(vecBombsiteCenterA, vecBombsiteMin, vecBombsiteMax))
{
g_BombsiteA = index;
}
else if (IsVecBetween(vecBombsiteCenterB, vecBombsiteMin, vecBombsiteMax))
{
g_BombsiteB = index;
}
}
}
stock bool:IsVecBetween(const Float:vecVector[3], const Float:vecMin[3], const Float:vecMax[3])
{
return ( (vecMin[0] <= vecVector[0] <= vecMax[0]) &&
(vecMin[1] <= vecVector[1] <= vecMax[1]) &&
(vecMin[2] <= vecVector[2] <= vecMax[2]) );
}
After running the code you will have an index for bombsite "A" inside of the global variable
g_BombsiteA and index for "B" inside of
g_BombsiteB.
__________________