Shorten this - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Shorten this (
/showthread.php?tid=672253)
Shorten this -
Symon - 02.02.2020
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);
}
Re: Shorten this -
Markski - 03.02.2020
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)
Re: Shorten this -
Symon - 03.02.2020
Oh thanks, i guess i'll stick with the original function then.
Re: Shorten this -
Nero_3D - 03.02.2020
you can use a little trick to make it faster and shorter