Added replicate and notify parameters to ResetConVar() - these were already available for SetConVarX()
3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is part of the SourceMod/SourcePawn SDK. This file may only be used
8 * or modified under the Terms and Conditions of its License Agreement, which is found
9 * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins
10 * may change at any time. To view the latest information, see:
11 * http://www.sourcemod.net/license.php
16 #if defined _sdktools_stringtables_included
19 #define _sdktools_stringtables_included
21 #define INVALID_STRING_TABLE -1 /**< An invalid string table index */
22 #define INVALID_STRING_INDEX -1 /**< An invalid string index in a table */
25 * Searches for a string table.
27 * @param name Name of string table to find.
28 * @return A string table index number if found, INVALID_STRING_TABLE otherwise.
30 native FindStringTable(const String:name[]);
33 * Returns the number of string tables that currently exist.
35 * @return Number of string tables that currently exist.
37 native GetNumStringTables();
40 * Returns the number of strings that currently exist in a given string table.
42 * @param tableidx A string table index.
43 * @return Number of strings that currently exist.
44 * @error Invalid string table index.
46 native GetStringTableNumStrings(tableidx);
49 * Returns the maximum number of strings that are allowed in a given string table.
51 * @param tableidx A string table index.
52 * @return Maximum number of strings allowed.
53 * @error Invalid string table index.
55 native GetStringTableMaxStrings(tableidx);
58 * Retrieves the name of a string table.
60 * @param tableidx A string table index.
61 * @param name Buffer to store the name of the string table.
62 * @param maxlength Maximum length of string buffer.
63 * @return Number of bytes written to the buffer (UTF-8 safe).
64 * @error Invalid string table index.
66 native GetStringTableName(tableidx, String:name[], maxlength);
69 * Searches for the index of a given string in a string table.
71 * @param tableidx A string table index.
72 * @param string String to find.
73 * @return String index if found, INVALID_STRING_INDEX otherwise.
74 * @error Invalid string table index.
76 native FindStringIndex(tableidx, const String:str[]);
79 * Retrieves the string at a given index of a string table.
81 * @param tableidx A string table index.
82 * @param stringidx A string index.
83 * @param name Buffer to store the string value.
84 * @param maxlength Maximum length of string buffer.
85 * @return Number of bytes written to the buffer (UTF-8 safe).
86 * @error Invalid string table index or string index.
88 native ReadStringTable(tableidx, stringIdx, String:str[], maxlength);
91 * Returns the length of the user data associated with a given string index.
93 * @param tableidx A string table index.
94 * @param stringidx A string index.
95 * @return Length of user data. This will be 0 if there is no user data.
96 * @error Invalid string table index or string index.
98 native GetStringTableDataLength(tableidx, stringidx);
101 * Retrieves the user data associated with a given string index.
103 * @param tableidx A string table index.
104 * @param stringidx A string index.
105 * @param userdata Buffer to store the user data. This will be set to "" if there is no user data.
106 * @param maxlength Maximum length of string buffer.
107 * @return Number of bytes written to the buffer (UTF-8 safe).
108 * @error Invalid string table index or string index.
110 native GetStringTableData(tableidx, stringIdx, String:userdata[], maxlength);
113 * Sets the user data associated with a given string index.
115 * @param tableidx A string table index.
116 * @param stringidx A string index.
117 * @param userdata User data string that will be set.
118 * @param length Length of user data string. This should include the null terminator.
119 * @return Number of bytes written to the buffer (UTF-8 safe).
120 * @error Invalid string table index or string index.
122 native SetStringTableData(tableidx, stringIdx, const String:userdata[], length);
125 * Adds a string to a given string table.
127 * @param tableidx A string table index.
128 * @param string String to add.
129 * @param userdata An optional user data string.
130 * @param length Length of user data string. This should include the null terminator.
131 * If set to -1, then user data will be not be altered if the specified string
132 * already exists in the string table.
134 native AddToStringTable(tableidx, const String:str[], const String:userdata[]="", length=-1);
137 * Locks or unlocks the network string tables.
139 * @param lock Determines whether network string tables should be locked.
140 * True means the tables should be locked for writing; false means unlocked.
141 * @return Previous lock state.
143 native bool:LockStringTables(bool:lock);
146 * Adds a file to the downloadables network string table.
147 * This forces a client to download the file if they do not already have it.
149 * @param filename File that will be added to downloadables table.
151 stock AddFileToDownloadsTable(const String:filename[])
153 static table = INVALID_STRING_TABLE;
155 if (table == INVALID_STRING_TABLE)
157 table = FindStringTable("downloadables");
160 new bool:save = LockStringTables(false);
161 AddToStringTable(table, filename);
162 LockStringTables(save);