1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/include/usermessages.inc Fri Feb 16 18:47:16 2007 +0000
1.3 @@ -0,0 +1,109 @@
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. This file may only be used
1.11 + * or modified under the Terms and Conditions of its License Agreement, which is found
1.12 + * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins
1.13 + * may change at any time. To view the latest information, see:
1.14 + * http://www.sourcemod.net/license.php
1.15 + *
1.16 + * Version: $Id$
1.17 + */
1.18 +
1.19 +#if defined _eventsmsgs_included
1.20 + #endinput
1.21 +#endif
1.22 +#define _eventsmsgs_included
1.23 +
1.24 +enum UserMsg
1.25 +{
1.26 + INVALID_MESSAGE_ID = -1,
1.27 +};
1.28 +
1.29 +#define USERMSG_PASSTHRU (1<<0) /**< Message will pass through other SourceMM plugins */
1.30 +#define USERMSG_PASSTHRU_ALL (1<<1) /**< Message will pass through other SourceMM plugins AND SourceMod */
1.31 +#define USERMSG_RELIABLE (1<<2) /**< Message will be set to reliable */
1.32 +#define USERMSG_INITMSG (1<<3) /**< Message will be considered to be an initmsg */
1.33 +
1.34 +/**
1.35 + * Returns the ID of a given message, or -1 on failure.
1.36 + *
1.37 + * @param msg String containing message name (case sensitive).
1.38 + * @return A message index, or INVALID_MESSAGE_ID on failure.
1.39 + */
1.40 +native UserMsg:GetUserMessageId(const String:msg[]);
1.41 +
1.42 +/**
1.43 + * Starts a usermessage (network message).
1.44 + * @note Only one message can be active at a time.
1.45 + *
1.46 + * @param msgname Message name to start.
1.47 + * @param clients Array containing player indexes to broadcast to.
1.48 + * @param numClients Number of players in the array.
1.49 + * @return A handle to a bf_write bit packing structure, or
1.50 + * INVALID_HANDLE on failure.
1.51 + */
1.52 +native Handle:StartMessage(String:msgname[], clients[], numClients, flags);
1.53 +
1.54 +/**
1.55 + * Starts a usermessage (network message).
1.56 + * @note Only one message can be active at a time.
1.57 + *
1.58 + * @param msg Message index to start.
1.59 + * @param clients Array containing player indexes to broadcast to.
1.60 + * @param numClients Number of players in the array.
1.61 + * @return A handle to a bf_write bit packing structure, or
1.62 + * INVALID_HANDLE on failure.
1.63 + */
1.64 +native Handle:StartMessageEx(UserMsg:msg, clients[], numClients, flags);
1.65 +
1.66 +/**
1.67 + * Ends a previously started user message (network message).
1.68 + *
1.69 + * @noreturn
1.70 + */
1.71 +native EndMessage();
1.72 +
1.73 +/**
1.74 + * Starts a usermessage (network message) that broadcasts to all clients.
1.75 + *
1.76 + * @param msgname Message name to start.
1.77 + * @param flags Optional flags to set.
1.78 + * @return A handle to a bf_write bit packing structure, or
1.79 + * INVALID_HANDLE on failure.
1.80 + */
1.81 +stock Handle:StartMessageAll(String:msgname[], flags=0)
1.82 +{
1.83 + new maxClients = GetMaxClients();
1.84 + new total = 0;
1.85 + new clients[maxClients];
1.86 + for (new i=1; i<=maxClients; i++)
1.87 + {
1.88 + if (IsClientConnected(i))
1.89 + {
1.90 + clients[total++] = i;
1.91 + }
1.92 + }
1.93 + return StartMessage(msgname, clients, total, flags);
1.94 +}
1.95 +
1.96 +/**
1.97 + * Starts a simpler usermessage (network message) for one client.
1.98 + *
1.99 + * @param msgname Message name to start.
1.100 + * @param client Client to send to.
1.101 + * @param flags Optional flags to set.
1.102 + * @return A handle to a bf_write bit packing structure, or
1.103 + * INVALID_HANDLE on failure.
1.104 + */
1.105 +stock Handle:StartMessageOne(String:msgname[], client, flags=0)
1.106 +{
1.107 + new players[1];
1.108 +
1.109 + players[0] = client;
1.110 +
1.111 + return StartMessage(msgname, players, 1, flags);
1.112 +}