karimoldacc/inline-timers
This include allows you to use inline functions as callbacks for timers, similiar to inline dialog callbacks and inline MySQL callbacks.
Mit sampctl installieren
sampctl package install karimoldacc/inline-timers
Führe das in deinem Projektordner aus. sampctl lädt das Paket und alles herunter, wovon es abhängt.
Fügt seine Include-Dateien samt der Bibliotheken, von denen es abhängt, dem Pawn-Compiler in deinem Browser hinzu, bereit zum Einbinden in ein Skript.
Hängt von 2 Paketen ab
- sampctl/samp-stdlibnicht in diesem Verzeichnis
- 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
Diese Seite wird aus dem erstellt, was GitHub über das Repository veröffentlicht. samp.directory hostet den Code nicht. Ein Problem mit diesem Eintrag melden