plugins/include/sdktools_stringtables.inc
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/plugins/include/sdktools_stringtables.inc	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,180 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 - * =============================================================================
     1.9 - *
    1.10 - * This file is part of the SourceMod/SourcePawn SDK.
    1.11 - *
    1.12 - * This program is free software; you can redistribute it and/or modify it under
    1.13 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 - * Free Software Foundation.
    1.15 - * 
    1.16 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 - * details.
    1.20 - *
    1.21 - * You should have received a copy of the GNU General Public License along with
    1.22 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 - *
    1.24 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 - * or <http://www.sourcemod.net/license.php>.
    1.32 - *
    1.33 - * Version: $Id$
    1.34 - */
    1.35 -
    1.36 -#if defined _sdktools_stringtables_included
    1.37 -  #endinput
    1.38 -#endif
    1.39 -#define _sdktools_stringtables_included
    1.40 -
    1.41 -#define INVALID_STRING_TABLE -1		/**< An invalid string table index */
    1.42 -#define INVALID_STRING_INDEX -1		/**< An invalid string index in a table */
    1.43 -
    1.44 -/**
    1.45 - * Searches for a string table.
    1.46 - *
    1.47 - * @param name			Name of string table to find.
    1.48 - * @return				A string table index number if found, INVALID_STRING_TABLE otherwise.
    1.49 - */
    1.50 -native FindStringTable(const String:name[]);
    1.51 -
    1.52 -/**
    1.53 - * Returns the number of string tables that currently exist.
    1.54 - *
    1.55 - * @return				Number of string tables that currently exist.
    1.56 - */
    1.57 -native GetNumStringTables();
    1.58 -
    1.59 -/**
    1.60 - * Returns the number of strings that currently exist in a given string table.
    1.61 - *
    1.62 - * @param tableidx		A string table index.
    1.63 - * @return				Number of strings that currently exist.
    1.64 - * @error				Invalid string table index.
    1.65 - */
    1.66 -native GetStringTableNumStrings(tableidx);
    1.67 -
    1.68 -/**
    1.69 - * Returns the maximum number of strings that are allowed in a given string table.
    1.70 - *
    1.71 - * @param tableidx		A string table index.
    1.72 - * @return				Maximum number of strings allowed.
    1.73 - * @error				Invalid string table index.
    1.74 - */
    1.75 -native GetStringTableMaxStrings(tableidx);
    1.76 -
    1.77 -/**
    1.78 - * Retrieves the name of a string table.
    1.79 - *
    1.80 - * @param tableidx		A string table index.
    1.81 - * @param name			Buffer to store the name of the string table.
    1.82 - * @param maxlength		Maximum length of string buffer.
    1.83 - * @return				Number of bytes written to the buffer (UTF-8 safe).
    1.84 - * @error				Invalid string table index.
    1.85 - */
    1.86 -native GetStringTableName(tableidx, String:name[], maxlength);
    1.87 -
    1.88 -/**
    1.89 - * Searches for the index of a given string in a string table.
    1.90 - *
    1.91 - * @param tableidx		A string table index.
    1.92 - * @param string		String to find.
    1.93 - * @return				String index if found, INVALID_STRING_INDEX otherwise.
    1.94 - * @error				Invalid string table index.
    1.95 - */
    1.96 -native FindStringIndex(tableidx, const String:str[]);
    1.97 -
    1.98 -/**
    1.99 - * Retrieves the string at a given index of a string table.
   1.100 - *
   1.101 - * @param tableidx		A string table index.
   1.102 - * @param stringidx		A string index.
   1.103 - * @param name			Buffer to store the string value.
   1.104 - * @param maxlength		Maximum length of string buffer.
   1.105 - * @return				Number of bytes written to the buffer (UTF-8 safe).
   1.106 - * @error				Invalid string table index or string index.
   1.107 - */
   1.108 -native ReadStringTable(tableidx, stringIdx, String:str[], maxlength);
   1.109 -
   1.110 -/**
   1.111 - * Returns the length of the user data associated with a given string index.
   1.112 - *
   1.113 - * @param tableidx		A string table index.
   1.114 - * @param stringidx		A string index.
   1.115 - * @return				Length of user data. This will be 0 if there is no user data.
   1.116 - * @error				Invalid string table index or string index.
   1.117 - */
   1.118 -native GetStringTableDataLength(tableidx, stringidx);
   1.119 -
   1.120 -/**
   1.121 - * Retrieves the user data associated with a given string index.
   1.122 - *
   1.123 - * @param tableidx		A string table index.
   1.124 - * @param stringidx		A string index.
   1.125 - * @param userdata		Buffer to store the user data. This will be set to "" if there is no user data.
   1.126 - * @param maxlength		Maximum length of string buffer.
   1.127 - * @return				Number of bytes written to the buffer (UTF-8 safe).
   1.128 - * @error				Invalid string table index or string index.
   1.129 - */
   1.130 -native GetStringTableData(tableidx, stringIdx, String:userdata[], maxlength);
   1.131 -
   1.132 -/**
   1.133 - * Sets the user data associated with a given string index.
   1.134 - *
   1.135 - * @param tableidx		A string table index.
   1.136 - * @param stringidx		A string index.
   1.137 - * @param userdata		User data string that will be set.
   1.138 - * @param length		Length of user data string. This should include the null terminator.
   1.139 - * @return				Number of bytes written to the buffer (UTF-8 safe).
   1.140 - * @error				Invalid string table index or string index.
   1.141 - */
   1.142 -native SetStringTableData(tableidx, stringIdx, const String:userdata[], length);
   1.143 -
   1.144 -/**
   1.145 - * Adds a string to a given string table.
   1.146 - *
   1.147 - * @param tableidx		A string table index.
   1.148 - * @param string		String to add.
   1.149 - * @param userdata		An optional user data string.
   1.150 - * @param length		Length of user data string. This should include the null terminator.
   1.151 - *						If set to -1, then user data will be not be altered if the specified string
   1.152 - *						already exists in the string table.
   1.153 - */
   1.154 -native AddToStringTable(tableidx, const String:str[], const String:userdata[]="", length=-1);
   1.155 -
   1.156 -/**
   1.157 - * Locks or unlocks the network string tables.
   1.158 - *
   1.159 - * @param lock			Determines whether network string tables should be locked.
   1.160 - *						True means the tables should be locked for writing; false means unlocked.
   1.161 - * @return				Previous lock state.
   1.162 - */
   1.163 -native bool:LockStringTables(bool:lock);
   1.164 -
   1.165 -/**
   1.166 - * Adds a file to the downloadables network string table.
   1.167 - * This forces a client to download the file if they do not already have it.
   1.168 - *
   1.169 - * @param filename		File that will be added to downloadables table.
   1.170 - */
   1.171 -stock AddFileToDownloadsTable(const String:filename[])
   1.172 -{
   1.173 -	static table = INVALID_STRING_TABLE;
   1.174 -	
   1.175 -	if (table == INVALID_STRING_TABLE)
   1.176 -	{
   1.177 -		table = FindStringTable("downloadables");
   1.178 -	}
   1.179 -	
   1.180 -	new bool:save = LockStringTables(false);
   1.181 -	AddToStringTable(table, filename);
   1.182 -	LockStringTables(save);
   1.183 -}