plugins/include/usermessages.inc
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/plugins/include/usermessages.inc	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,211 +0,0 @@
     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.
    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 -#pragma deprecated Constant has no effect
    1.57 -#define USERMSG_PASSTHRU		(1<<0)		/**< (DEPRECATED, NO EFFECT) */
    1.58 -#pragma deprecated Constant has no effect
    1.59 -#define USERMSG_PASSTHRU_ALL	(1<<1)		/**< (DEPRECATED, NO EFFECT) */
    1.60 -#pragma deprecated Constant has no effect
    1.61 -#define USERMSG_BLOCK_MM		(1<<4)		/**< (DEPRECATED, NO EFFECT) */
    1.62 -#pragma deprecated Constant has no effect
    1.63 -#define USERMSG_BLOCK_SM		(1<<5)		/**< (DEPRECATED, NO EFFECT) */
    1.64 -#pragma deprecated Constant has no effect
    1.65 -#define USERMSG_BLOCK_ALL		(1<<6)		/**< (DEPRECATED, NO EFFECT) */
    1.66 -
    1.67 -/**
    1.68 - * @endsection
    1.69 - */
    1.70 -
    1.71 -/**
    1.72 - * Returns the ID of a given message, or -1 on failure.
    1.73 - *
    1.74 - * @param msg			String containing message name (case sensitive).
    1.75 - * @return				A message index, or INVALID_MESSAGE_ID on failure.
    1.76 - */
    1.77 -native UserMsg:GetUserMessageId(const String:msg[]);
    1.78 -
    1.79 -/**
    1.80 - * Retrieves the name of a message by ID.
    1.81 - *
    1.82 - * @param msg_id		Message index.
    1.83 - * @param msg			Buffer to store the name of the message.
    1.84 - * @param maxlength		Maximum length of string buffer.
    1.85 - * @return				True if message index is valid, false otherwise.
    1.86 - */
    1.87 -native bool:GetUserMessageName(UserMsg:msg_id, String:msg[], maxlength);
    1.88 -
    1.89 -/**
    1.90 - * Starts a usermessage (network message).
    1.91 - * @note Only one message can be active at a time.
    1.92 - * @note It is illegal to send any message while a non-intercept hook is in progress.
    1.93 - *
    1.94 - * @param msgname		Message name to start.
    1.95 - * @param clients		Array containing player indexes to broadcast to.
    1.96 - * @param numClients	Number of players in the array.
    1.97 - * @param flags			Optional flags to set.
    1.98 - * @return				A handle to a bf_write bit packing structure, or
    1.99 - *						INVALID_HANDLE on failure.
   1.100 - * @error				Invalid message name or unable to start a message.
   1.101 - */
   1.102 -native Handle:StartMessage(String:msgname[], clients[], numClients, flags=0);
   1.103 -
   1.104 -/**
   1.105 - * Starts a usermessage (network message).
   1.106 - * @note Only one message can be active at a time.
   1.107 - * @note It is illegal to send any message while a non-intercept hook is in progress.
   1.108 - *
   1.109 - * @param msg			Message index to start.
   1.110 - * @param clients		Array containing player indexes to broadcast to.
   1.111 - * @param numClients	Number of players in the array.
   1.112 - * @param flags			Optional flags to set.
   1.113 - * @return				A handle to a bf_write bit packing structure, or
   1.114 - *						INVALID_HANDLE on failure.
   1.115 - * @error				Invalid message name or unable to start a message.
   1.116 - */
   1.117 -native Handle:StartMessageEx(UserMsg:msg, clients[], numClients, flags=0);
   1.118 -
   1.119 -/**
   1.120 - * Ends a previously started user message (network message).
   1.121 - *
   1.122 - * @noreturn
   1.123 - */
   1.124 -native EndMessage();
   1.125 -
   1.126 -/**
   1.127 - * Called when a message is hooked
   1.128 - *
   1.129 - * @param msg_id		Message index.
   1.130 - * @param bf			Handle to the input bit buffer of the message.
   1.131 - * @param players		Array containing player indexes.
   1.132 - * @param playersNum	Number of players in the array.
   1.133 - * @param reliable		True if message is reliable, false otherwise.
   1.134 - * @param init			True if message is an initmsg, false otherwise.
   1.135 - * @return				Ignored for normal hooks.  For intercept hooks, Plugin_Handled 
   1.136 - *						blocks the message from being sent, and Plugin_Continue 
   1.137 - *						resumes normal functionality.
   1.138 - */
   1.139 -functag MsgHook Action:public(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init);
   1.140 -
   1.141 -/**
   1.142 - * Called when a message is finished sending.
   1.143 - *
   1.144 - * @param msg_id		Message index.
   1.145 - */
   1.146 -functag MsgSentNotify public(UserMsg:msg_id);
   1.147 -
   1.148 -/**
   1.149 - * Hooks a user message.
   1.150 - *
   1.151 - * @param msg_id		Message index.
   1.152 - * @param hook			Function to use as a hook.
   1.153 - * @param intercept		If intercept is true, message will be fully intercepted,
   1.154 - * 						allowing the user to block the message.  Otherwise,
   1.155 - *						the hook is normal and ignores the return value.
   1.156 - * @param notify		Notification function.
   1.157 - * @noreturn
   1.158 - * @error				Invalid message index.
   1.159 - */
   1.160 -native HookUserMessage(UserMsg:msg_id, MsgHook:hook, bool:intercept=false, MsgSentNotify:notify=MsgSentNotify:-1);
   1.161 -
   1.162 -/**
   1.163 - * Removes one usermessage hook.
   1.164 - *
   1.165 - * @param msg_id		Message index.
   1.166 - * @param hook			Function used for the hook.
   1.167 - * @param intercept		Specifies whether the hook was an intercept hook or not.
   1.168 - * @noreturn
   1.169 - * @error				Invalid message index.
   1.170 - */
   1.171 -native UnhookUserMessage(UserMsg:msg_id, MsgHook:hook, bool:intercept=false);
   1.172 -
   1.173 -/**
   1.174 - * Starts a usermessage (network message) that broadcasts to all clients.
   1.175 - * @note See StartMessage or StartMessageEx().
   1.176 - *
   1.177 - * @param msgname		Message name to start.
   1.178 - * @param flags			Optional flags to set.
   1.179 - * @return				A handle to a bf_write bit packing structure, or
   1.180 - *						INVALID_HANDLE on failure.
   1.181 - */
   1.182 -stock Handle:StartMessageAll(String:msgname[], flags=0)
   1.183 -{
   1.184 -	new maxClients = GetMaxClients();
   1.185 -	new total = 0;
   1.186 -	new clients[maxClients];
   1.187 -	for (new i=1; i<=maxClients; i++)
   1.188 -	{
   1.189 -		if (IsClientConnected(i))
   1.190 -		{
   1.191 -			clients[total++] = i;
   1.192 -		}
   1.193 -	}
   1.194 -	return StartMessage(msgname, clients, total, flags);
   1.195 -}
   1.196 -
   1.197 -/**
   1.198 - * Starts a simpler usermessage (network message) for one client.
   1.199 - * @note See StartMessage or StartMessageEx().
   1.200 - *
   1.201 - * @param msgname		Message name to start.
   1.202 - * @param client		Client to send to.
   1.203 - * @param flags			Optional flags to set.
   1.204 - * @return				A handle to a bf_write bit packing structure, or
   1.205 - *						INVALID_HANDLE on failure.
   1.206 - */
   1.207 -stock Handle:StartMessageOne(String:msgname[], client, flags=0)
   1.208 -{
   1.209 -	new players[1];
   1.210 -	
   1.211 -	players[0] = client;
   1.212 -	
   1.213 -	return StartMessage(msgname, players, 1, flags);
   1.214 -}