karimoldacc/inline-timers
This include allows you to use inline functions as callbacks for timers, similiar to inline dialog callbacks and inline MySQL callbacks.
Instalar con sampctl
sampctl package install karimoldacc/inline-timers
Ejecútalo en la carpeta de tu proyecto. sampctl descarga el paquete y sus dependencias.
Depende de 2 paquetes
- sampctl/samp-stdlibno está en este directorio
- pawn-lang/YSI-Includes★ 226
README.md
inline_timers
This include allows you to use inline functions as callbacks for timers, similiar to inline dialog callbacks and inline MySQL callbacks.
There is no support for passing extra arguments through this, because the variables (and arguments) in the parent function are accessible in the inline function as well due to a feature called "closuers", thus rendering the usage of the extra arguments useless. This is however a feature of YSI itself and it has nothing to do with this include.
Installation
Simply install to your project:
sampctl package install ltkarim/inline-timers
Include in your code and begin using the library:
#include <inline_timers>
Usage
SetInlineTimer(callback: callback, delay, repeat)
- Parameters:
callback: The inline callback to use.delay: The interval of the timer in milliseconds.repeat: whether the timer should repeat or not.- Returns:
falseon failure,IDto be used withKillInlineTimeron success.
Starts a timer with the specified interval.
NOTE: This function does NOT return the timer ID, rather the malloc address that contains the timer ID and callback data. You can't use KillTimer to kill it!
KillInlineTimer(timer)
- Parameters:
timer: The timer ID returned bySetInlineTimer.- Returns:
trueregardless of the result.
Stops the specified timer.
NOTE: Inline timers have to be killed with the above function since it allocates extra memory that need to be freed.
Example:
new
someInt = 1337,
someStr[] = "hello world",
Float: someFloat = 1.337
;
inline TimerTest()
{
printf(" TimerTest called after 3 seconds! %i, %s, %0.3f", someInt, someStr, someFloat);
}
SetInlineTimer(using inline TimerTest, 3000, false);
Outputs:
TimerTest called! 1337, hello world, 1.337
Dependencies
- YSI
- y_malloc
- y_inline
Testing
To test, simply run the package:
sampctl package run
Credits
Esta página se genera con lo que GitHub publica sobre el repositorio. samp.directory no aloja el código. Informar de un problema con esta ficha