plugins/include/sdktools_tempents.inc
author Scott Ehlert <ds@alliedmods.net>
Thu Apr 24 10:25:44 2008 +0000 (2008-04-24)
changeset 2023 1bd756a9f8db
parent 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Added any tag to ADT array functions to fix potential tag mismatches
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * =============================================================================
ds@1952
     4
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
ds@1952
     5
 * =============================================================================
ds@1952
     6
 *
ds@1952
     7
 * This file is part of the SourceMod/SourcePawn SDK.
ds@1952
     8
 *
ds@1952
     9
 * This program is free software; you can redistribute it and/or modify it under
ds@1952
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952
    11
 * Free Software Foundation.
ds@1952
    12
 * 
ds@1952
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1952
    16
 * details.
ds@1952
    17
 *
ds@1952
    18
 * You should have received a copy of the GNU General Public License along with
ds@1952
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1952
    20
 *
ds@1952
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1952
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1952
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1952
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952
    28
 * or <http://www.sourcemod.net/license.php>.
ds@1952
    29
 *
ds@1952
    30
 * Version: $Id$
ds@1952
    31
 */
ds@1952
    32
ds@1952
    33
#if defined _sdktools_tempents_included
ds@1952
    34
 #endinput
ds@1952
    35
#endif
ds@1952
    36
#define _sdktools_tempents_included
ds@1952
    37
ds@1952
    38
/**
ds@1952
    39
 * Called when a temp entity is going to be sent.
ds@1952
    40
 *
ds@1952
    41
 * @param te_name	TE name.
ds@1952
    42
 * @param Players	Array containing target player indexes.
ds@1952
    43
 * @param numClients	Number of players in the array.
ds@1952
    44
 * @param delay		Delay in seconds to send the TE.
ds@1952
    45
 * @return		Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it.
ds@1952
    46
 */
ds@1952
    47
functag TEHook Action:public(const String:te_name[], const Players[], numClients, Float:delay);
ds@1952
    48
ds@1952
    49
/**
ds@1952
    50
 * Hooks a temp entity.
ds@1952
    51
 *
ds@1952
    52
 * @param te_name	TE name to hook.
ds@1952
    53
 * @param hook		Function to use as a hook.
ds@1952
    54
 * @noreturn
ds@1952
    55
 * @error		Temp Entity name not available or invalid function hook.
ds@1952
    56
 */
ds@1952
    57
native AddTempEntHook(const String:te_name[], TEHook:hook);
ds@1952
    58
ds@1952
    59
/**
ds@1952
    60
 * Removes a temp entity hook.
ds@1952
    61
 *
ds@1952
    62
 * @param te_name	TE name to unhook.
ds@1952
    63
 * @param hook		Function used for the hook.
ds@1952
    64
 * @noreturn
ds@1952
    65
 * @error		Temp Entity name not available or invalid function hook.
ds@1952
    66
 */
ds@1952
    67
native RemoveTempEntHook(const String:te_name[], TEHook:hook);
ds@1952
    68
ds@1952
    69
/**
ds@1952
    70
 * Starts a temp entity transmission.
ds@1952
    71
 *
ds@1952
    72
 * @param te_name	TE name.
ds@1952
    73
 * @noreturn
ds@1952
    74
 * @error		Temp Entity name not available.
ds@1952
    75
 */
ds@1952
    76
native TE_Start(const String:te_name[]);
ds@1952
    77
ds@1952
    78
/**
ds@1952
    79
 * Checks if a certain TE property exists.
ds@1952
    80
 *
ds@1952
    81
 * @param prop		Property to use.
ds@1952
    82
 * @return		True if the property exists, otherwise false.
ds@1952
    83
 */
ds@1952
    84
native bool:TE_IsValidProp(const String:prop[]);
ds@1952
    85
ds@1952
    86
/**
ds@1952
    87
 * Sets an integer value in the current temp entity.
ds@1952
    88
 *
ds@1952
    89
 * @param prop		Property to use.
ds@1952
    90
 * @param value		Integer value to set.
ds@1952
    91
 * @noreturn
ds@1952
    92
 * @error		Property not found.
ds@1952
    93
 */
ds@1952
    94
native TE_WriteNum(const String:prop[], value);
ds@1952
    95
ds@1952
    96
/**
ds@1952
    97
 * Reads an integer value in the current temp entity.
ds@1952
    98
 *
ds@1952
    99
 * @param prop		Property to use.
ds@1952
   100
 * @return		Property value.
ds@1952
   101
 * @error		Property not found.
ds@1952
   102
 */
ds@1952
   103
native TE_ReadNum(const String:prop[]);
ds@1952
   104
ds@1952
   105
/**
ds@1952
   106
 * Sets a floating point number in the current temp entity.
ds@1952
   107
 *
ds@1952
   108
 * @param prop		Property to use.
ds@1952
   109
 * @param value		Floating point number to set.
ds@1952
   110
 * @noreturn
ds@1952
   111
 * @error		Property not found.
ds@1952
   112
 */
ds@1952
   113
native TE_WriteFloat(const String:prop[], Float:value);
ds@1952
   114
ds@1952
   115
/**
ds@1952
   116
 * Reads a floating point number in the current temp entity.
ds@1952
   117
 *
ds@1952
   118
 * @param prop		Property to use.
ds@1952
   119
 * @noreturn		Property value.
ds@1952
   120
 * @error		Property not found.
ds@1952
   121
 */
ds@1952
   122
native Float:TE_ReadFloat(const String:prop[]);
ds@1952
   123
ds@1952
   124
/**
ds@1952
   125
 * Sets a vector in the current temp entity.
ds@1952
   126
 *
ds@1952
   127
 * @param prop		Property to use.
ds@1952
   128
 * @param vector	Vector to set.
ds@1952
   129
 * @noreturn
ds@1952
   130
 * @error		Property not found.
ds@1952
   131
 */
ds@1952
   132
native TE_WriteVector(const String:prop[], const Float:vector[3]);
ds@1952
   133
ds@1952
   134
/**
ds@1952
   135
 * Reads a vector in the current temp entity.
ds@1952
   136
 *
ds@1952
   137
 * @param prop		Property to use.
ds@1952
   138
 * @param vector	Vector to read.
ds@1952
   139
 * @noreturn
ds@1952
   140
 * @error		Property not found.
ds@1952
   141
 */
ds@1952
   142
native TE_ReadVector(const String:prop[], Float:vector[3]);
ds@1952
   143
ds@1952
   144
/**
ds@1952
   145
 * Sets a QAngle in the current temp entity.
ds@1952
   146
 *
ds@1952
   147
 * @param prop		Property to use.
ds@1952
   148
 * @param angles	Angles to set.
ds@1952
   149
 * @return		True on success, otherwise false.
ds@1952
   150
 * @error		Property not found.
ds@1952
   151
 */
ds@1952
   152
native TE_WriteAngles(const String:prop[], const Float:angles[3]);
ds@1952
   153
ds@1952
   154
/**
ds@1952
   155
 * Sets an array of floats in the current temp entity.
ds@1952
   156
 *
ds@1952
   157
 * @param prop		Property to use.
ds@1952
   158
 * @param array		Array of values to copy.
ds@1952
   159
 * @param arraySize	Number of values to copy.
ds@1952
   160
 * @return		True on success, otherwise false.
ds@1952
   161
 * @error		Property not found.
ds@1952
   162
 */
ds@1952
   163
native TE_WriteFloatArray(const String:prop[], const Float:array[], arraySize);
ds@1952
   164
ds@1952
   165
/**
ds@1952
   166
 * Sends the current temp entity to one or more clients.
ds@1952
   167
 *
ds@1952
   168
 * @param clients	Array containing player indexes to broadcast to.
ds@1952
   169
 * @param numClients	Number of players in the array.
ds@1952
   170
 * @param delay		Delay in seconds to send the TE.
ds@1952
   171
 * @noreturn
ds@1952
   172
 * @error		Invalid client index or client not in game.
ds@1952
   173
 */
ds@1952
   174
native TE_Send(clients[], numClients, Float:delay=0.0);
ds@1952
   175
ds@1952
   176
/**
ds@1952
   177
 * Sets an encoded entity index in the current temp entity.
ds@1952
   178
 * (This is usually used for m_nStartEntity and m_nEndEntity).
ds@1952
   179
 *
ds@1952
   180
 * @param prop		Property to use.
ds@1952
   181
 * @param value		Value to set.
ds@1952
   182
 * @noreturn
ds@1952
   183
 * @error		Property not found.
ds@1952
   184
 */
ds@1952
   185
stock TE_WriteEncodedEnt(const String:prop[], value)
ds@1952
   186
{
ds@1952
   187
	new encvalue = (value & 0x0FFF) | ((1 & 0xF)<<12);
ds@1952
   188
	return TE_WriteNum(prop, encvalue);
ds@1952
   189
}
ds@1952
   190
ds@1952
   191
/**
ds@1952
   192
 * Broadcasts the current temp entity to all clients.
ds@1952
   193
 * @note See TE_Start().
ds@1952
   194
 *
ds@1952
   195
 * @param delay		Delay in seconds to send the TE.
ds@1952
   196
 * @noreturn
ds@1952
   197
 */
ds@1952
   198
stock TE_SendToAll(Float:delay=0.0)
ds@1952
   199
{
ds@1952
   200
	new maxClients = GetMaxClients();
ds@1952
   201
	new total = 0;
ds@1952
   202
	new clients[maxClients];
ds@1952
   203
	for (new i=1; i<=maxClients; i++)
ds@1952
   204
	{
ds@1952
   205
		if (IsClientInGame(i))
ds@1952
   206
		{
ds@1952
   207
			clients[total++] = i;
ds@1952
   208
		}
ds@1952
   209
	}
ds@1952
   210
	return TE_Send(clients, total, delay);
ds@1952
   211
}
ds@1952
   212
ds@1952
   213
/**
ds@1952
   214
 * Sends the current TE to only a client.
ds@1952
   215
 * @note See TE_Start().
ds@1952
   216
 *
ds@1952
   217
 * @param client	Client to send to.
ds@1952
   218
 * @param delay		Delay in seconds to send the TE.
ds@1952
   219
 * @noreturn
ds@1952
   220
 * @error		Invalid client index or client not in game.
ds@1952
   221
 */
ds@1952
   222
stock TE_SendToClient(client, Float:delay=0.0)
ds@1952
   223
{
ds@1952
   224
	new players[1];
ds@1952
   225
ds@1952
   226
	players[0] = client;
ds@1952
   227
ds@1952
   228
	return TE_Send(players, 1, delay);
ds@1952
   229
}