plugins/include/events.inc
author Scott Ehlert <ds@alliedmods.net>
Fri Jun 22 15:37:12 2007 +0000 (2007-06-22)
changeset 1001 8de56a71f200
parent 801 712a6e20b3e1
child 1330 ab94316bb52b
permissions -rw-r--r--
Implemented amb423 - Added IsClientObserver() native
ds@576
     1
/**
ds@576
     2
 * vim: set ts=4 :
ds@576
     3
 * ===============================================================
ds@576
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
ds@576
     5
 * ===============================================================
ds@576
     6
 *
ds@576
     7
 *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
ds@576
     8
 * or modified under the Terms and Conditions of its License Agreement, which is found 
ds@576
     9
 * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
ds@576
    10
 * may change at any time.  To view the latest information, see:
ds@576
    11
 *   http://www.sourcemod.net/license.php
ds@576
    12
 *
ds@576
    13
 * Version: $Id$
ds@576
    14
 */
ds@576
    15
 
ds@576
    16
#if defined _events_included
ds@576
    17
 #endinput
ds@576
    18
#endif
ds@576
    19
#define _events_included
ds@576
    20
ds@576
    21
/**
ds@576
    22
 * Event hook modes determining how hooking should be handled
ds@576
    23
 */
ds@576
    24
enum EventHookMode
ds@576
    25
{
ds@576
    26
	EventHookMode_Pre,					/**< Hook callback fired before event is fired */
ds@576
    27
	EventHookMode_Post,					/**< Hook callback fired after event is fired */
ds@576
    28
	EventHookMode_PostNoCopy			/**< Hook callback fired after event is fired, but event data won't be copied */
ds@576
    29
};
ds@576
    30
dvander@619
    31
/**
dvander@619
    32
 * Hook function types for events.
dvander@619
    33
 */
ds@576
    34
funcenum EventHook
ds@576
    35
{
ds@576
    36
	/**
ds@576
    37
	 * Called when a game event is fired.
ds@576
    38
	 *
ds@576
    39
	 * @param event			Handle to event. This could be INVALID_HANDLE if every plugin hooking 
ds@576
    40
	 *						this event has set the hook mode EventHookMode_PostNoCopy.
ds@576
    41
	 * @param name			String containing the name of the event.
ds@576
    42
	 * @param dontBroadcast	True if event was not broadcast to clients, false otherwise.
ds@576
    43
	 * @return				Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
ds@576
    44
	 */
ds@576
    45
	Action:public(Handle:event, const String:name[], bool:dontBroadcast),
ds@576
    46
	/**
ds@576
    47
	 * Called when a game event is fired.
ds@576
    48
	 *
ds@576
    49
	 * @param event			Handle to event. This could be INVALID_HANDLE if every plugin hooking 
ds@576
    50
	 *						this event has set the hook mode EventHookMode_PostNoCopy.
ds@576
    51
	 * @param name			String containing the name of the event.
ds@576
    52
	 * @param dontBroadcast	True if event was not broadcast to clients, false otherwise.
ds@576
    53
	 * @noreturn
ds@576
    54
	 */
ds@576
    55
	public(Handle:event, const String:name[], bool:dontBroadcast),
ds@576
    56
};
ds@576
    57
ds@576
    58
/**
ds@576
    59
 * Creates a hook for when a game event is fired.
ds@576
    60
 *
ds@576
    61
 * @param name			Name of event.
ds@576
    62
 * @param callback		An EventHook function pointer.
ds@576
    63
 * @param mode			Optional EventHookMode determining the type of hook.
ds@576
    64
 * @noreturn
ds@576
    65
 * @error				Invalid event name or invalid callback function.
ds@576
    66
 */
ds@576
    67
native HookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
ds@576
    68
ds@576
    69
/**
ds@801
    70
 * Creates a hook for when a game event is fired.
ds@801
    71
 *
ds@801
    72
 * @param name			Name of event.
ds@801
    73
 * @param callback		An EventHook function pointer.
ds@801
    74
 * @param mode			Optional EventHookMode determining the type of hook.
ds@801
    75
 * @return				True if event exists and was hooked successfully, false otherwise.
ds@801
    76
 * @error				Invalid callback function.
ds@801
    77
 */
ds@801
    78
native bool:HookEventEx(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
ds@801
    79
ds@801
    80
/**
ds@576
    81
 * Removes a hook for when a game event is fired.
ds@576
    82
 *
ds@576
    83
 * @param name			Name of event.
ds@576
    84
 * @param callback		An EventHook function pointer.
ds@576
    85
 * @param mode			Optional EventHookMode determining the type of hook.
ds@576
    86
 * @noreturn
ds@576
    87
 * @error				Invalid callback function or no active hook for specified event.
ds@576
    88
 */
ds@576
    89
native UnhookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
ds@576
    90
ds@576
    91
/**
ds@576
    92
 * Creates a game event to be fired later.
ds@576
    93
 *
ds@576
    94
 * @param name			Name of event.
ds@713
    95
 * @param force			If set to true, this forces the event to be created even if it's not being hooked.
ds@713
    96
 *						Note that this will not force it if the event doesn't exist at all.
ds@713
    97
 * @return				Handle to event. INVALID_HANDLE is returned if the event doesn't exist or isn't 
ds@713
    98
						being hooked (unless force is true).
ds@576
    99
 */
ds@713
   100
native Handle:CreateEvent(const String:name[], bool:force=false);
ds@576
   101
ds@576
   102
/**
ds@576
   103
 * Fires a game event.
ds@576
   104
 *
ds@576
   105
 * @param event			Handle to the event.
ds@576
   106
 * @param dontBroadcast	Optional boolean that determines if event should be broadcast to clients.
ds@576
   107
 * @noreturn
ds@576
   108
 * @error				Invalid or corrupt Handle.
ds@576
   109
 */
ds@712
   110
native FireEvent(Handle:event, bool:dontBroadcast=false);
ds@576
   111
ds@576
   112
/**
ds@576
   113
 * Cancels a previously created game event that has not been fired.
ds@576
   114
 *
ds@576
   115
 * @param event			Handled to the event.
ds@576
   116
 * @noreturn
ds@576
   117
 * @error				Invalid or corrupt Handle.
ds@576
   118
 */
ds@576
   119
native CancelCreatedEvent(Handle:event);
ds@576
   120
ds@576
   121
/**
ds@576
   122
 * Returns the boolean value of a game event's key.
ds@576
   123
 *
ds@576
   124
 * @param event			Handle to the event.
ds@576
   125
 * @param key			Name of event key.
ds@576
   126
 * @return				The boolean value of the specfied event key.
ds@576
   127
 * @error				Invalid or corrupt Handle.
ds@576
   128
 */
ds@576
   129
native bool:GetEventBool(Handle:event, const String:key[]);
ds@576
   130
ds@576
   131
/**
ds@576
   132
 * Sets the boolean value of a game event's key.
ds@576
   133
 *
ds@576
   134
 * @param event			Handle to the event.
ds@576
   135
 * @param key			Name of event key.
ds@576
   136
 * @param value			New boolean value.
ds@576
   137
 * @noreturn
ds@576
   138
 * @error				Invalid or corrupt Handle.
ds@576
   139
 */
ds@576
   140
native SetEventBool(Handle:event, const String:key[], bool:value);
ds@576
   141
ds@576
   142
/**
ds@576
   143
 * Returns the integer value of a game event's key.
ds@576
   144
 *
ds@576
   145
 * @param event			Handle to the event.
ds@576
   146
 * @param key			Name of event key.
ds@576
   147
 * @return				The integer value of the specfied event key.
ds@576
   148
 * @error				Invalid or corrupt Handle.
ds@576
   149
 */
ds@576
   150
native GetEventInt(Handle:event, const String:key[]);
ds@576
   151
ds@576
   152
/**
ds@576
   153
 * Sets the integer value of a game event's key.
ds@576
   154
 *
ds@576
   155
 * @param event			Handle to the event.
ds@576
   156
 * @param key			Name of event key.
ds@576
   157
 * @param value			New integer value.
ds@576
   158
 * @noreturn
ds@576
   159
 * @error				Invalid or corrupt Handle.
ds@576
   160
 */
ds@576
   161
native SetEventInt(Handle:event, const String:key[], value);
ds@576
   162
ds@576
   163
/**
ds@576
   164
 * Returns the floating point value of a game event's key.
ds@576
   165
 *
ds@576
   166
 * @param event			Handle to the event.
ds@576
   167
 * @param key			Name of event key.
ds@576
   168
 * @return				The floating point value of the specfied event key.
ds@576
   169
 * @error				Invalid or corrupt Handle.
ds@576
   170
 */
ds@576
   171
native Float:GetEventFloat(Handle:event, const String:key[]);
ds@576
   172
ds@576
   173
/**
ds@576
   174
 * Sets the floating point value of a game event's key.
ds@576
   175
 *
ds@576
   176
 * @param event			Handle to the event.
ds@576
   177
 * @param key			Name of event key.
ds@576
   178
 * @param value			New floating point value.
ds@576
   179
 * @noreturn
ds@576
   180
 * @error				Invalid or corrupt Handle.
ds@576
   181
 */
ds@576
   182
native SetEventFloat(Handle:event, const String:key[], Float:value);
ds@576
   183
ds@576
   184
/**
ds@576
   185
 * Retrieves the string value of a game event's key.
ds@576
   186
 *
ds@576
   187
 * @param event			Handle to the event.
ds@576
   188
 * @param key			Name of event key.
ds@576
   189
 * @param value			Buffer to store the value of the specified event key.
ds@576
   190
 * @param maxlength		Maximum length of string buffer.
ds@576
   191
 * @noreturn
ds@576
   192
 * @error				Invalid or corrupt Handle.
ds@576
   193
 */
ds@576
   194
native GetEventString(Handle:event, const String:key[], String:value[], maxlength);
ds@576
   195
ds@576
   196
/**
ds@576
   197
 * Sets the string value of a game event's key.
ds@576
   198
 *
ds@576
   199
 * @param event			Handle to the event.
ds@576
   200
 * @param key			Name of event key.
ds@576
   201
 * @param value			New string value.
ds@576
   202
 * @noreturn
ds@576
   203
 * @error				Invalid or corrupt Handle.
ds@576
   204
 */
ds@576
   205
native SetEventString(Handle:event, const String:key[], const String:value[]);
ds@576
   206
ds@576
   207
/**
ds@576
   208
 * Retrieves the name of a game event.
ds@576
   209
 *
ds@576
   210
 * @param event			Handle to the event.
ds@576
   211
 * @param value			Buffer to store the name of the event.
ds@576
   212
 * @param maxlength		Maximum length of string buffer.
ds@576
   213
 * @noreturn
ds@576
   214
 * @error				Invalid or corrupt Handle.     
ds@576
   215
 */
ds@576
   216
native GetEventName(Handle:event, String:name[], maxlength);