changed SOUND_FROM_PLAYER from -1 to -2 to maintain compatibility with SOUND_FROM_LOCAL_PLAYER
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 _timers_included
19 #define _timers_included
23 #define TIMER_REPEAT (1<<0) /**< Timer will repeat until it returns Plugin_Stop */
24 #define TIMER_HNDL_CLOSE (1<<9) /**< Timer will automatically call CloseHandle() on its value when finished */
27 * Any of the following prototypes will work for a timed function.
32 * Called when the timer interval has elapsed.
34 * @param timer Handle to the timer object.
35 * @param hndl Handle passed when the timer was created.
36 * @return Plugin_Stop to stop a repeating timer, any other value for
39 Action:public(Handle:timer, Handle:hndl),
42 * Called when the timer interval has elapsed.
44 * @param timer Handle to the timer object.
45 * @param value Value passed when the timer was created.
46 * @return Plugin_Stop to stop a repeating timer, any other value for
49 Action:public(Handle:timer, any:value),
52 * Called when the timer interval has elapsed.
54 * @param timer Handle to the timer object.
55 * @return Plugin_Stop to stop a repeating timer, any other value for
58 Action:public(Handle:timer),
62 * Creates a basic timer. Calling CloseHandle() on a timer will end the timer.
64 * @param interval Interval from the current game time to execute the given function.
65 * @param func Function to execute once the given interval has elapsed.
66 * @param value Handle or value to give to the timer function.
67 * @param flags Flags to set (such as repeatability or auto-Handle closing).
68 * @return Handle to the timer object. You do not need to call CloseHandle().
70 native Handle:CreateTimer(Float:interval, Timer:func, any:value=INVALID_HANDLE, flags=0);
73 * Kills a timer. Use this instead of CloseHandle() if you need more options.
75 * @param autoClose If autoClose is true, the timer's value will be
76 * closed as a handle if TIMER_HNDL_CLOSE was not specified.
79 native KillTimer(Handle:timer, bool:autoClose=false);
82 * Manually triggers a timer so its function will be called.
84 * @param timer Timer Handle to trigger.
85 * @param reset If reset is true, the elapsed time counter is reset
86 * so the full interval must pass again.
89 native TriggerTimer(Handle:timer, bool:reset=false);
92 * Returns the simulated game time.
94 * @param simulated Retrieves whether or not the tick count
95 * is being manually simulated by SourceMod.
96 * This is the case if no players have joined
98 * @return Time based on the game tick count.
100 native Float:GetTickedTime(&bool:simulated);
103 * Creates a timer associated with a new data pack, and returns the datapack.
104 * @note The datapack is automatically freed when the timer ends.
105 * @note The position of the datapack is not reset or changed for the timer function.
107 * @param interval Interval from the current game time to execute the given function.
108 * @param func Function to execute once the given interval has elapsed.
109 * @param data The newly created datapack is passed though this by-reference parameter.
110 * @param flags Timer flags.
111 * @return Handle to the timer object. You do not need to call CloseHandle().
113 stock Handle:CreateDataTimer(Float:interval, Timer:func, &Handle:data, flags=0)
115 data = CreateDataPack();
116 flags |= TIMER_HNDL_CLOSE;
117 return CreateTimer(interval, func, data, flags);