fixed
amb1379 with sweeping changes to the entity stuff. all prop stocks are now natives so they can properly compute everything quickly, as well as do type checks. Get/SetEntDataEnt are deprecated for being sucky, the new 2 versions do more checking and uses better values. lastly, there are functions/parameters for finding types and sizes of property.
3 * =============================================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * =============================================================================
7 * This file is part of the SourceMod/SourcePawn SDK.
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, version 3.0, as published by the
11 * Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
21 * As a special exception, AlliedModders LLC gives you permission to link the
22 * code of this program (as well as its derivative works) to "Half-Life 2," the
23 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 * by the Valve Corporation. You must obey the GNU General Public License in
25 * all respects for all other code used. Additionally, AlliedModders LLC grants
26 * this exception to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 * or <http://www.sourcemod.net/license.php>.
33 #if defined _sdktools_stringtables_included
36 #define _sdktools_stringtables_included
38 #define INVALID_STRING_TABLE -1 /**< An invalid string table index */
39 #define INVALID_STRING_INDEX -1 /**< An invalid string index in a table */
42 * Searches for a string table.
44 * @param name Name of string table to find.
45 * @return A string table index number if found, INVALID_STRING_TABLE otherwise.
47 native FindStringTable(const String:name[]);
50 * Returns the number of string tables that currently exist.
52 * @return Number of string tables that currently exist.
54 native GetNumStringTables();
57 * Returns the number of strings that currently exist in a given string table.
59 * @param tableidx A string table index.
60 * @return Number of strings that currently exist.
61 * @error Invalid string table index.
63 native GetStringTableNumStrings(tableidx);
66 * Returns the maximum number of strings that are allowed in a given string table.
68 * @param tableidx A string table index.
69 * @return Maximum number of strings allowed.
70 * @error Invalid string table index.
72 native GetStringTableMaxStrings(tableidx);
75 * Retrieves the name of a string table.
77 * @param tableidx A string table index.
78 * @param name Buffer to store the name of the string table.
79 * @param maxlength Maximum length of string buffer.
80 * @return Number of bytes written to the buffer (UTF-8 safe).
81 * @error Invalid string table index.
83 native GetStringTableName(tableidx, String:name[], maxlength);
86 * Searches for the index of a given string in a string table.
88 * @param tableidx A string table index.
89 * @param string String to find.
90 * @return String index if found, INVALID_STRING_INDEX otherwise.
91 * @error Invalid string table index.
93 native FindStringIndex(tableidx, const String:str[]);
96 * Retrieves the string at a given index of a string table.
98 * @param tableidx A string table index.
99 * @param stringidx A string index.
100 * @param name Buffer to store the string value.
101 * @param maxlength Maximum length of string buffer.
102 * @return Number of bytes written to the buffer (UTF-8 safe).
103 * @error Invalid string table index or string index.
105 native ReadStringTable(tableidx, stringIdx, String:str[], maxlength);
108 * Returns the length of the user data associated with a given string index.
110 * @param tableidx A string table index.
111 * @param stringidx A string index.
112 * @return Length of user data. This will be 0 if there is no user data.
113 * @error Invalid string table index or string index.
115 native GetStringTableDataLength(tableidx, stringidx);
118 * Retrieves the user data associated with a given string index.
120 * @param tableidx A string table index.
121 * @param stringidx A string index.
122 * @param userdata Buffer to store the user data. This will be set to "" if there is no user data.
123 * @param maxlength Maximum length of string buffer.
124 * @return Number of bytes written to the buffer (UTF-8 safe).
125 * @error Invalid string table index or string index.
127 native GetStringTableData(tableidx, stringIdx, String:userdata[], maxlength);
130 * Sets the user data associated with a given string index.
132 * @param tableidx A string table index.
133 * @param stringidx A string index.
134 * @param userdata User data string that will be set.
135 * @param length Length of user data string. This should include the null terminator.
136 * @return Number of bytes written to the buffer (UTF-8 safe).
137 * @error Invalid string table index or string index.
139 native SetStringTableData(tableidx, stringIdx, const String:userdata[], length);
142 * Adds a string to a given string table.
144 * @param tableidx A string table index.
145 * @param string String to add.
146 * @param userdata An optional user data string.
147 * @param length Length of user data string. This should include the null terminator.
148 * If set to -1, then user data will be not be altered if the specified string
149 * already exists in the string table.
151 native AddToStringTable(tableidx, const String:str[], const String:userdata[]="", length=-1);
154 * Locks or unlocks the network string tables.
156 * @param lock Determines whether network string tables should be locked.
157 * True means the tables should be locked for writing; false means unlocked.
158 * @return Previous lock state.
160 native bool:LockStringTables(bool:lock);
163 * Adds a file to the downloadables network string table.
164 * This forces a client to download the file if they do not already have it.
166 * @param filename File that will be added to downloadables table.
168 stock AddFileToDownloadsTable(const String:filename[])
170 static table = INVALID_STRING_TABLE;
172 if (table == INVALID_STRING_TABLE)
174 table = FindStringTable("downloadables");
177 new bool:save = LockStringTables(false);
178 AddToStringTable(table, filename);
179 LockStringTables(save);