YSI-Includes icon indicating copy to clipboard operation
YSI-Includes copied to clipboard

va_args stopped working after update

Open MateusArthur opened this issue 1 year ago • 6 comments

stock fmat(const fmat[], va_args<>) { new str[400]; va_format(str, sizeof(str), fmat, va_start<1>); return str; }

As an example, this function is no longer formatting a string correctly, it just returns empty formatting:

Code SendClientMessage(playerid, -1, fmat("My name is %s!", PlayerName(playerid)));

Output: My Name is !

And in the terminal we have the following warning:

*** YSI Warning: Bare ___ usage found - make sure it is a function parameter.

MateusArthur avatar Nov 23 '23 15:11 MateusArthur

Use va_SendClientMessage(playerid, -1, "My name is %s!", PlayerName(playerid));

Sesomsoma avatar Dec 27 '23 13:12 Sesomsoma

Use va_SendClientMessage(playerid, -1, "My name is %s!", PlayerName(playerid));

Yes, I tried that, it has the same problem, I think it might be my compiler version: Pawn compiler 3.10.10

MateusArthur avatar Dec 27 '23 18:12 MateusArthur

Uhm. Try this:

#include <YSI\y_va>

stock SendClientMessageEx(playerid, colour, const fmat[], va_args<>) { new str[145]; va_format(str, sizeof (str), fmat, va_start<3>); return SendClientMessage(playerid, colour, str); }

Sesomsoma avatar Dec 27 '23 19:12 Sesomsoma

That compiler should be fine. Which YSI version are you on?

Y-Less avatar Apr 24 '24 21:04 Y-Less

And does this still happen? I can't reproduce it.

Y-Less avatar Apr 24 '24 23:04 Y-Less

And does this still happen? I can't reproduce it.

Yes, this still happens, I use the latest version that was available at the end of last year. I didn't change anything about the project until then.

info: `*** Streamer Plugin: The plugin version (0x295) is older than the include file version (0x296) for this script. The plugin might need to be updated to the latest version.

     ==============================================================
     |                                                            |
     |                                                            |
     |    YYYYYYY       YYYYYYY    SSSSSSSSSSSSSSS  IIIIIIIIII    |
     |    Y:::::Y       Y:::::Y  SS:::::::::::::::S I::::::::I    |
     |    Y:::::Y       Y:::::Y S:::::SSSSSS::::::S I::::::::I    |
     |    Y::::::Y     Y::::::Y S:::::S     SSSSSSS II::::::II    |
     |    YYY:::::Y   Y:::::YYY S:::::S               I::::I      |
     |       Y:::::Y Y:::::Y    S:::::S               I::::I      |
     |        Y:::::Y:::::Y      S::::SSSS            I::::I      |
     |         Y:::::::::Y        SS::::::SSSSS       I::::I      |
     |          Y:::::::Y           SSS::::::::SS     I::::I      |
     |           Y:::::Y               SSSSSS::::S    I::::I      |
     |           Y:::::Y                    S:::::S   I::::I      |
     |           Y:::::Y                    S:::::S   I::::I      |
     |           Y:::::Y        SSSSSSS     S:::::S II::::::II    |
     |        YYYY:::::YYYY     S::::::SSSSSS:::::S I::::::::I    |
     |        Y:::::::::::Y     S:::::::::::::::SS  I::::::::I    |
     |        YYYYYYYYYYYYY      SSSSSSSSSSSSSSS    IIIIIIIIII    |
     |                                                            |
     |                                                            |
     |                      (c) 2021 MPL v1.1                     |
     |            Alex "Y_Less" Cole and contributors.            |
     |                                                            |
     |                                                            |
     ==============================================================

========================================== | | | Generating code, this may take a | | little bit of time. Note that this | | code generation works best with the | | JIT plugin, which you are not | | currently using. Get it here: | | | | https://git.io/jit-plugin | | | | Please wait... | | | | Done in 118ms! | | |

Filterscript '../scriptfiles/callbackfix.amx' loaded. *** YSI Info: Script ID: 1 | | | Server: 0.3.7-R2 (W) | | Started: 24 Apr 2024 - 21:07:20 | | | | Compiler: 3.10.10 (Windows) | | Includes: 0.3.7 | | Codepage: | | Built: 24 Apr 2024 - 21:07:12 | | | | YSI: v05.09.0982 | | Master: 1 | | | | JIT: | | Crashdetect: | | |

| | | Unable to check the latest YSI version | | - please watch the forums and github: | | | | https://git.io/5.x | | |

*** YSI Warning: Bare ___ usage found - make sure it is a function parameter. VALOR 0 VALOR 25`

code:

new valor = 25;
	print(fmat("VALOR %d", valor));
	printf("VALOR %d", valor);

MateusArthur avatar Apr 25 '24 00:04 MateusArthur