28.12.2011, 03:36
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:
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]
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.
pawn Код:
new scm[128];
format(scm, sizeof(scm), "%s warned %s for %s.", blah, blah, blah);
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.");