Need some answers.
#3

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..):

pawn Код:
format(string, length, "text", replacements);
The string is the string you want to 'format', you must declare it BEFORE using format():
pawn Код:
new string[128];
The length is best to be ignored, just put 'sizeof(string)'.
pawn Код:
format(string, sizeof(string), "text", replacements);
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:

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);
Should output "MP2 (ID: 69) has 100.0 health". %0.2f means it will show only two decimal places.

The ordering is obviously important.
Reply


Messages In This Thread
Need some answers. - by Faisal_khan - 09.06.2012, 06:13
AW: Need some answers. - by Extremo - 09.06.2012, 06:22
Re: Need some answers. - by MP2 - 09.06.2012, 06:38
Re: Need some answers. - by Rudy_ - 09.06.2012, 07:13
Re: Need some answers. - by Faisal_khan - 09.06.2012, 07:27
AW: Need some answers. - by Extremo - 09.06.2012, 07:28
Re: Need some answers. - by Faisal_khan - 09.06.2012, 07:36
AW: Need some answers. - by Extremo - 09.06.2012, 07:46
Re: Need some answers. - by Faisal_khan - 09.06.2012, 07:50
Re: Need some answers. - by MadeMan - 09.06.2012, 07:51

Forum Jump:


Users browsing this thread: 2 Guest(s)