1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This file is part of the SourceMod/SourcePawn SDK.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#if defined _sdktools_stringtables_included
#endinput
#endif
#define _sdktools_stringtables_included
#define INVALID_STRING_TABLE -1 /**< An invalid string table index */
#define INVALID_STRING_INDEX -1 /**< An invalid string index in a table */
/**
* Searches for a string table.
*
* @param name Name of string table to find.
* @return A string table index number if found, INVALID_STRING_TABLE otherwise.
*/
native int FindStringTable(const char[] name);
/**
* Returns the number of string tables that currently exist.
*
* @return Number of string tables that currently exist.
*/
native int GetNumStringTables();
/**
* Returns the number of strings that currently exist in a given string table.
*
* @param tableidx A string table index.
* @return Number of strings that currently exist.
* @error Invalid string table index.
*/
native int GetStringTableNumStrings(int tableidx);
/**
* Returns the maximum number of strings that are allowed in a given string table.
*
* @param tableidx A string table index.
* @return Maximum number of strings allowed.
* @error Invalid string table index.
*/
native int GetStringTableMaxStrings(int tableidx);
/**
* Retrieves the name of a string table.
*
* @param tableidx A string table index.
* @param name Buffer to store the name of the string table.
* @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid string table index.
*/
native int GetStringTableName(int tableidx, char[] name, int maxlength);
/**
* Searches for the index of a given string in a string table.
*
* @param tableidx A string table index.
* @param str String to find.
* @return String index if found, INVALID_STRING_INDEX otherwise.
* @error Invalid string table index.
*/
native int FindStringIndex(int tableidx, const char[] str);
/**
* Retrieves the string at a given index of a string table.
*
* @param tableidx A string table index.
* @param stringidx A string index.
* @param str Buffer to store the string value.
* @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (UTF-8 safe).
* @error Invalid string table index or string index.
*/
native int ReadStringTable(int tableidx, int stringidx, char[] str, int maxlength);
/**
* Returns the length of the user data associated with a given string index.
*
* @param tableidx A string table index.
* @param stringidx A string index.
* @return Length of user data. This will be 0 if there is no user data.
* @error Invalid string table index or string index.
*/
native int GetStringTableDataLength(int tableidx, int stringidx);
/**
* Retrieves the user data associated with a given string index.
*
* @param tableidx A string table index.
* @param stringidx A string index.
* @param userdata Buffer to store the user data. This will be set to "" if there is no user data
* @param maxlength Maximum length of string buffer.
* @return Number of bytes written to the buffer (binary safe, includes the null terminator).
* @error Invalid string table index or string index.
*/
native int GetStringTableData(int tableidx, int stringidx, char[] userdata, int maxlength);
/**
* Sets the user data associated with a given string index.
*
* @param tableidx A string table index.
* @param stringidx A string index.
* @param userdata User data string that will be set.
* @param length Length of user data string. This should include the null terminator.
* @error Invalid string table index or string index.
*/
native void SetStringTableData(int tableidx, int stringidx, const char[] userdata, int length);
/**
* Adds a string to a given string table.
*
* @param tableidx A string table index.
* @param str String to add.
* @param userdata An optional user data string.
* @param length Length of user data string. This should include the null terminator.
* If set to -1, then user data will be not be altered if the specified string
* already exists in the string table.
* @error Invalid string table index.
*/
native void AddToStringTable(int tableidx, const char[] str, const char[] userdata="", int length=-1);
/**
* Locks or unlocks the network string tables.
*
* @param lock Determines whether network string tables should be locked.
* True means the tables should be locked for writing; false means unlocked.
* @return Previous lock state.
*/
native bool LockStringTables(bool lock);
/**
* Adds a file to the downloadables network string table.
* This forces a client to download the file if they do not already have it.
*
* @param filename File that will be added to downloadables table.
*/
stock void AddFileToDownloadsTable(const char[] filename)
{
static int table = INVALID_STRING_TABLE;
if (table == INVALID_STRING_TABLE)
{
table = FindStringTable("downloadables");
}
bool save = LockStringTables(false);
AddToStringTable(table, filename);
LockStringTables(save);
}
|