Skip to content

Commit

Permalink
Merge pull request #786 from adib-yg/patch-10
Browse files Browse the repository at this point in the history
Fix format.md 'Examples'
  • Loading branch information
leonardssh authored Dec 1, 2023
2 parents fb93611 + c56333f commit ce221fb
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions docs/scripting/functions/format.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,31 @@ You may optionally put a number between the `%` and the letter of the placeholde
```c
new result[128];
new number = 42;
format(result,sizeof(result), "The number is %i.",number); //-> The number is 42.
new string[]= "simple message";
format(result,sizeof(result), "This is a %s containing the number %i.", string, number);
format(result, sizeof(result), "The number is %i.", number); // The number is 42.

new string[] = "simple message";
format(result, sizeof(result), "This is a %s containing the number %i.", string, number);
// This is a simple message containing the number 42.
```
```c
new string[64];
format(string,sizeof(string),"Your score is: %d",GetPlayerScore(playerid));
SendClientMessage(playerid,0xFFFFFFAA,string);
new hour, minute, second, string[32];
format(string, sizeof(string), "Your score is: %d", GetPlayerScore(playerid));
SendClientMessage(playerid, 0xFF8000FF, string);
```

```c
new string[32];
new hour, minute, second;
gettime(hour, minute, second);
format(string, sizeof(string), "The time is %02d:%02d:%02d.", hour, minute, second);
// will output something like "The time is 09:45:02."
```
format(string, sizeof(string), "The time is %02d:%02d:%02d.", hour, minute, second); // will output something like 09:45:02
SendClientMessage(playerid, -1, string);
new string[35];
format(string,sizeof(string),"43%s of my shirts are black.","%%");
SendClientMessage(playerid,0xFFFFFAA,string);
```c
new string[32];
format(string, sizeof(string), "43%s of my shirts are black.", "%%");
SendClientMessage(playerid, 0xFF8000FF, string);
```

## Notes
Expand Down

0 comments on commit ce221fb

Please sign in to comment.