PDA

View Full Version : Print "%" percent symbol in console


Merudo
02-22-2016, 18:51
Is there a way to show the "%" symbol in console with PrintToConsole?

The "%" symbol is reserved to print variables (%d prints an integer, %f a float, etc)

I tried using "%%" but it doesn't show the symbol.

thecount
02-22-2016, 20:02
How are you using it? Because "%%" should definitely work.

Merudo
02-22-2016, 20:26
I'm using VFormat, which seems to replace my %% by spaces.

Miu
02-22-2016, 21:00
void f(const char[] s, ...)
{
decl String:buf[512];
VFormat(buf, sizeof(buf), s, 2);
PrintToServer("%s", buf);
}

asherkin
02-23-2016, 04:31
As Miu indicates, you were probably double-formatting by passing the formatted buffer as the first arguments to PrintToServer (which is a massive security bug).

Merudo
02-23-2016, 10:12
Yes it was a multiple formatting error :) Thanks guys!

In my case my error was to do

PrintToConsole(client, buf);

instead of

PrintToConsole(client, "%s", buf);