SourceMod SDK  1.7
IUserMessages.h
Go to the documentation of this file.
1 
32 #ifndef _INCLUDE_SOURCEMOD_INTERFACE_USERMESSAGES_H_
33 #define _INCLUDE_SOURCEMOD_INTERFACE_USERMESSAGES_H_
34 
35 #include <IShareSys.h>
36 #include <sp_vm_api.h>
37 #include <IForwardSys.h>
38 #include <irecipientfilter.h>
39 
40 namespace google { namespace protobuf {
41  class Message;
42 } };
43 
44 class bf_write;
45 
51 #define SMINTERFACE_USERMSGS_NAME "IUserMessages"
52 #define SMINTERFACE_USERMSGS_VERSION 4
53 
54 namespace SourceMod
55 {
56  enum UserMessageType
57  {
58  UM_BitBuf,
59  UM_Protobuf,
60  };
61 
66  {
67  public:
76  virtual void OnUserMessageSent(int msg_id)
77  {
78  }
79 
83  virtual unsigned int GetUserMessageAPIVersion()
84  {
85  return SMINTERFACE_USERMSGS_VERSION;
86  }
87 
96  virtual void OnPostUserMessage(int msg_id, bool sent)
97  {
98  }
99 
100  virtual UserMessageType GetUserMessageType() const =0;
101  };
102 
104  {
105  public:
114  virtual void OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
115  {
116  }
117 
126  virtual ResultType InterceptUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
127  {
128  return Pl_Continue;
129  }
130 
131  virtual UserMessageType GetUserMessageType() const
132  {
133  return UM_BitBuf;
134  }
135  };
136 
138  {
139  public:
148  virtual void OnUserMessage(int msg_id, google::protobuf::Message *msg, IRecipientFilter *pFilter)
149  {
150  }
151 
160  virtual ResultType InterceptUserMessage(int msg_id, google::protobuf::Message *msg, IRecipientFilter *pFilter)
161  {
162  return Pl_Continue;
163  }
164 
165  virtual UserMessageType GetUserMessageType() const
166  {
167  return UM_Protobuf;
168  }
169  };
170 
171  #define USERMSG_RELIABLE (1<<2)
172  #define USERMSG_INITMSG (1<<3)
173  #define USERMSG_BLOCKHOOKS (1<<7)
178  class IUserMessages : public SMInterface
179  {
180  public:
181  virtual unsigned int GetInterfaceVersion()
182  {
183  return SMINTERFACE_USERMSGS_VERSION;
184  }
185  virtual const char *GetInterfaceName()
186  {
187  return SMINTERFACE_USERMSGS_NAME;
188  }
189  public:
196  virtual int GetMessageIndex(const char *msg) =0;
197 
206  virtual bool HookUserMessage(int msg_id,
207  IUserMessageListener *pListener,
208  bool intercept=false) =0;
209 
219  virtual bool UnhookUserMessage(int msg_id,
220  IUserMessageListener *pListener,
221  bool intercept=false) =0;
222 
232  virtual bf_write *StartBitBufMessage(int msg_id,
233  const cell_t players[],
234  unsigned int playersNum,
235  int flags) =0;
236 
237  virtual google::protobuf::Message *StartProtobufMessage(int msg_id,
238  const cell_t players[],
239  unsigned int playersNum,
240  int flags) =0;
241 
246  virtual bool EndMessage() =0;
247 
256  virtual bool HookUserMessage2(int msg_id,
257  IUserMessageListener *pListener,
258  bool intercept=false) =0;
259 
269  virtual bool UnhookUserMessage2(int msg_id,
270  IUserMessageListener *pListener,
271  bool intercept=false) =0;
272 
281  virtual bool GetMessageName(int msgid, char *buffer, size_t maxlength) const =0;
282 
288  virtual UserMessageType GetUserMessageType() const =0;
289  };
290 }
291 
292 #endif //_INCLUDE_SOURCEMOD_INTERFACE_USERMESSAGES_H_
Defines the interface for managing collections ("forwards") of plugin calls.
virtual void OnPostUserMessage(int msg_id, bool sent)
Called when a hooked user message hook is finished, regardless of the hook type.
Definition: IUserMessages.h:96
Defines the Share System, responsible for shared resources and dependencies.
virtual const char * GetInterfaceName()
Must return a string defining the interface's unique name.
Definition: IUserMessages.h:185
virtual void OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
Called when a hooked user message is being sent and all interceptions have finished.
Definition: IUserMessages.h:114
virtual void OnUserMessage(int msg_id, google::protobuf::Message *msg, IRecipientFilter *pFilter)
Called when a hooked user message is being sent and all interceptions have finished.
Definition: IUserMessages.h:148
virtual ResultType InterceptUserMessage(int msg_id, google::protobuf::Message *msg, IRecipientFilter *pFilter)
Called when a hooked user message is intercepted.
Definition: IUserMessages.h:160
virtual ResultType InterceptUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
Called when a hooked user message is intercepted.
Definition: IUserMessages.h:126
virtual unsigned int GetUserMessageAPIVersion()
Returns the user message API version.
Definition: IUserMessages.h:83
Definition: IAdminSystem.h:63
virtual void OnUserMessageSent(int msg_id)
Called when a hooked user message is sent, regardless of the hook type.
Definition: IUserMessages.h:76
Definition: IUserMessages.h:103
virtual unsigned int GetInterfaceVersion()
Must return an integer defining the interface's version.
Definition: IUserMessages.h:181
Definition: IUserMessages.h:40
Listens to user messages sent from the server.
Definition: IUserMessages.h:65
Definition: IUserMessages.h:137