plugins/include/sdktools_tempents.inc
author Borja Ferrer <faluco@alliedmods.net>
Fri Aug 03 01:58:34 2007 +0000 (2007-08-03)
changeset 1256 76416aff76c3
parent 1255 e3db1a9eb578
child 1330 ab94316bb52b
permissions -rw-r--r--
yay fixed comments
faluco@1031
     1
/**
faluco@1031
     2
 * vim: set ts=4 :
faluco@1031
     3
 * ===============================================================
faluco@1031
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
faluco@1031
     5
 * ===============================================================
faluco@1031
     6
 *
faluco@1031
     7
 *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
faluco@1031
     8
 * or modified under the Terms and Conditions of its License Agreement, which is found 
faluco@1031
     9
 * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
faluco@1031
    10
 * may change at any time.  To view the latest information, see:
faluco@1031
    11
 *   http://www.sourcemod.net/license.php
faluco@1031
    12
 *
faluco@1031
    13
 * Version: $Id$
faluco@1031
    14
 */
faluco@1031
    15
faluco@1031
    16
#if defined _sdktools_tempents_included
faluco@1031
    17
 #endinput
faluco@1031
    18
#endif
faluco@1031
    19
#define _sdktools_tempents_included
faluco@1031
    20
faluco@1031
    21
/**
faluco@1255
    22
 * Called when a temp entity is going to be sent.
faluco@1255
    23
 *
faluco@1255
    24
 * @param te_name	TE name.
faluco@1255
    25
 * @param Players	Array containing target player indexes.
faluco@1255
    26
 * @param numClients	Number of players in the array.
faluco@1255
    27
 * @param delay		Delay in seconds to send the TE.
faluco@1255
    28
 * @return		Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it.
faluco@1255
    29
 */
faluco@1255
    30
functag TEHook Action:public(const String:te_name[], const Players[], numClients, Float:delay);
faluco@1255
    31
faluco@1255
    32
/**
faluco@1255
    33
 * Hooks a temp entity.
faluco@1255
    34
 *
faluco@1255
    35
 * @param te_name	TE name to hook.
faluco@1255
    36
 * @param hook		Function to use as a hook.
faluco@1255
    37
 * @noreturn
faluco@1255
    38
 * @error		Temp Entity name not available or invalid function hook.
faluco@1255
    39
 */
faluco@1255
    40
native AddTempEntHook(const String:te_name[], TEHook:hook);
faluco@1255
    41
faluco@1255
    42
/**
faluco@1256
    43
 * Removes a temp entity hook.
faluco@1255
    44
 *
faluco@1255
    45
 * @param te_name	TE name to unhook.
faluco@1255
    46
 * @param hook		Function used for the hook.
faluco@1255
    47
 * @noreturn
faluco@1255
    48
 * @error		Temp Entity name not available or invalid function hook.
faluco@1255
    49
 */
faluco@1255
    50
native RemoveTempEntHook(const String:te_name[], TEHook:hook);
faluco@1255
    51
faluco@1255
    52
/**
faluco@1031
    53
 * Starts a temp entity transmission.
faluco@1031
    54
 *
faluco@1031
    55
 * @param te_name	TE name.
faluco@1031
    56
 * @noreturn
faluco@1031
    57
 * @error		Temp Entity name not available.
faluco@1031
    58
 */
faluco@1031
    59
native TE_Start(const String:te_name[]);
faluco@1031
    60
faluco@1031
    61
/**
faluco@1031
    62
 * Checks if a certain TE property exists.
faluco@1031
    63
 *
faluco@1031
    64
 * @param prop		Property to use.
faluco@1031
    65
 * @return		True if the property exists, otherwise false.
faluco@1031
    66
 */
faluco@1031
    67
native bool:TE_IsValidProp(const String:prop[]);
faluco@1031
    68
faluco@1031
    69
/**
faluco@1031
    70
 * Sets an integer value in the current temp entity.
faluco@1031
    71
 *
faluco@1031
    72
 * @param prop		Property to use.
faluco@1031
    73
 * @param value		Integer value to set.
faluco@1031
    74
 * @noreturn
faluco@1031
    75
 * @error		Property not found.
faluco@1031
    76
 */
faluco@1031
    77
native TE_WriteNum(const String:prop[], value);
faluco@1031
    78
faluco@1031
    79
/**
faluco@1255
    80
 * Reads an integer value in the current temp entity.
faluco@1255
    81
 *
faluco@1255
    82
 * @param prop		Property to use.
faluco@1255
    83
 * @return		Property value.
faluco@1255
    84
 * @error		Property not found.
faluco@1255
    85
 */
faluco@1255
    86
native TE_ReadNum(const String:prop[]);
faluco@1255
    87
faluco@1255
    88
/**
faluco@1031
    89
 * Sets a floating point number in the current temp entity.
faluco@1031
    90
 *
faluco@1031
    91
 * @param prop		Property to use.
faluco@1031
    92
 * @param value		Floating point number to set.
faluco@1031
    93
 * @noreturn
faluco@1031
    94
 * @error		Property not found.
faluco@1031
    95
 */
faluco@1031
    96
native TE_WriteFloat(const String:prop[], Float:value);
faluco@1031
    97
faluco@1031
    98
/**
faluco@1255
    99
 * Reads a floating point number in the current temp entity.
faluco@1255
   100
 *
faluco@1255
   101
 * @param prop		Property to use.
faluco@1255
   102
 * @noreturn		Property value.
faluco@1255
   103
 * @error		Property not found.
faluco@1255
   104
 */
faluco@1255
   105
native Float:TE_ReadFloat(const String:prop[]);
faluco@1255
   106
faluco@1255
   107
/**
faluco@1031
   108
 * Sets a vector in the current temp entity.
faluco@1031
   109
 *
faluco@1031
   110
 * @param prop		Property to use.
faluco@1031
   111
 * @param vector	Vector to set.
faluco@1031
   112
 * @noreturn
faluco@1031
   113
 * @error		Property not found.
faluco@1031
   114
 */
faluco@1039
   115
native TE_WriteVector(const String:prop[], const Float:vector[3]);
faluco@1031
   116
faluco@1031
   117
/**
faluco@1255
   118
 * Reads a vector in the current temp entity.
faluco@1255
   119
 *
faluco@1255
   120
 * @param prop		Property to use.
faluco@1255
   121
 * @param vector	Vector to read.
faluco@1255
   122
 * @noreturn
faluco@1255
   123
 * @error		Property not found.
faluco@1255
   124
 */
faluco@1255
   125
native TE_ReadVector(const String:prop[], Float:vector[3]);
faluco@1255
   126
faluco@1255
   127
/**
faluco@1031
   128
 * Sets a QAngle in the current temp entity.
faluco@1031
   129
 *
faluco@1031
   130
 * @param prop		Property to use.
faluco@1031
   131
 * @param angles	Angles to set.
faluco@1031
   132
 * @return		True on success, otherwise false.
faluco@1031
   133
 * @error		Property not found.
faluco@1031
   134
 */
faluco@1039
   135
native TE_WriteAngles(const String:prop[], const Float:angles[3]);
faluco@1039
   136
faluco@1039
   137
/**
faluco@1039
   138
 * Sets an array of floats in the current temp entity.
faluco@1039
   139
 *
faluco@1039
   140
 * @param prop		Property to use.
faluco@1039
   141
 * @param array		Array of values to copy.
faluco@1039
   142
 * @param arraySize	Number of values to copy.
faluco@1039
   143
 * @return		True on success, otherwise false.
faluco@1039
   144
 * @error		Property not found.
faluco@1039
   145
 */
faluco@1039
   146
native TE_WriteFloatArray(const String:prop[], const Float:array[], arraySize);
faluco@1031
   147
faluco@1031
   148
/**
faluco@1031
   149
 * Sends the current temp entity to one or more clients.
faluco@1031
   150
 *
faluco@1031
   151
 * @param clients	Array containing player indexes to broadcast to.
faluco@1031
   152
 * @param numClients	Number of players in the array.
faluco@1031
   153
 * @param delay		Delay in seconds to send the TE.
faluco@1031
   154
 * @noreturn
faluco@1031
   155
 * @error		Invalid client index or client not in game.
faluco@1031
   156
 */
faluco@1031
   157
native TE_Send(clients[], numClients, Float:delay=0.0);
faluco@1031
   158
faluco@1031
   159
/**
faluco@1031
   160
 * Sets an encoded entity index in the current temp entity.
faluco@1031
   161
 * (This is usually used for m_nStartEntity and m_nEndEntity).
faluco@1031
   162
 *
faluco@1031
   163
 * @param prop		Property to use.
faluco@1031
   164
 * @param value		Value to set.
faluco@1031
   165
 * @noreturn
faluco@1031
   166
 * @error		Property not found.
faluco@1031
   167
 */
faluco@1031
   168
stock TE_WriteEncodedEnt(const String:prop[], value)
faluco@1031
   169
{
faluco@1031
   170
	new encvalue = (value & 0x0FFF) | ((1 & 0xF)<<12);
faluco@1031
   171
	return TE_WriteNum(prop, encvalue);
faluco@1031
   172
}
faluco@1031
   173
faluco@1031
   174
/**
faluco@1031
   175
 * Broadcasts the current temp entity to all clients.
faluco@1031
   176
 * @note See TE_Start().
faluco@1031
   177
 *
faluco@1031
   178
 * @param delay		Delay in seconds to send the TE.
faluco@1031
   179
 * @noreturn
faluco@1031
   180
 */
faluco@1031
   181
stock TE_SendToAll(Float:delay=0.0)
faluco@1031
   182
{
faluco@1031
   183
	new maxClients = GetMaxClients();
faluco@1031
   184
	new total = 0;
faluco@1031
   185
	new clients[maxClients];
faluco@1031
   186
	for (new i=1; i<=maxClients; i++)
faluco@1031
   187
	{
faluco@1031
   188
		if (IsClientInGame(i))
faluco@1031
   189
		{
faluco@1031
   190
			clients[total++] = i;
faluco@1031
   191
		}
faluco@1031
   192
	}
faluco@1031
   193
	return TE_Send(clients, total, delay);
faluco@1031
   194
}
faluco@1031
   195
faluco@1031
   196
/**
faluco@1031
   197
 * Sends the current TE to only a client.
faluco@1031
   198
 * @note See TE_Start().
faluco@1031
   199
 *
faluco@1031
   200
 * @param client	Client to send to.
faluco@1031
   201
 * @param delay		Delay in seconds to send the TE.
faluco@1031
   202
 * @noreturn
faluco@1031
   203
 * @error		Invalid client index or client not in game.
faluco@1031
   204
 */
dvander@1053
   205
stock TE_SendToClient(client, Float:delay=0.0)
faluco@1031
   206
{
faluco@1031
   207
	new players[1];
faluco@1031
   208
faluco@1031
   209
	players[0] = client;
faluco@1031
   210
faluco@1031
   211
	return TE_Send(players, 1, delay);
faluco@1031
   212
}