String length cut-off?
#3

You can't show more than 128 (or 127?) characters in a client message. There is no way to get around this. If it's longer, it will not show. You HAVE to cut stuff off when you have user-input strings in the messages. This can be done like so:

pawn Код:
new scm[128];
format(scm, sizeof(scm), "%s warned %s for %s.", blah, blah, blah);
You could set a limit for the reason by using strlen() on both players' names, plus the characters in the string, take that away from 128 and you have the reason limit. Example:

MP2 has warned Tee for 'hacking'.

MP2 = 3
Tee = 3
Rest of string = 20 (+1 null char = 21)

Total = 21+3+3 (27)
Reason limit = 128-(strlen(name1)+strlen(name2)+21) [101]

pawn Код:
if(strlen(reason) > reason_limit) return SendClientMessage(playerid, red, "ERROR: Reason too long.");
Note that color embedding also counts, it will add 8 characters to a string. I recommend not using embedding when user-input strings are used. unless they are going to be short.
Reply


Messages In This Thread
String length cut-off? - by Tee - 28.12.2011, 00:57
Re: String length cut-off? - by JamesC - 28.12.2011, 01:37
Re: String length cut-off? - by MP2 - 28.12.2011, 03:36
Re: String length cut-off? - by Scenario - 28.12.2011, 04:11
Re: String length cut-off? - by Tee - 28.12.2011, 15:57
Re: String length cut-off? - by Seven_of_Nine - 28.12.2011, 16:00
Re: String length cut-off? - by Tee - 28.12.2011, 16:01
Re: String length cut-off? - by rinori - 28.12.2011, 16:10
Re: String length cut-off? - by Seven_of_Nine - 28.12.2011, 16:22
Re: String length cut-off? - by Calgon - 28.12.2011, 16:42

Forum Jump:


Users browsing this thread: 1 Guest(s)