Posts: 484
Threads: 189
Joined: Jun 2016
Reputation:
0
Why don't you use global string of size 1024/2000 instead of repeating string[X] on almost each like you'll need it ? On this code string size of 128 i'll be enough.
Posts: 1,076
Threads: 70
Joined: Jul 2016
Reputation:
0
Always, keep in mind that SA-MP's implementation of pawn has few limitations, especially when it comes to working with strings, the maximum input length is 128 characters long, as for the output, it's 144, this applies on client messages in particular.
Posts: 484
Threads: 189
Joined: Jun 2016
Reputation:
0
So, what's the best idea instead of doing global and only 1 string ?
Posts: 789
Threads: 76
Joined: Nov 2011
Reputation:
0
Best idea (as mentioned indirectly above) is to keep local strings.
Also, it's a good habit making the string sizes as big as you need them, and not excessively big.
For the string above, we know that %s (playername) can't exceed the name-limit of 25 letters, and %d (as meters) will not exceed the limit of the script-defined range. Each number counts as 1 letter, and then we know the length of the entire string.
61 + 25 + 4 (i assume %d sholdn't need to exceed 9999) + 1 (plus one extra for the string-terminater) = 91.
You can safely shorten it down to 91.
However, these types of things doesn't mean the difference in terms of speeds or performance in small amounts. If you have a large script with many of those, then yes - it's smart to keep them short. No need to occupy space that you don't need.