%s in SendClientMessage
#18

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
A friend of mine made this:
Код:
new FALSE = false;
#define SendClientFormattedMessage(%0,%1,%2) do{new _str[128]; format(_str,128,%2); SendClientMessage(%0,%1,_str);}while(FALSE)
#define SendClientFormattedMessageToAll(%1,%2,%3) do{new sendfstring[128];format(sendfstring,128,(%2),%3);SendClientMessageToAll((%1),sendfstring);}while(FALSE)
Which is much shorter and quicker. I think it can still be optimized, though. There's a loop in it, to make sure the "new _str;" doesn't give errors when using this function multiple times in a row. But it might be replaceable with "if (true)" or something similar, or just brackets.
pawn Код:
stock SendFormatMessage(const iPlayer, const iColor, const szFormat[], { Float, _ }: ...) { // Improved by SiX_MiX [Snir]
    new iArgs = ((numargs() - 3) << 2);
    if(iArgs){
        static _:s_szBuf[144],s_iAddr1,s_iAddr2;
        #emit ADDR.PRI szFormat
        #emit STOR.PRI s_iAddr1
        for(s_iAddr2 = s_iAddr1 + iArgs, iArgs += 12; s_iAddr2 != s_iAddr1; s_iAddr2 -= 4) {
            #emit LOAD.PRI s_iAddr2
            #emit LOAD.I
            #emit PUSH.PRI
        }
        #emit CONST.PRI s_szBuf
        #emit PUSH.S szFormat
        #emit PUSH.C 144
        #emit PUSH.PRI
        #emit PUSH.S iArgs
        #emit SYSREQ.C format
        #emit LCTRL 4
        #emit LOAD.S.ALT iArgs
        #emit ADD.C 4
        #emit ADD
        #emit SCTRL 4
        return (iPlayer != -1) ? SendClientMessage(iPlayer, iColor, s_szBuf) : SendClientMessageToAll(iColor, s_szBuf);
    }
    return (iPlayer != -1) ? SendClientMessage(iPlayer, iColor, szFormat) : SendClientMessageToAll(iColor, szFormat);
}
... this is not mine though.
Reply


Messages In This Thread
%s in SendClientMessage - by Dan.. - 13.01.2013, 09:18
Re: %s in SendClientMessage - by Kwarde - 13.01.2013, 09:49
Re: %s in SendClientMessage - by CaHbKo - 13.01.2013, 10:24
Re: %s in SendClientMessage - by TheArcher - 13.01.2013, 13:06
Re: %s in SendClientMessage - by Dan.. - 13.01.2013, 13:41
Re: %s in SendClientMessage - by TheArcher - 13.01.2013, 14:11
Re: %s in SendClientMessage - by Skyrise - 16.01.2013, 02:34
Re: %s in SendClientMessage - by mastermax7777 - 16.01.2013, 05:03
Re: %s in SendClientMessage - by Neil. - 16.01.2013, 07:05
Re: %s in SendClientMessage - by RajatPawar - 16.01.2013, 07:11
Re: %s in SendClientMessage - by leong124 - 16.01.2013, 08:13
Re: %s in SendClientMessage - by Kwarde - 16.01.2013, 12:20
Re: %s in SendClientMessage - by kaisersouse - 16.01.2013, 12:43
Re: %s in SendClientMessage - by leong124 - 16.01.2013, 13:59
Re: %s in SendClientMessage - by liquor - 22.01.2013, 20:12
Re: %s in SendClientMessage - by RootKiller - 22.01.2013, 21:02
Re: %s in SendClientMessage - by Basssiiie - 22.01.2013, 22:03
Re: %s in SendClientMessage - by TheArcher - 22.01.2013, 22:29
Re: %s in SendClientMessage - by leong124 - 23.01.2013, 06:54
Re: %s in SendClientMessage - by Basssiiie - 23.01.2013, 21:40
Re: %s in SendClientMessage - by Dan.. - 24.01.2013, 14:25
Re: %s in SendClientMessage - by leong124 - 24.01.2013, 15:10

Forum Jump:


Users browsing this thread: 1 Guest(s)