SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 02/02/2020, 07:59 PM   #1
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 924
Reputation: 91
Default Shorten this

I wonder if there's a way to shorten this function and make a macro instead (#define SendClientMessageEx ...)

pawn Code:
stock SendClientMessageEx(playerid, color, const str[], {Float,_}:...)
{
    static args, start, end,string[200];
    #emit LOAD.S.pri 8
    #emit STOR.pri args

    if(args > 12)
    {
        #emit ADDR.pri str
        #emit STOR.pri start

        for(end = start + (args - 12); end > start; end -= 4)
        {
            #emit LREF.pri end
            #emit PUSH.pri
        }
        #emit PUSH.S str
        #emit PUSH.C 156
        #emit PUSH.C string
        #emit PUSH.C args
        #emit SYSREQ.C format

        SCM(playerid, color, string);

        #emit LCTRL 5
        #emit SCTRL 4
        #emit RETN
    }
    return SCM(playerid, color, str);
}
Symon is offline   Reply With Quote
Old 03/02/2020, 03:24 AM   #2
Markski
Big Clucker
 
Markski's Avatar
 
Join Date: Apr 2015
Location: La Plata, Argentina
Posts: 133
Reputation: 59
Default Re: Shorten this

What's wrong with that? IMO it's the best approach for this solution.

To answer your question though, there's this:

Code:
stock bool:FALSE = false;
new scmExStr[144];
#define SendClientMessageEx(%0,%1,%2,%3) do{format(scmExStr,144,%2,%3);SendClientMessage(%0,%1,scmExStr);}while(FALSE)
But it has a few caveats

- You can't return this function
- You can't use it unless you give it more args (which you shouldn't anyways)
Markski is offline   Reply With Quote
Old 03/02/2020, 07:47 AM   #3
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 924
Reputation: 91
Default Re: Shorten this

Oh thanks, i guess i'll stick with the original function then.
Symon is offline   Reply With Quote
Old 03/02/2020, 02:19 PM   #4
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,853
Reputation: 689
Default Re: Shorten this

you can use a little trick to make it faster and shorter
Nero_3D 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
How can I shorten it ? NeXoR Scripting Help 4 04/03/2016 11:14 AM
[Include] shorten.inc - than simply shorten the work mathuusho Includes 4 26/10/2013 04:52 PM
How to shorten this up a bit? Pawnie Scripting Help 4 18/10/2013 07:41 PM
Shorten help basse Scripting Help 6 30/09/2012 06:07 PM
Way to shorten this? Kitten Help Archive 4 19/06/2011 05:11 AM


All times are GMT. The time now is 05:27 PM.


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