plugins/include/usermessages.inc
branchrefac-jit
changeset 2284 026da5437111
parent 2192 7602d7fb60d9
child 2288 15c77b21589a
     1.1 --- a/plugins/include/usermessages.inc	Fri Jul 11 06:51:21 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,202 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     1.8 - * =============================================================================
     1.9 - *
    1.10 - * This file is part of the SourceMod/SourcePawn SDK.
    1.11 - *
    1.12 - * This program is free software; you can redistribute it and/or modify it under
    1.13 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 - * Free Software Foundation.
    1.15 - * 
    1.16 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 - * details.
    1.20 - *
    1.21 - * You should have received a copy of the GNU General Public License along with
    1.22 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 - *
    1.24 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 - * or <http://www.sourcemod.net/license.php>.
    1.32 - *
    1.33 - * Version: $Id$
    1.34 - */
    1.35 - 
    1.36 -#if defined _eventsmsgs_included
    1.37 - #endinput
    1.38 -#endif
    1.39 -#define _eventsmsgs_included
    1.40 -
    1.41 -/**
    1.42 - * UserMsg helper values.
    1.43 - */
    1.44 -enum UserMsg
    1.45 -{
    1.46 -	INVALID_MESSAGE_ID = -1,
    1.47 -};
    1.48 -
    1.49 -/**
    1.50 - * @section Message Flags.
    1.51 - */
    1.52 -#define USERMSG_RELIABLE		(1<<2)		/**< Message will be set on the reliable stream */
    1.53 -#define USERMSG_INITMSG			(1<<3)		/**< Message will be considered to be an initmsg */
    1.54 -#define USERMSG_BLOCKHOOKS		(1<<7)		/**< Prevents the message from triggering SourceMod and Metamod hooks */
    1.55 -
    1.56 -/**
    1.57 - * @endsection
    1.58 - */
    1.59 -
    1.60 -/**
    1.61 - * Returns the ID of a given message, or -1 on failure.
    1.62 - *
    1.63 - * @param msg			String containing message name (case sensitive).
    1.64 - * @return				A message index, or INVALID_MESSAGE_ID on failure.
    1.65 - */
    1.66 -native UserMsg:GetUserMessageId(const String:msg[]);
    1.67 -
    1.68 -/**
    1.69 - * Retrieves the name of a message by ID.
    1.70 - *
    1.71 - * @param msg_id		Message index.
    1.72 - * @param msg			Buffer to store the name of the message.
    1.73 - * @param maxlength		Maximum length of string buffer.
    1.74 - * @return				True if message index is valid, false otherwise.
    1.75 - */
    1.76 -native bool:GetUserMessageName(UserMsg:msg_id, String:msg[], maxlength);
    1.77 -
    1.78 -/**
    1.79 - * Starts a usermessage (network message).
    1.80 - * @note Only one message can be active at a time.
    1.81 - * @note It is illegal to send any message while a non-intercept hook is in progress.
    1.82 - *
    1.83 - * @param msgname		Message name to start.
    1.84 - * @param clients		Array containing player indexes to broadcast to.
    1.85 - * @param numClients	Number of players in the array.
    1.86 - * @param flags			Optional flags to set.
    1.87 - * @return				A handle to a bf_write bit packing structure, or
    1.88 - *						INVALID_HANDLE on failure.
    1.89 - * @error				Invalid message name, unable to start a message, invalid client,
    1.90 - *						or client not connected.
    1.91 - */
    1.92 -native Handle:StartMessage(String:msgname[], clients[], numClients, flags=0);
    1.93 -
    1.94 -/**
    1.95 - * Starts a usermessage (network message).
    1.96 - * @note Only one message can be active at a time.
    1.97 - * @note It is illegal to send any message while a non-intercept hook is in progress.
    1.98 - *
    1.99 - * @param msg			Message index to start.
   1.100 - * @param clients		Array containing player indexes to broadcast to.
   1.101 - * @param numClients	Number of players in the array.
   1.102 - * @param flags			Optional flags to set.
   1.103 - * @return				A handle to a bf_write bit packing structure, or
   1.104 - *						INVALID_HANDLE on failure.
   1.105 - * @error				Invalid message name, unable to start a message, invalid client,
   1.106 - *						or client not connected.
   1.107 - */
   1.108 -native Handle:StartMessageEx(UserMsg:msg, clients[], numClients, flags=0);
   1.109 -
   1.110 -/**
   1.111 - * Ends a previously started user message (network message).
   1.112 - *
   1.113 - * @noreturn
   1.114 - */
   1.115 -native EndMessage();
   1.116 -
   1.117 -/**
   1.118 - * Called when a message is hooked
   1.119 - *
   1.120 - * @param msg_id		Message index.
   1.121 - * @param bf			Handle to the input bit buffer of the message.
   1.122 - * @param players		Array containing player indexes.
   1.123 - * @param playersNum	Number of players in the array.
   1.124 - * @param reliable		True if message is reliable, false otherwise.
   1.125 - * @param init			True if message is an initmsg, false otherwise.
   1.126 - * @return				Ignored for normal hooks.  For intercept hooks, Plugin_Handled 
   1.127 - *						blocks the message from being sent, and Plugin_Continue 
   1.128 - *						resumes normal functionality.
   1.129 - */
   1.130 -functag MsgHook Action:public(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init);
   1.131 -
   1.132 -/**
   1.133 - * Called when a message is finished sending.
   1.134 - *
   1.135 - * @param msg_id		Message index.
   1.136 - */
   1.137 -functag MsgSentNotify public(UserMsg:msg_id);
   1.138 -
   1.139 -/**
   1.140 - * Hooks a user message.
   1.141 - *
   1.142 - * @param msg_id		Message index.
   1.143 - * @param hook			Function to use as a hook.
   1.144 - * @param intercept		If intercept is true, message will be fully intercepted,
   1.145 - * 						allowing the user to block the message.  Otherwise,
   1.146 - *						the hook is normal and ignores the return value.
   1.147 - * @param notify		Notification function.
   1.148 - * @noreturn
   1.149 - * @error				Invalid message index.
   1.150 - */
   1.151 -native HookUserMessage(UserMsg:msg_id, MsgHook:hook, bool:intercept=false, MsgSentNotify:notify=MsgSentNotify:-1);
   1.152 -
   1.153 -/**
   1.154 - * Removes one usermessage hook.
   1.155 - *
   1.156 - * @param msg_id		Message index.
   1.157 - * @param hook			Function used for the hook.
   1.158 - * @param intercept		Specifies whether the hook was an intercept hook or not.
   1.159 - * @noreturn
   1.160 - * @error				Invalid message index.
   1.161 - */
   1.162 -native UnhookUserMessage(UserMsg:msg_id, MsgHook:hook, bool:intercept=false);
   1.163 -
   1.164 -/**
   1.165 - * Starts a usermessage (network message) that broadcasts to all clients.
   1.166 - * @note See StartMessage or StartMessageEx().
   1.167 - *
   1.168 - * @param msgname		Message name to start.
   1.169 - * @param flags			Optional flags to set.
   1.170 - * @return				A handle to a bf_write bit packing structure, or
   1.171 - *						INVALID_HANDLE on failure.
   1.172 - */
   1.173 -stock Handle:StartMessageAll(String:msgname[], flags=0)
   1.174 -{
   1.175 -	new maxClients = GetMaxClients();
   1.176 -	new total = 0;
   1.177 -	new clients[maxClients];
   1.178 -	for (new i=1; i<=maxClients; i++)
   1.179 -	{
   1.180 -		if (IsClientConnected(i))
   1.181 -		{
   1.182 -			clients[total++] = i;
   1.183 -		}
   1.184 -	}
   1.185 -	return StartMessage(msgname, clients, total, flags);
   1.186 -}
   1.187 -
   1.188 -/**
   1.189 - * Starts a simpler usermessage (network message) for one client.
   1.190 - * @note See StartMessage or StartMessageEx().
   1.191 - *
   1.192 - * @param msgname		Message name to start.
   1.193 - * @param client		Client to send to.
   1.194 - * @param flags			Optional flags to set.
   1.195 - * @return				A handle to a bf_write bit packing structure, or
   1.196 - *						INVALID_HANDLE on failure.
   1.197 - */
   1.198 -stock Handle:StartMessageOne(String:msgname[], client, flags=0)
   1.199 -{
   1.200 -	new players[1];
   1.201 -	
   1.202 -	players[0] = client;
   1.203 -	
   1.204 -	return StartMessage(msgname, players, 1, flags);
   1.205 -}