SA-MP Forums Archive
[Tutorial] String Formatting - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] String Formatting (/showthread.php?tid=265433)

Pages: 1 2


Re: String Formatting - sim_sima - 06.08.2011

Nice tutorial!


Re: String Formatting - sim_sima - 20.10.2011

Really usefull tutorial


Re: String Formatting - krogsgaard20 - 08.01.2012

^Thanks.
I would like to hear everyone's opinion about the tutorial, thank you.


Re: String Formatting - Jessyy - 21.07.2012

there is a small mistake ...
Code:
native strformat(dest[], size=sizeof dest, bool: pack=false, const format[], . . . )
this functions does not exist in pawn ... ((


Re: String Formatting - cazanova - 26.07.2012

i want a message

E.x " Good ob for killing (playername)

any help


Re: String Formatting - Amit_B - 26.07.2012

Quote:
Originally Posted by krogsgaard20
View Post
The reason for using "23 + MAX_PLAYER_NAME" and not 128 is because the smaller array sizes, the better. 128 is way too much for our small message in this tutorial. Allways make arrays as small as possible.
Quote:
Originally Posted by Toreno
View Post
True, using a 128 array size is over than you need.

@ krogsgaard20,
To be honest, that tutorial taught me alot.
Good tutorial and good job!
You're right that using small arrays will be better instead of setting them to 128, but, will you really going to count every formatted string you send? Don't you two prefer to just guess the maximum string?

Also, I agree with Y_Less, although I don't know what 3 means. But its true that this one would be better:
pawn Code:
new str[64];
GetPlayerName(playerid,str,MAX_PLAYER_NAME);
format(str,sizeof(str),"Hello %s",str);



Re: String Formatting - Vince - 26.07.2012

You can quite easily count the characters you need by looking at the 'Col' value in the bottom-right-corner of Pawno (or any other editor for that matter) for the start and end of the string and subtracting them from each other.

As for point 3 that Y_Less stated, I assume that will pad the string with dots, in some way.


Re: String Formatting - Kaperstone - 26.07.2012

Did you people even noticed that last post was posted 6 months ago and the thread\tutorial created 1 year ago... ?
means you're answering to questions that were asked 1 year ago


Re: String Formatting - Amit_B - 26.07.2012

Quote:
Originally Posted by Vince
View Post
You can quite easily count the characters you need by looking at the 'Col' value in the bottom-right-corner of Pawno (or any other editor for that matter) for the start and end of the string and subtracting them from each other.

As for point 3 that Y_Less stated, I assume that will pad the string with dots, in some way.
I'm pretty sure that most of scripters will prefer to use a specific value for string length, such as 16, 32, 64 and etc instead of using the amount of characters in the string.

Also, using the 'col' value will still require to find the number without spaces, functions or any other type of code that can be found in a line of a string.


Re: String Formatting - Madsen - 31.03.2013

thx, it was rly helpfull


Re: String Formatting - ZcvDev - 01.02.2015

nice tutorial


Re: String Formatting - JasonRiggs - 27.01.2017

I've got a problem idk its reason,
error 012: invalid function call, not a valid address
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

Line :

Quote:

format(string,sizeof(string),"(( %s %s: %s ))",atext,RemoveUnderScore(playerid),result);




Re: String Formatting - BlackbirdXd - 15.02.2017

Quote:
Originally Posted by JasonRiggs
View Post
I've got a problem idk its reason,
error 012: invalid function call, not a valid address
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

Line :
Code:
format(string,sizeof(string),"%s %s %s",atext,RemoveUnderScore(playerid),result);



Re: String Formatting - RoW001 - 20.03.2017

Yea dudes, but SendClientMessage limit is actually 144 .


Re: String Formatting - Eoussama - 15.12.2017

Quote:
Originally Posted by RoW001
View Post
Yea dudes, but SendClientMessage limit is actually 144 .
That limit is not exclusive to only that function, It's the output's limit.