16.02.2013, 07:47
Hi,
My problem is: Some characters from line 1 is in line 2.
Look at function.
Max char. per line is 48. You can see if lenght > 48 then searching for space and moving rest of text to new line.
Logs with bug:
Problem is there.
What's wrong?
My problem is: Some characters from line 1 is in line 2.
Look at function.
Код:
stock SendChatMessage(playerid, text[]) { new nickname[32], separated[128]; GetPlayerName(playerid, nickname, 32); new len = strlen(text); new lastpos; new pos; new idx=48; new count = floatround(len/25); if(count < 0) count = 1; if(len > 48) { foreachEx(i, count) { pos = strfind(text, " ", true, idx); new line = GetEmptyChatLine(); if(pos != -1) strmid(separated, text, lastpos, pos); else strmid(separated, text, idx-48, idx-count+1); format(ChatInfo[line][chattext], 128, "%s", separated); lastpos = pos; if(lastpos == -1) lastpos = 0; idx += 48; if(GetEmptyChatLine() == -1) MoveChatMessages(); } } else { new line = GetEmptyChatLine(); strmid(separated, text, 0, strlen(text)); format(ChatInfo[line][chattext], 128, "%s", separated); if(GetEmptyChatLine() == -1) MoveChatMessages(); } format(ChatString, 512, "%s~n~%s~n~%s~n~%s~n~%s~n~%s~n~%s", ChatInfo[0][chattext],ChatInfo[1][chattext],ChatInfo[2][chattext],ChatInfo[3][chattext],ChatInfo[4][chattext],ChatInfo[5][chattext],ChatInfo[6][chattext]); TextDrawSetString(Chat, ChatString); }
Logs with bug:
Код:
[16:49:10] idx: 48, lp: 0, p: 51, sep: Witamy na serwerze Evil Lands. Nastepuje testowanie [16:49:10] idx: 96, lp: 51, p: -1, sep: nie czatu do przenoszenia lini [16:49:10] idx: 144, lp: 0, p: -1, sep:
What's wrong?