SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/03/2019, 11:55 PM   #1
polygxn
Big Clucker
 
polygxn's Avatar
 
Join Date: Dec 2018
Location: Hungary
Posts: 75
Reputation: 1
Default Calling an inline function (y_inline)?

Stupid question, but how?

PHP Code:
function MainFunction() {
    for (new 
ii<SOME_THINGi++) {
        
//I want to call SomeFunction here
        
SomeFunction(); // Not working
    
}

    
inline SomeFunction() {
        print(
":)");
    }

polygxn is offline   Reply With Quote
Old 17/03/2019, 12:05 AM   #2
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,831
Reputation: 3244
Default Re: Calling an inline function (y_inline)?

You canít quite do that. y_inline assumes that you are always passing the function as a parameter somewhere else. The best you can do is:

Code:
Looper(Func:function<>)
{
    for (new i = 0; i != SOME_THING; ++i)
    {
        @.function();
    }
}

main()
{
    inline SomeFunction()
    {
    }
    Looper(using inline SomeFunction);
}
Y_Less is online now   Reply With Quote
Old 17/03/2019, 12:11 AM   #3
polygxn
Big Clucker
 
polygxn's Avatar
 
Join Date: Dec 2018
Location: Hungary
Posts: 75
Reputation: 1
Default Re: Calling an inline function (y_inline)?

Quote:
Originally Posted by Y_Less View Post
You canít quite do that. y_inline assumes that you are always passing the function as a parameter somewhere else. The best you can do is:

Code:
Looper(Func:function<>)
{
    for (new i = 0; i != SOME_THING; ++i)
    {
        @.function();
    }
}

main()
{
    inline SomeFunction()
    {
    }
    Looper(using inline SomeFunction);
}
Oh, okay, thanks! I just want to keep my code way too clean sometimes I do stupid things, but at least I know this is not possible.
polygxn is offline   Reply With Quote
Old 17/03/2019, 12:19 AM   #4
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,831
Reputation: 3244
Default Re: Calling an inline function (y_inline)?

I did some testing, this will compile (note the extra brackets around using due to a quirk in the syntax):

Code:
main()
{
    inline X()
    {
        printf("hi");
    }
    new Func:x<> = (using inline X);
    @.x();
}
However, it crashes at the @ call. I might look in to seeing what it would take to make it work fully.
Y_Less is online now   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
[Include] inline-timers: Use y_inline functions with timers! iKarim Includes 7 21/04/2018 07:16 AM
y_inline and y_dialog, inline not getting called. RaeF Scripting Help 0 22/05/2015 12:09 AM
YSI Error: Format specifier didn't match on inline function LoadUser_Data. LivingLikeYouDo Scripting Help 3 26/07/2014 05:42 PM
Using inline function gives me errors. How to fix it? Cameryn Scripting Help 3 10/01/2014 12:18 AM
YSI:Format specifier didn't match on inline function dusk Scripting Help 3 19/03/2013 03:22 PM


All times are GMT. The time now is 08:37 PM.


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