1.1 --- a/extensions/sdktools/teamnatives.cpp Mon Sep 08 06:38:10 2008 +0000
1.2 +++ b/extensions/sdktools/teamnatives.cpp Mon Sep 08 07:00:34 2008 +0000
1.3 @@ -109,6 +109,7 @@
1.4 return g_Teams.size();
1.5 }
1.6
1.7 +static int g_teamname_offset = -1;
1.8 static cell_t GetTeamName(IPluginContext *pContext, const cell_t *params)
1.9 {
1.10 int teamindex = params[1];
1.11 @@ -117,8 +118,25 @@
1.12 return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
1.13 }
1.14
1.15 - static int offset = g_pGameHelpers->FindInSendTable(g_Teams[teamindex].ClassName, "m_szTeamname")->GetOffset();
1.16 - char *name = (char *)((unsigned char *)g_Teams[teamindex].pEnt + offset);
1.17 + if (g_teamname_offset == 0)
1.18 + {
1.19 + return pContext->ThrowNativeError("Team names are not available on this game.");
1.20 + }
1.21 +
1.22 + if (g_teamname_offset == -1)
1.23 + {
1.24 + SendProp *prop = g_pGameHelpers->FindInSendTable(g_Teams[teamindex].ClassName, "m_szTeamname");
1.25 +
1.26 + if (prop == NULL)
1.27 + {
1.28 + g_teamname_offset = 0;
1.29 + return pContext->ThrowNativeError("Team names are not available on this game.");
1.30 + }
1.31 +
1.32 + g_teamname_offset = prop->GetOffset();
1.33 + }
1.34 +
1.35 + char *name = (char *)((unsigned char *)g_Teams[teamindex].pEnt + g_teamname_offset);
1.36
1.37 pContext->StringToLocalUTF8(params[2], params[3], name, NULL);
1.38