SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 27/03/2018, 02:10 PM   #1
iKarim
Banned
 
Join Date: Oct 2015
Posts: 579
Reputation: 142
Default inline-timers: Use y_inline functions with timers!

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:

Code:
sampctl package install ltkarim/inline-timers
GitHub: https://github.com/ltkarim/inline-timers


Include in your code and begin using the library:

PHP Code:
#include <inline-timers> 


Usage


Example:

PHP Code:
new 
    
someInt 1337,
    
someStr[] = "hello world",
    
FloatsomeFloat 1.337
;

inline TimerTest()
{
    
printf(" TimerTest called after 3 seconds! %i %s %0.3f"someIntsomeStrsomeFloat);
}
SetInlineTimer(using inline TimerTest3000false); 
Outputs:

Code:
TimerTest called! 1337, hello world, 1.337
Dependencies

  • YSI
    • y_malloc
    • y_inline

Testing


To test, simply run the package:

Code:
sampctl package run

Credits

iKarim is offline   Reply With Quote
Old 27/03/2018, 02:13 PM   #2
NelsonC
Huge Clucker
 
NelsonC's Avatar
 
Join Date: Oct 2017
Location: Germany
Posts: 309
Reputation: 18
Default Re: inline-timers: Use y_inline functions with timers!

Good job.
__________________
Perfect City RPG
NelsonC is offline   Reply With Quote
Old 20/04/2018, 07:23 PM   #3
iKarim
Banned
 
Join Date: Oct 2015
Posts: 579
Reputation: 142
Default Re: inline-timers: Use y_inline functions with timers!

Quote:
Originally Posted by [HLF]Southclaw View Post
Damn I missed this, I'm surprised this isn't part of YSI already tbh. *stares at ******* Nice work!
I always thought it's a feature of y_timers too!
iKarim is offline   Reply With Quote
Old 21/04/2018, 04:42 AM   #4
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,885
Reputation: 1337
Default Re: inline-timers: Use y_inline functions with timers!

Maybe you could extend this to textdraws/playertextdraws as well?
Pottus is offline   Reply With Quote
Old 21/04/2018, 06:35 AM   #5
Fairuz
Huge Clucker
 
Fairuz's Avatar
 
Join Date: Sep 2015
Location: Indonesia
Posts: 453
Reputation: 64
Default Re: inline-timers: Use y_inline functions with timers!

What's different with y_timers or default SetTimer function? and can you explain what is inline? Thank you.
__________________
Los Santos based Cops and Robbers with many features.
209.58.183.101:7777
Fairuz is offline   Reply With Quote
Old 21/04/2018, 07:16 AM   #6
iKarim
Banned
 
Join Date: Oct 2015
Posts: 579
Reputation: 142
Default Re: inline-timers: Use y_inline functions with timers!

Quote:
Originally Posted by Pottus View Post
Maybe you could extend this to textdraws/playertextdraws as well?
Inline textdraw click callbacks? It's possible, but I'd say it doesn't belong to this include, since this is dedicated to timers. I'll take a look though.

Quote:
Originally Posted by Dice_ View Post
What's different with y_timers or default SetTimer function? and can you explain what is inline? Thank you.
y_timers is a part of the YSI libraries, it basically extends/simplifies what you can do with normal timers, you can read more about it here: http://forum.sa-mp.com/showthread.php?t=571044

Inline functions are also a part of the YSI libraries, y_inline, it's sort of similar to anonymous functions in JavaScript or any other language, it can be used with y_dialog, BlueG's MySQL plugin and timers with this include.

PHP Code:
main() 
{
    
inline TimerTest()
    {
        
printf("called");
    }
    
SetInlineTimer(using inline TimerTest3000false);

iKarim is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
y_inline and y_dialog, inline not getting called. RaeF Scripting Help 0 22/05/2015 12:09 AM
[Tutorial] How to create custom functions, format, set timers and PVars. RajatPawar Tutorials 6 16/01/2013 05:19 AM
Using timers with inline. Yiin Scripting Help 4 20/12/2012 11:22 AM
How to use timers ? marinov Help Archive 16 28/11/2010 02:50 AM
timers KnooL Help Archive 0 05/12/2009 09:21 PM


All times are GMT. The time now is 03:19 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.