plugins/include/events.inc
author Borja Ferrer <faluco@alliedmods.net>
Wed Mar 28 23:35:12 2007 +0000 (2007-03-28)
changeset 658 b46ff98c249b
parent 619 6934bf39171e
child 712 7accb9b0ae5d
permissions -rw-r--r--
added iplayerinfo natives
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
 * Flags for firing game events
ds@576
    23
 */
ds@576
    24
#define EVENT_PASSTHRU_ALL	(1<<1)		/**< Event will pass through other SourceMM plugins AND SourceMod */
ds@576
    25
ds@576
    26
/**
ds@576
    27
 * Event hook modes determining how hooking should be handled
ds@576
    28
 */
ds@576
    29
enum EventHookMode
ds@576
    30
{
ds@576
    31
	EventHookMode_Pre,					/**< Hook callback fired before event is fired */
ds@576
    32
	EventHookMode_Post,					/**< Hook callback fired after event is fired */
ds@576
    33
	EventHookMode_PostNoCopy			/**< Hook callback fired after event is fired, but event data won't be copied */
ds@576
    34
};
ds@576
    35
dvander@619
    36
/**
dvander@619
    37
 * Hook function types for events.
dvander@619
    38
 */
ds@576
    39
funcenum EventHook
ds@576
    40
{
ds@576
    41
	/**
ds@576
    42
	 * Called when a game event is fired.
ds@576
    43
	 *
ds@576
    44
	 * @param event			Handle to event. This could be INVALID_HANDLE if every plugin hooking 
ds@576
    45
	 *						this event has set the hook mode EventHookMode_PostNoCopy.
ds@576
    46
	 * @param name			String containing the name of the event.
ds@576
    47
	 * @param dontBroadcast	True if event was not broadcast to clients, false otherwise.
ds@576
    48
	 * @return				Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
ds@576
    49
	 */
ds@576
    50
	Action:public(Handle:event, const String:name[], bool:dontBroadcast),
ds@576
    51
	/**
ds@576
    52
	 * Called when a game event is fired.
ds@576
    53
	 *
ds@576
    54
	 * @param event			Handle to event. This could be INVALID_HANDLE if every plugin hooking 
ds@576
    55
	 *						this event has set the hook mode EventHookMode_PostNoCopy.
ds@576
    56
	 * @param name			String containing the name of the event.
ds@576
    57
	 * @param dontBroadcast	True if event was not broadcast to clients, false otherwise.
ds@576
    58
	 * @noreturn
ds@576
    59
	 */
ds@576
    60
	public(Handle:event, const String:name[], bool:dontBroadcast),
ds@576
    61
};
ds@576
    62
ds@576
    63
/**
ds@576
    64
 * Creates a hook for when a game event is fired.
ds@576
    65
 *
ds@576
    66
 * @param name			Name of event.
ds@576
    67
 * @param callback		An EventHook function pointer.
ds@576
    68
 * @param mode			Optional EventHookMode determining the type of hook.
ds@576
    69
 * @noreturn
ds@576
    70
 * @error				Invalid event name or invalid callback function.
ds@576
    71
 */
ds@576
    72
native HookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
ds@576
    73
ds@576
    74
/**
ds@576
    75
 * Removes a hook for when a game event is fired.
ds@576
    76
 *
ds@576
    77
 * @param name			Name of event.
ds@576
    78
 * @param callback		An EventHook function pointer.
ds@576
    79
 * @param mode			Optional EventHookMode determining the type of hook.
ds@576
    80
 * @noreturn
ds@576
    81
 * @error				Invalid callback function or no active hook for specified event.
ds@576
    82
 */
ds@576
    83
native UnhookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
ds@576
    84
ds@576
    85
/**
ds@576
    86
 * Creates a game event to be fired later.
ds@576
    87
 *
ds@576
    88
 * @param name			Name of event.
ds@576
    89
 * @return				Handle to event or INVALID_HANDLE if event doesn't exist.
ds@576
    90
 */
ds@576
    91
native Handle:CreateEvent(const String:name[]);
ds@576
    92
ds@576
    93
/**
ds@576
    94
 * Fires a game event.
ds@576
    95
 *
ds@576
    96
 * @param event			Handle to the event.
ds@577
    97
 * @param flags			Optional bitstring flags. See EVENT_* constants for more details.
ds@576
    98
 * @param dontBroadcast	Optional boolean that determines if event should be broadcast to clients.
ds@576
    99
 * @noreturn
ds@576
   100
 * @error				Invalid or corrupt Handle.
ds@576
   101
 */
ds@577
   102
native FireEvent(Handle:event, flags=0, bool:dontBroadcast=false);
ds@576
   103
ds@576
   104
/**
ds@576
   105
 * Cancels a previously created game event that has not been fired.
ds@576
   106
 *
ds@576
   107
 * @param event			Handled to the event.
ds@576
   108
 * @noreturn
ds@576
   109
 * @error				Invalid or corrupt Handle.
ds@576
   110
 */
ds@576
   111
native CancelCreatedEvent(Handle:event);
ds@576
   112
ds@576
   113
/**
ds@576
   114
 * Returns the boolean value of a game event's key.
ds@576
   115
 *
ds@576
   116
 * @param event			Handle to the event.
ds@576
   117
 * @param key			Name of event key.
ds@576
   118
 * @return				The boolean value of the specfied event key.
ds@576
   119
 * @error				Invalid or corrupt Handle.
ds@576
   120
 */
ds@576
   121
native bool:GetEventBool(Handle:event, const String:key[]);
ds@576
   122
ds@576
   123
/**
ds@576
   124
 * Sets the boolean value of a game event's key.
ds@576
   125
 *
ds@576
   126
 * @param event			Handle to the event.
ds@576
   127
 * @param key			Name of event key.
ds@576
   128
 * @param value			New boolean value.
ds@576
   129
 * @noreturn
ds@576
   130
 * @error				Invalid or corrupt Handle.
ds@576
   131
 */
ds@576
   132
native SetEventBool(Handle:event, const String:key[], bool:value);
ds@576
   133
ds@576
   134
/**
ds@576
   135
 * Returns the integer value of a game event's key.
ds@576
   136
 *
ds@576
   137
 * @param event			Handle to the event.
ds@576
   138
 * @param key			Name of event key.
ds@576
   139
 * @return				The integer value of the specfied event key.
ds@576
   140
 * @error				Invalid or corrupt Handle.
ds@576
   141
 */
ds@576
   142
native GetEventInt(Handle:event, const String:key[]);
ds@576
   143
ds@576
   144
/**
ds@576
   145
 * Sets the integer value of a game event's key.
ds@576
   146
 *
ds@576
   147
 * @param event			Handle to the event.
ds@576
   148
 * @param key			Name of event key.
ds@576
   149
 * @param value			New integer value.
ds@576
   150
 * @noreturn
ds@576
   151
 * @error				Invalid or corrupt Handle.
ds@576
   152
 */
ds@576
   153
native SetEventInt(Handle:event, const String:key[], value);
ds@576
   154
ds@576
   155
/**
ds@576
   156
 * Returns the floating point value of a game event's key.
ds@576
   157
 *
ds@576
   158
 * @param event			Handle to the event.
ds@576
   159
 * @param key			Name of event key.
ds@576
   160
 * @return				The floating point value of the specfied event key.
ds@576
   161
 * @error				Invalid or corrupt Handle.
ds@576
   162
 */
ds@576
   163
native Float:GetEventFloat(Handle:event, const String:key[]);
ds@576
   164
ds@576
   165
/**
ds@576
   166
 * Sets the floating point value of a game event's key.
ds@576
   167
 *
ds@576
   168
 * @param event			Handle to the event.
ds@576
   169
 * @param key			Name of event key.
ds@576
   170
 * @param value			New floating point value.
ds@576
   171
 * @noreturn
ds@576
   172
 * @error				Invalid or corrupt Handle.
ds@576
   173
 */
ds@576
   174
native SetEventFloat(Handle:event, const String:key[], Float:value);
ds@576
   175
ds@576
   176
/**
ds@576
   177
 * Retrieves the string value of a game event's key.
ds@576
   178
 *
ds@576
   179
 * @param event			Handle to the event.
ds@576
   180
 * @param key			Name of event key.
ds@576
   181
 * @param value			Buffer to store the value of the specified event key.
ds@576
   182
 * @param maxlength		Maximum length of string buffer.
ds@576
   183
 * @noreturn
ds@576
   184
 * @error				Invalid or corrupt Handle.
ds@576
   185
 */
ds@576
   186
native GetEventString(Handle:event, const String:key[], String:value[], maxlength);
ds@576
   187
ds@576
   188
/**
ds@576
   189
 * Sets the string value of a game event's key.
ds@576
   190
 *
ds@576
   191
 * @param event			Handle to the event.
ds@576
   192
 * @param key			Name of event key.
ds@576
   193
 * @param value			New string value.
ds@576
   194
 * @noreturn
ds@576
   195
 * @error				Invalid or corrupt Handle.
ds@576
   196
 */
ds@576
   197
native SetEventString(Handle:event, const String:key[], const String:value[]);
ds@576
   198
ds@576
   199
/**
ds@576
   200
 * Retrieves the name of a game event.
ds@576
   201
 *
ds@576
   202
 * @param event			Handle to the event.
ds@576
   203
 * @param value			Buffer to store the name of the event.
ds@576
   204
 * @param maxlength		Maximum length of string buffer.
ds@576
   205
 * @noreturn
ds@576
   206
 * @error				Invalid or corrupt Handle.     
ds@576
   207
 */
ds@576
   208
native GetEventName(Handle:event, String:name[], maxlength);