diff --git a/extensions/sdktools/teamnatives.cpp b/extensions/sdktools/teamnatives.cpp index d918d1ba..6334ca5e 100644 --- a/extensions/sdktools/teamnatives.cpp +++ b/extensions/sdktools/teamnatives.cpp @@ -219,6 +219,17 @@ static cell_t GetTeamClientCount(IPluginContext *pContext, const cell_t *params) return fn(g_Teams[teamindex].pEnt, 0); } +static cell_t GetTeamEntity(IPluginContext *pContext, const cell_t *params) +{ + int teamindex = params[1]; + if (teamindex >= (int)g_Teams.size() || !g_Teams[teamindex].ClassName) + { + return pContext->ThrowNativeError("Team index %d is invalid", teamindex); + } + + return gamehelpers->EntityToBCompatRef(g_Teams[teamindex].pEnt); +} + sp_nativeinfo_t g_TeamNatives[] = { {"GetTeamCount", GetTeamCount}, @@ -226,5 +237,6 @@ sp_nativeinfo_t g_TeamNatives[] = {"GetTeamScore", GetTeamScore}, {"SetTeamScore", SetTeamScore}, {"GetTeamClientCount", GetTeamClientCount}, + {"GetTeamEntity", GetTeamEntity}, {NULL, NULL} }; diff --git a/plugins/include/sdktools_functions.inc b/plugins/include/sdktools_functions.inc index 63d3d1be..ee819dfd 100644 --- a/plugins/include/sdktools_functions.inc +++ b/plugins/include/sdktools_functions.inc @@ -259,6 +259,15 @@ native SetTeamScore(index, value); */ native GetTeamClientCount(index); +/** + * Returns the entity index of a team. + * + * @param teamIndex Team index. + * @return Entity index of team. + * @error Invalid team index. + */ +native int GetTeamEntity(int teamIndex); + /** * Sets the model to a given entity. *