Printf

From SA-MP

Jump to: navigation, search


printf

Outputs a formatted string on the console (the server window, not the in-game chat).


(const format[], {Float,_}:...)
format[]The format string
{Float,_}:...Indefinite number of arguments of any tag
This function does not return a specific value, it's best to simply ignore it.


Format Strings

Placeholder Meaning
%c Inserts a single character.
%d Inserts an integer (whole) number
%x Inserts a number in hexadecimal notation.
%f Inserts a floating point number.
%s Inserts a string.
%% Inserts the literal '%'

The values for the placeholders follow in the exact same order as parameters in the call.

You may optionally put a number between the '%' and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces.

new number = 42;
printf("The number is %d.",number);  //-> The number is 42.
 
new string[]= "simple message";
printf("This is a %s containing the number %d.", string, number); //-> This is a simple message containing the number 42.

Related Functions

The following functions might be useful as well, as they're related to this function in one way or another.

  • format: General formatting function.
Personal tools