Template:FormatSpecifiers

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 04:28, 13 July 2015
WopsS (Talk | contribs)
(Updated for 0.3.7 R2.)
← Previous diff
Current revision
Freaksken (Talk | contribs)
(Add note on the use of the asterisk)
Line 37: Line 37:
size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces. size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces.
To cut the number of decimal places beeing shown of a float, you can add '.<max number>' between the '%' and the 'f'. (example: %.2f) To cut the number of decimal places beeing shown of a float, you can add '.<max number>' between the '%' and the 'f'. (example: %.2f)
 +
 +See [http://forum.sa-mp.com/showpost.php?p=4008655&postcount=756 this post] to see how you can specify a variable width or precision by using an asterisk.

Current revision

Format Specifiers

Specifier Meaning
%i Integer (whole number)
%d Integer (whole number).
%s String
%f Floating-point number (Float: tag)
%c ASCII character
%x Hexadecimal number
%b Binary number
%% Literal '%'
%q Escape a text for SQLite. (Added in 0.3.7 R2)

The values for the placeholders follow in the exact same order as parameters in the call. For example, "I am %i years old" - the %i will be replaced with an Integer variable, which is the person's age.

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. To cut the number of decimal places beeing shown of a float, you can add '.<max number>' between the '%' and the 'f'. (example: %.2f)

See this post to see how you can specify a variable width or precision by using an asterisk.

Personal tools