plugins/include/sdktools_tempents.inc
author Borja Ferrer <faluco@alliedmods.net>
Fri Aug 03 01:53:00 2007 +0000 (2007-08-03)
changeset 1255 e3db1a9eb578
parent 1053 6d642ebae456
child 1256 76416aff76c3
permissions -rw-r--r--
added amb719, added TE hooks and read prop natives to read props before transmission
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@1255
    43
 * Removes a temp entity.
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
 * @param value		Integer value to read.
faluco@1255
    84
 * @return		Property value.
faluco@1255
    85
 * @error		Property not found.
faluco@1255
    86
 */
faluco@1255
    87
native TE_ReadNum(const String:prop[]);
faluco@1255
    88
faluco@1255
    89
/**
faluco@1031
    90
 * Sets a floating point number in the current temp entity.
faluco@1031
    91
 *
faluco@1031
    92
 * @param prop		Property to use.
faluco@1031
    93
 * @param value		Floating point number to set.
faluco@1031
    94
 * @noreturn
faluco@1031
    95
 * @error		Property not found.
faluco@1031
    96
 */
faluco@1031
    97
native TE_WriteFloat(const String:prop[], Float:value);
faluco@1031
    98
faluco@1031
    99
/**
faluco@1255
   100
 * Reads a floating point number in the current temp entity.
faluco@1255
   101
 *
faluco@1255
   102
 * @param prop		Property to use.
faluco@1255
   103
 * @param value		Floating point number to read.
faluco@1255
   104
 * @noreturn		Property value.
faluco@1255
   105
 * @error		Property not found.
faluco@1255
   106
 */
faluco@1255
   107
native Float:TE_ReadFloat(const String:prop[]);
faluco@1255
   108
faluco@1255
   109
/**
faluco@1031
   110
 * Sets a vector in the current temp entity.
faluco@1031
   111
 *
faluco@1031
   112
 * @param prop		Property to use.
faluco@1031
   113
 * @param vector	Vector to set.
faluco@1031
   114
 * @noreturn
faluco@1031
   115
 * @error		Property not found.
faluco@1031
   116
 */
faluco@1039
   117
native TE_WriteVector(const String:prop[], const Float:vector[3]);
faluco@1031
   118
faluco@1031
   119
/**
faluco@1255
   120
 * Reads a vector in the current temp entity.
faluco@1255
   121
 *
faluco@1255
   122
 * @param prop		Property to use.
faluco@1255
   123
 * @param vector	Vector to read.
faluco@1255
   124
 * @noreturn
faluco@1255
   125
 * @error		Property not found.
faluco@1255
   126
 */
faluco@1255
   127
native TE_ReadVector(const String:prop[], Float:vector[3]);
faluco@1255
   128
faluco@1255
   129
/**
faluco@1031
   130
 * Sets a QAngle in the current temp entity.
faluco@1031
   131
 *
faluco@1031
   132
 * @param prop		Property to use.
faluco@1031
   133
 * @param angles	Angles to set.
faluco@1031
   134
 * @return		True on success, otherwise false.
faluco@1031
   135
 * @error		Property not found.
faluco@1031
   136
 */
faluco@1039
   137
native TE_WriteAngles(const String:prop[], const Float:angles[3]);
faluco@1039
   138
faluco@1039
   139
/**
faluco@1039
   140
 * Sets an array of floats in the current temp entity.
faluco@1039
   141
 *
faluco@1039
   142
 * @param prop		Property to use.
faluco@1039
   143
 * @param array		Array of values to copy.
faluco@1039
   144
 * @param arraySize	Number of values to copy.
faluco@1039
   145
 * @return		True on success, otherwise false.
faluco@1039
   146
 * @error		Property not found.
faluco@1039
   147
 */
faluco@1039
   148
native TE_WriteFloatArray(const String:prop[], const Float:array[], arraySize);
faluco@1031
   149
faluco@1031
   150
/**
faluco@1031
   151
 * Sends the current temp entity to one or more clients.
faluco@1031
   152
 *
faluco@1031
   153
 * @param clients	Array containing player indexes to broadcast to.
faluco@1031
   154
 * @param numClients	Number of players in the array.
faluco@1031
   155
 * @param delay		Delay in seconds to send the TE.
faluco@1031
   156
 * @noreturn
faluco@1031
   157
 * @error		Invalid client index or client not in game.
faluco@1031
   158
 */
faluco@1031
   159
native TE_Send(clients[], numClients, Float:delay=0.0);
faluco@1031
   160
faluco@1031
   161
/**
faluco@1031
   162
 * Sets an encoded entity index in the current temp entity.
faluco@1031
   163
 * (This is usually used for m_nStartEntity and m_nEndEntity).
faluco@1031
   164
 *
faluco@1031
   165
 * @param prop		Property to use.
faluco@1031
   166
 * @param value		Value to set.
faluco@1031
   167
 * @noreturn
faluco@1031
   168
 * @error		Property not found.
faluco@1031
   169
 */
faluco@1031
   170
stock TE_WriteEncodedEnt(const String:prop[], value)
faluco@1031
   171
{
faluco@1031
   172
	new encvalue = (value & 0x0FFF) | ((1 & 0xF)<<12);
faluco@1031
   173
	return TE_WriteNum(prop, encvalue);
faluco@1031
   174
}
faluco@1031
   175
faluco@1031
   176
/**
faluco@1031
   177
 * Broadcasts the current temp entity to all clients.
faluco@1031
   178
 * @note See TE_Start().
faluco@1031
   179
 *
faluco@1031
   180
 * @param delay		Delay in seconds to send the TE.
faluco@1031
   181
 * @noreturn
faluco@1031
   182
 */
faluco@1031
   183
stock TE_SendToAll(Float:delay=0.0)
faluco@1031
   184
{
faluco@1031
   185
	new maxClients = GetMaxClients();
faluco@1031
   186
	new total = 0;
faluco@1031
   187
	new clients[maxClients];
faluco@1031
   188
	for (new i=1; i<=maxClients; i++)
faluco@1031
   189
	{
faluco@1031
   190
		if (IsClientInGame(i))
faluco@1031
   191
		{
faluco@1031
   192
			clients[total++] = i;
faluco@1031
   193
		}
faluco@1031
   194
	}
faluco@1031
   195
	return TE_Send(clients, total, delay);
faluco@1031
   196
}
faluco@1031
   197
faluco@1031
   198
/**
faluco@1031
   199
 * Sends the current TE to only a client.
faluco@1031
   200
 * @note See TE_Start().
faluco@1031
   201
 *
faluco@1031
   202
 * @param client	Client to send to.
faluco@1031
   203
 * @param delay		Delay in seconds to send the TE.
faluco@1031
   204
 * @noreturn
faluco@1031
   205
 * @error		Invalid client index or client not in game.
faluco@1031
   206
 */
dvander@1053
   207
stock TE_SendToClient(client, Float:delay=0.0)
faluco@1031
   208
{
faluco@1031
   209
	new players[1];
faluco@1031
   210
faluco@1031
   211
	players[0] = client;
faluco@1031
   212
faluco@1031
   213
	return TE_Send(players, 1, delay);
faluco@1031
   214
}