Update CS:GO team score gamedata.
3 * =============================================================================
4 * SourceMod SDKTools Extension
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #include "extension.h"
34 static cell_t LockStringTables(IPluginContext *pContext, const cell_t *params)
36 bool lock = params[1] ? true : false;
38 return engine->LockNetworkStringTables(lock) ? 1 : 0;
41 static cell_t FindStringTable(IPluginContext *pContext, const cell_t *params)
44 pContext->LocalToString(params[1], &name);
46 INetworkStringTable *pTable = netstringtables->FindTable(name);
50 return INVALID_STRING_TABLE;
53 return pTable->GetTableId();
56 static cell_t GetNumStringTables(IPluginContext *pContext, const cell_t *params)
58 return netstringtables->GetNumTables();
61 static cell_t GetStringTableNumStrings(IPluginContext *pContext, const cell_t *params)
63 TABLEID idx = static_cast<TABLEID>(params[1]);
64 INetworkStringTable *pTable = netstringtables->GetTable(idx);
68 return pContext->ThrowNativeError("Invalid string table index %d", idx);
71 return pTable->GetNumStrings();
74 static cell_t GetStringTableMaxStrings(IPluginContext *pContext, const cell_t *params)
76 TABLEID idx = static_cast<TABLEID>(params[1]);
77 INetworkStringTable *pTable = netstringtables->GetTable(idx);
81 return pContext->ThrowNativeError("Invalid string table index %d", idx);
84 return pTable->GetMaxStrings();
87 static cell_t GetStringTableName(IPluginContext *pContext, const cell_t *params)
89 TABLEID idx = static_cast<TABLEID>(params[1]);
90 INetworkStringTable *pTable = netstringtables->GetTable(idx);
95 return pContext->ThrowNativeError("Invalid string table index %d", idx);
98 pContext->StringToLocalUTF8(params[2], params[3], pTable->GetTableName(), &numBytes);
103 static cell_t FindStringIndex(IPluginContext *pContext, const cell_t *params)
105 TABLEID idx = static_cast<TABLEID>(params[1]);
106 INetworkStringTable *pTable = netstringtables->GetTable(idx);
111 return pContext->ThrowNativeError("Invalid string table index %d", idx);
114 pContext->LocalToString(params[2], &str);
116 return pTable->FindStringIndex(str);
119 static cell_t ReadStringTable(IPluginContext *pContext, const cell_t *params)
121 TABLEID idx = static_cast<TABLEID>(params[1]);
122 INetworkStringTable *pTable = netstringtables->GetTable(idx);
129 return pContext->ThrowNativeError("Invalid string table index %d", idx);
132 stringidx = params[2];
133 #if SOURCE_ENGINE == SE_DOTA
134 value = pTable->GetString(stringidx, false);
136 value = pTable->GetString(stringidx);
141 return pContext->ThrowNativeError("Invalid string index specified for table (index %d) (table \"%s\")", stringidx, pTable->GetTableName());
144 pContext->StringToLocalUTF8(params[3], params[4], value, &numBytes);
149 static cell_t GetStringTableDataLength(IPluginContext *pContext, const cell_t *params)
151 TABLEID idx = static_cast<TABLEID>(params[1]);
152 INetworkStringTable *pTable = netstringtables->GetTable(idx);
154 const void *userdata;
159 return pContext->ThrowNativeError("Invalid string table index %d", idx);
162 stringidx = params[2];
163 if (stringidx < 0 || stringidx >= pTable->GetNumStrings())
165 return pContext->ThrowNativeError("Invalid string index specified for table (index %d) (table \"%s\")", stringidx, pTable->GetTableName());
168 userdata = pTable->GetStringUserData(stringidx, &datalen);
177 static cell_t GetStringTableData(IPluginContext *pContext, const cell_t *params)
179 TABLEID idx = static_cast<TABLEID>(params[1]);
180 INetworkStringTable *pTable = netstringtables->GetTable(idx);
182 const char *userdata;
188 return pContext->ThrowNativeError("Invalid string table index %d", idx);
191 stringidx = params[2];
192 if (stringidx < 0 || stringidx >= pTable->GetNumStrings())
194 return pContext->ThrowNativeError("Invalid string index specified for table (index %d) (table \"%s\")", stringidx, pTable->GetTableName());
197 userdata = (const char *)pTable->GetStringUserData(stringidx, &datalen);
203 pContext->StringToLocalUTF8(params[3], params[4], userdata, &numBytes);
208 static cell_t SetStringTableData(IPluginContext *pContext, const cell_t *params)
210 TABLEID idx = static_cast<TABLEID>(params[1]);
211 INetworkStringTable *pTable = netstringtables->GetTable(idx);
217 return pContext->ThrowNativeError("Invalid string table index %d", idx);
220 stringidx = params[2];
221 if (stringidx < 0 || stringidx >= pTable->GetNumStrings())
223 return pContext->ThrowNativeError("Invalid string index specified for table (index %d) (table \"%s\")", stringidx, pTable->GetTableName());
226 pContext->LocalToString(params[3], &userdata);
227 pTable->SetStringUserData(stringidx, params[4], userdata);
232 static cell_t AddToStringTable(IPluginContext *pContext, const cell_t *params)
234 TABLEID idx = static_cast<TABLEID>(params[1]);
235 INetworkStringTable *pTable = netstringtables->GetTable(idx);
236 char *str, *userdata;
240 return pContext->ThrowNativeError("Invalid string table index %d", idx);
243 pContext->LocalToString(params[2], &str);
244 pContext->LocalToString(params[3], &userdata);
246 #if SOURCE_ENGINE >= SE_ORANGEBOX
247 pTable->AddString(true, str, params[4], userdata);
249 pTable->AddString(str, params[4], userdata);
255 sp_nativeinfo_t g_StringTableNatives[] =
257 {"LockStringTables", LockStringTables},
258 {"FindStringTable", FindStringTable},
259 {"GetNumStringTables", GetNumStringTables},
260 {"GetStringTableNumStrings", GetStringTableNumStrings},
261 {"GetStringTableMaxStrings", GetStringTableMaxStrings},
262 {"GetStringTableName", GetStringTableName},
263 {"FindStringIndex", FindStringIndex},
264 {"ReadStringTable", ReadStringTable},
265 {"GetStringTableDataLength", GetStringTableDataLength},
266 {"GetStringTableData", GetStringTableData},
267 {"SetStringTableData", SetStringTableData},
268 {"AddToStringTable", AddToStringTable},