[Include] formatex - Improved "format" function!
#28

Quote:
Originally Posted by Joey^
Посмотреть сообщение
Is there any way to use your formatex and the va_format from y_va together?

Cause I use SendClientMessageEx with va_format and I want to use your custom format in SCMEx.
pawn Код:
stock va_formatex(output[], size = sizeof(output), const fmat[], va_:STATIC_ARGS) {
    new
        num_args,
        arg_start,
        arg_end;
    // Get the pointer to the number of arguments to the last function.
    #emit LOAD.S.pri   0
    #emit ADD.C        8
    #emit MOVE.alt
    // Get the number of arguments.
    #emit LOAD.I
    #emit STOR.S.pri   num_args
    // Get the variable arguments (end).
    #emit ADD
    #emit STOR.S.pri   arg_end
    // Get the variable arguments (start).
    #emit LOAD.S.pri   STATIC_ARGS
    #emit SMUL.C       4
    #emit ADD
    #emit STOR.S.pri   arg_start
    // Using an assembly loop here screwed the code up as the labels added some
    // odd stack/frame manipulation code...
    while (arg_end != arg_start)
    {
        #emit MOVE.pri
        #emit LOAD.I
        #emit PUSH.pri
        #emit CONST.pri    4
        #emit SUB.alt
        #emit STOR.S.pri   arg_end
    }
    // Push the additional parameters.
    #emit PUSH.S       fmat
    #emit PUSH.S       size
    #emit PUSH.S       output
    // Push the argument count.
    #emit LOAD.S.pri   num_args
    #emit ADD.C        12
    #emit LOAD.S.alt   STATIC_ARGS
    #emit XCHG
    #emit SMUL.C       4
    #emit SUB.alt
    #emit PUSH.pri
    #emit MOVE.alt
    // Push the return address.
    #emit LCTRL        6
    #emit ADD.C        28
    #emit PUSH.pri
    // Call formatex
    #emit CONST.pri    formatex
    #emit SCTRL        6
}
You can now do:
pawn Код:
static stock
    gs_Buffer[256]
;

stock SendClientMessagef(playerid, color, fmat[], va_args<>) {
    va_formatex(gs_Buffer, _, fmat, va_start<3>);

    SendClientMessage(playerid, color, gs_Buffer);
}

stock SendClientMessageToAllf(color, fmat[], va_args<>) {
    va_formatex(gs_Buffer, _, fmat, va_start<2>);

    SendClientMessageToAll(color, gs_Buffer);
}
Thus:
pawn Код:
color = 0xFFFFFFFF;

SendClientMessageToAllf(color, "* %P%C just joined the server.", playerid, color);
Reply


Messages In This Thread
formatex - Improved "format" function! - by Slice - 26.01.2012, 08:00
Re: formatex - Improved "format" function! - by KingHual - 26.01.2012, 08:02
Re: formatex - Improved "format" function! - by kizla - 26.01.2012, 08:03
Re: formatex - Improved "format" function! - by [HK]Ryder[AN] - 26.01.2012, 08:05
Re: formatex - Improved "format" function! - by Slice - 26.01.2012, 08:10
Re: formatex - Improved "format" function! - by iPLEOMAX - 26.01.2012, 08:19
Re: formatex - Improved "format" function! - by fiki574 - 26.01.2012, 08:30
Re: formatex - Improved "format" function! - by T0pAz - 26.01.2012, 08:37
Re: formatex - Improved "format" function! - by Kaperstone - 26.01.2012, 08:48
Re: formatex - Improved "format" function! - by System64 - 26.01.2012, 09:02
Re: formatex - Improved "format" function! - by Lorenc_ - 26.01.2012, 09:07
Re: formatex - Improved "format" function! - by [Diablo] - 26.01.2012, 10:56
Re: formatex - Improved "format" function! - by [XST]O_x - 26.01.2012, 13:46
Re: formatex - Improved "format" function! - by hossa - 26.01.2012, 14:13
Re: formatex - Improved "format" function! - by iZN - 26.01.2012, 14:24
Re: formatex - Improved "format" function! - by TheArcher - 26.01.2012, 16:29
Re: formatex - Improved "format" function! - by TheBetaFox - 26.01.2012, 16:39
Respuesta: formatex - Improved "format" function! - by [Nikk] - 26.01.2012, 16:49
Re: formatex - Improved "format" function! - by Slice - 29.01.2012, 13:32
Re: formatex - Improved "format" function! - by Niko_boy - 29.01.2012, 14:26
Re: formatex - Improved "format" function! - by DeathTone - 19.02.2012, 02:00
Re: formatex - Improved "format" function! - by Slice - 19.02.2012, 10:33
Re: formatex - Improved "format" function! - by Shelby - 19.02.2012, 23:05
Re: formatex - Improved "format" function! - by shitbird - 21.02.2012, 15:03
Re: formatex - Improved "format" function! - by Marricio - 21.02.2012, 19:54
Re: formatex - Improved "format" function! - by Joey^ - 03.03.2012, 16:49
Re: formatex - Improved "format" function! - by Niko_boy - 04.06.2012, 14:28
Re: formatex - Improved "format" function! - by Slice - 04.06.2012, 14:40
Re: formatex - Improved "format" function! - by Slice - 04.06.2012, 16:35
Re: formatex - Improved "format" function! - by QuaTTrO - 22.07.2013, 07:33
Re: formatex - Improved "format" function! - by Omirrow - 23.07.2013, 19:38
Re: formatex - Improved "format" function! - by Darnell - 24.07.2013, 13:07
Re: formatex - Improved "format" function! - by Ryan_Bowe - 14.03.2015, 20:55
Re: formatex - Improved "format" function! - by Dayvison_ - 01.04.2016, 19:17
Re: formatex - Improved "format" function! - by bsHoX - 03.04.2016, 03:18
Re: formatex - Improved "format" function! - by AndySedeyn - 02.10.2016, 10:02
Re: formatex - Improved "format" function! - by Adiiti - 20.08.2017, 14:55

Forum Jump:


Users browsing this thread: 6 Guest(s)