Fixed AskPluginLoad would still allowed plugin to load even if it returned false.
3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is part of the SourceMod/SourcePawn SDK. This file may only be used
8 * or modified under the Terms and Conditions of its License Agreement, which is found
9 * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins
10 * may change at any time. To view the latest information, see:
11 * http://www.sourcemod.net/license.php
16 #if defined _eventsmsgs_included
19 #define _eventsmsgs_included
22 * UserMsg helper values.
26 INVALID_MESSAGE_ID = -1,
30 * @section Message Flags.
32 #define USERMSG_PASSTHRU (1<<0) /**< (DEPRECATED, NO EFFECT) */
33 #define USERMSG_PASSTHRU_ALL (1<<1) /**< (DEPRECATED, NO EFFECT) */
34 #define USERMSG_RELIABLE (1<<2) /**< Message will be set on the reliable stream */
35 #define USERMSG_INITMSG (1<<3) /**< Message will be considered to be an initmsg */
36 #define USERMSG_BLOCK_MM (1<<4) /**< Message will be blocked from going through MM:S hooks */
37 #define USERMSG_BLOCK_SM (1<<5) /**< Message will be blocked from going through SourceMod hooks */
38 #define USERMSG_BLOCK_ALL (1<<6) /**< Message will be blocked from going through any hooks */
45 * Returns the ID of a given message, or -1 on failure.
47 * @param msg String containing message name (case sensitive).
48 * @return A message index, or INVALID_MESSAGE_ID on failure.
50 native UserMsg:GetUserMessageId(const String:msg[]);
53 * Retrieves the name of a message by ID.
55 * @param msg_id Message index.
56 * @param msg Buffer to store the name of the message.
57 * @param maxlength Maximum length of string buffer.
58 * @return True if message index is valid, false otherwise.
60 native bool:GetUserMessageName(UserMsg:msg_id, String:msg[], maxlength);
63 * Starts a usermessage (network message).
64 * @note Only one message can be active at a time.
65 * @note It is illegal to send any message while a non-intercept hook is in progress.
67 * @param msgname Message name to start.
68 * @param clients Array containing player indexes to broadcast to.
69 * @param numClients Number of players in the array.
70 * @param flags Optional flags to set.
71 * @return A handle to a bf_write bit packing structure, or
72 * INVALID_HANDLE on failure.
73 * @error Invalid message name or unable to start a message.
75 native Handle:StartMessage(String:msgname[], clients[], numClients, flags=0);
78 * Starts a usermessage (network message).
79 * @note Only one message can be active at a time.
80 * @note It is illegal to send any message while a non-intercept hook is in progress.
82 * @param msg Message index to start.
83 * @param clients Array containing player indexes to broadcast to.
84 * @param numClients Number of players in the array.
85 * @param flags Optional flags to set.
86 * @return A handle to a bf_write bit packing structure, or
87 * INVALID_HANDLE on failure.
88 * @error Invalid message name or unable to start a message.
90 native Handle:StartMessageEx(UserMsg:msg, clients[], numClients, flags=0);
93 * Ends a previously started user message (network message).
100 * Called when a message is hooked
102 * @param msg_id Message index.
103 * @param bf Handle to the input bit buffer of the message.
104 * @param players Array containing player indexes.
105 * @param playersNum Number of players in the array.
106 * @param reliable True if message is reliable, false otherwise.
107 * @param init True if message is an initmsg, false otherwise.
108 * @return Ignored for normal hooks. For intercept hooks, false blocks
109 * the message from being sent, and true continues.
111 functag MsgHook Action:public(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init);
114 * Called when a message is finished sending.
116 * @param msg_id Message index.
118 functag MsgSentNotify public(UserMsg:msg_id);
121 * Hooks a user message.
123 * @param msg_id Message index.
124 * @param hook Function to use as a hook.
125 * @param intercept If intercept is true, message will be fully intercepted,
126 * allowing the user to block the message. Otherwise,
127 * the hook is normal and ignores the return value.
128 * @param notify Notification function.
130 * @error Invalid message index.
132 native HookUserMessage(UserMsg:msg_id, MsgHook:hook, bool:intercept=false, MsgSentNotify:notify=MsgSentNotify:-1);
135 * Removes one usermessage hook.
137 * @param msg_id Message index.
138 * @param hook Function used for the hook.
139 * @param intercept Specifies whether the hook was an intercept hook or not.
141 * @error Invalid message index.
143 native UnhookUserMessage(UserMsg:msg_id, MsgHook:hook, bool:intercept=false);
146 * Starts a usermessage (network message) that broadcasts to all clients.
147 * @note See StartMessage or StartMessageEx().
149 * @param msgname Message name to start.
150 * @param flags Optional flags to set.
151 * @return A handle to a bf_write bit packing structure, or
152 * INVALID_HANDLE on failure.
154 stock Handle:StartMessageAll(String:msgname[], flags=0)
156 new maxClients = GetMaxClients();
158 new clients[maxClients];
159 for (new i=1; i<=maxClients; i++)
161 if (IsClientConnected(i))
163 clients[total++] = i;
166 return StartMessage(msgname, clients, total, flags);
170 * Starts a simpler usermessage (network message) for one client.
171 * @note See StartMessage or StartMessageEx().
173 * @param msgname Message name to start.
174 * @param client Client to send to.
175 * @param flags Optional flags to set.
176 * @return A handle to a bf_write bit packing structure, or
177 * INVALID_HANDLE on failure.
179 stock Handle:StartMessageOne(String:msgname[], client, flags=0)
185 return StartMessage(msgname, players, 1, flags);