SA-MP Forums Archive
[QUESTION]About "format". - 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)
+--- Thread: [QUESTION]About "format". (/showthread.php?tid=297967)



[QUESTION]About "format". - [DOG]irinel1996 - 18.11.2011

Hi.
I have a little question, is possible make biggest formats? Because if I use too much characters it'll crash my compiler.
And strcat wasn't made for formatting strings.

Well, any suggestion?

Best regards!


Re: [QUESTION]About "format". - Calgon - 18.11.2011

format() at any rate shouldn't crash your compiler, it should give you a warning.

If you format a string that is too long, you can always begin formatting again on another line and include the old formatted string, like so:

pawn Код:
new szTestString[128];
format(szTestString, sizeof(szTestString), "asfmdasflmkasflkmasflmkalkmsfalkmsfalkmsflmkas");
format(szTestString, sizeof(szTestString), "%s asfmdasflmkasflkmasflmkalkmsfalkmsfalkmsflmkas", szTestString);



Respuesta: [QUESTION]About "format". - [DOG]irinel1996 - 18.11.2011

Hahaha... Good idea bro.
It works, thanks a lot.

EDIT:
Now I have another problem.
For example if I want make something like this:
pawn Код:
format(strings, sizeof(strings),"first format lalalalala");
format(strings, sizeof(strings),"%s "AV"%s",strings,Other);
Other won't appear. =/


Re: [QUESTION]About "format". - MP2 - 18.11.2011

You need to escape quotemarks by putting a backslash behind them. Also make sure the 'strings' array is large enough.


Respuesta: [QUESTION]About "format". - [DOG]irinel1996 - 18.11.2011

It works perfect with less characters, but if I add 4 or more characteres , It won't compile and the compiler crash.
And "strings" is large enough, It will crash too if I put 500. I need something like strcat, but with it I can't format strings.