plugins/include/sdktools_tempents.inc
author Borja Ferrer <faluco@alliedmods.net>
Mon Jul 02 00:25:46 2007 +0000 (2007-07-02)
changeset 1031 d9cf44ddcd9c
child 1039 71e55e3fd8f7
permissions -rw-r--r--
initial import of the TE code
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@1031
    22
 * Starts a temp entity transmission.
faluco@1031
    23
 *
faluco@1031
    24
 * @param te_name	TE name.
faluco@1031
    25
 * @noreturn
faluco@1031
    26
 * @error		Temp Entity name not available.
faluco@1031
    27
 */
faluco@1031
    28
native TE_Start(const String:te_name[]);
faluco@1031
    29
faluco@1031
    30
/**
faluco@1031
    31
 * Checks if a certain TE property exists.
faluco@1031
    32
 *
faluco@1031
    33
 * @param prop		Property to use.
faluco@1031
    34
 * @return		True if the property exists, otherwise false.
faluco@1031
    35
 */
faluco@1031
    36
native bool:TE_IsValidProp(const String:prop[]);
faluco@1031
    37
faluco@1031
    38
/**
faluco@1031
    39
 * Sets an integer value in the current temp entity.
faluco@1031
    40
 *
faluco@1031
    41
 * @param prop		Property to use.
faluco@1031
    42
 * @param value		Integer value to set.
faluco@1031
    43
 * @noreturn
faluco@1031
    44
 * @error		Property not found.
faluco@1031
    45
 */
faluco@1031
    46
native TE_WriteNum(const String:prop[], value);
faluco@1031
    47
faluco@1031
    48
/**
faluco@1031
    49
 * Sets a floating point number in the current temp entity.
faluco@1031
    50
 *
faluco@1031
    51
 * @param prop		Property to use.
faluco@1031
    52
 * @param value		Floating point number to set.
faluco@1031
    53
 * @noreturn
faluco@1031
    54
 * @error		Property not found.
faluco@1031
    55
 */
faluco@1031
    56
native TE_WriteFloat(const String:prop[], Float:value);
faluco@1031
    57
faluco@1031
    58
/**
faluco@1031
    59
 * Sets a vector in the current temp entity.
faluco@1031
    60
 *
faluco@1031
    61
 * @param prop		Property to use.
faluco@1031
    62
 * @param vector	Vector to set.
faluco@1031
    63
 * @noreturn
faluco@1031
    64
 * @error		Property not found.
faluco@1031
    65
 */
faluco@1031
    66
native TE_WriteVector(const String:prop[], Float:vector[3]);
faluco@1031
    67
faluco@1031
    68
/**
faluco@1031
    69
 * Sets a QAngle in the current temp entity.
faluco@1031
    70
 *
faluco@1031
    71
 * @param prop		Property to use.
faluco@1031
    72
 * @param angles	Angles to set.
faluco@1031
    73
 * @return		True on success, otherwise false.
faluco@1031
    74
 * @error		Property not found.
faluco@1031
    75
 */
faluco@1031
    76
native TE_WriteAngles(const String:prop[], Float:angles[3]);
faluco@1031
    77
faluco@1031
    78
/**
faluco@1031
    79
 * Sends the current temp entity to one or more clients.
faluco@1031
    80
 *
faluco@1031
    81
 * @param clients	Array containing player indexes to broadcast to.
faluco@1031
    82
 * @param numClients	Number of players in the array.
faluco@1031
    83
 * @param delay		Delay in seconds to send the TE.
faluco@1031
    84
 * @noreturn
faluco@1031
    85
 * @error		Invalid client index or client not in game.
faluco@1031
    86
 */
faluco@1031
    87
native TE_Send(clients[], numClients, Float:delay=0.0);
faluco@1031
    88
faluco@1031
    89
/**
faluco@1031
    90
 * Sets an encoded entity index in the current temp entity.
faluco@1031
    91
 * (This is usually used for m_nStartEntity and m_nEndEntity).
faluco@1031
    92
 *
faluco@1031
    93
 * @param prop		Property to use.
faluco@1031
    94
 * @param value		Value to set.
faluco@1031
    95
 * @noreturn
faluco@1031
    96
 * @error		Property not found.
faluco@1031
    97
 */
faluco@1031
    98
stock TE_WriteEncodedEnt(const String:prop[], value)
faluco@1031
    99
{
faluco@1031
   100
	new encvalue = (value & 0x0FFF) | ((1 & 0xF)<<12);
faluco@1031
   101
	return TE_WriteNum(prop, encvalue);
faluco@1031
   102
}
faluco@1031
   103
faluco@1031
   104
/**
faluco@1031
   105
 * Broadcasts the current temp entity to all clients.
faluco@1031
   106
 * @note See TE_Start().
faluco@1031
   107
 *
faluco@1031
   108
 * @param delay		Delay in seconds to send the TE.
faluco@1031
   109
 * @noreturn
faluco@1031
   110
 */
faluco@1031
   111
stock TE_SendToAll(Float:delay=0.0)
faluco@1031
   112
{
faluco@1031
   113
	new maxClients = GetMaxClients();
faluco@1031
   114
	new total = 0;
faluco@1031
   115
	new clients[maxClients];
faluco@1031
   116
	for (new i=1; i<=maxClients; i++)
faluco@1031
   117
	{
faluco@1031
   118
		if (IsClientInGame(i))
faluco@1031
   119
		{
faluco@1031
   120
			clients[total++] = i;
faluco@1031
   121
		}
faluco@1031
   122
	}
faluco@1031
   123
	return TE_Send(clients, total, delay);
faluco@1031
   124
}
faluco@1031
   125
faluco@1031
   126
/**
faluco@1031
   127
 * Sends the current TE to only a client.
faluco@1031
   128
 * @note See TE_Start().
faluco@1031
   129
 *
faluco@1031
   130
 * @param client	Client to send to.
faluco@1031
   131
 * @param delay		Delay in seconds to send the TE.
faluco@1031
   132
 * @noreturn
faluco@1031
   133
 * @error		Invalid client index or client not in game.
faluco@1031
   134
 */
faluco@1031
   135
stock TE_SendToOne(client, Float:delay=0.0)
faluco@1031
   136
{
faluco@1031
   137
	new players[1];
faluco@1031
   138
faluco@1031
   139
	players[0] = client;
faluco@1031
   140
faluco@1031
   141
	return TE_Send(players, 1, delay);
faluco@1031
   142
}