09.06.2012, 06:38
That is pretty confusing, and I know all about strings and format(), so I think Faisal_khan is going to go when he looks at that. I did.
Here's a clear explanation of format (which is what he wants to know - not how it works internally..):
The string is the string you want to 'format', you must declare it BEFORE using format():
The length is best to be ignored, just put 'sizeof(string)'.
In the text is where we put our message. If we want to insert things such as numbers we need to specify where it should be inserted with 'specifiers'. A list of these can be found on the wiki. Here's a practical example:
Should output "MP2 (ID: 69) has 100.0 health". %0.2f means it will show only two decimal places.
The ordering is obviously important.
Here's a clear explanation of format (which is what he wants to know - not how it works internally..):
pawn Код:
format(string, length, "text", replacements);
pawn Код:
new string[128];
pawn Код:
format(string, sizeof(string), "text", replacements);
pawn Код:
new name = "MP2";
new id = 69;
new Float:health = 100.0;
new string[128];
format(string, sizeof(string), "%s (ID: %i) has %0.2f health.", name, id, health);
SendClientMessage(playerid, -1, string);
The ordering is obviously important.