Printf
From SA-MP Wiki
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 |
| Returns | This function doesn't return a specific value |
Warning: The format string or its output should not exceed 1024 characters. Anything beyond that length can lead to a server to crash.
Format Strings
| Placeholder | Meaning |
|---|---|
| %b | Inserts a number at this position in binary radix |
| %c | Inserts a single character. |
| %d | Inserts an integer (whole) number |
| %f | Inserts a floating point number. |
| %i | Inserts an integer. |
| %s | Inserts a string. |
| %x | Inserts a number in hexadecimal notation. |
| %% | 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. To cut the number of decimal places beeing shown of a float, you can add '.<max number>' between the '%' and the 'f'. (example: %.2f)
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. new character = 64; printf("I'm %c home",character); //-> I'm @ home
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- Print: Print a basic message in the logs and console.
- format: Format a string.
