28.03.2013, 16:30
Hello,
I had created chat in textdraw and system message in textdraw too.
When the box is full, client crashes. Time by time the chat crashes too.
Look at code:
And functions:
And the last:
I had created chat in textdraw and system message in textdraw too.
When the box is full, client crashes. Time by time the chat crashes too.
Look at code:
Код:
stock SendSystemMessage(playerid, text[]) { new separated[128]; new len = strlen(text); new lastpos, lines; new pos; new idx=48; new count; if(len <= 48) count = 1; else if(len >= 49 && len <= 96) count = 2; else count = 3; if(len > 48) { foreachEx(i, count) { pos = strfind(text, " ", true, idx); foreachEx(a, 15) { if(pos == -1) { pos = strfind(text, " ", true, idx-a); } else break; } if(pos != -1 && len <= 96 && lines >= 1) pos = -1; //Entering ENTER if(lines >= 1) { if(pos != -1) strmid(separated, text, lastpos+1, pos); else strmid(separated, text, lastpos+1, len); } else { if(pos != -1) strmid(separated, text, lastpos, pos); else strmid(separated, text, lastpos+1, len); } new eline = GetEmptySystemLine(playerid); //Formating line chat if(eline != 999) format(SysInfo[playerid][eline][chattext], 128, "%s", separated); else { MoveSystemMessages(playerid); format(SysInfo[playerid][6][chattext], 128, "%s", separated); } lastpos = pos; if(lastpos == -1) lastpos = 0; idx += 48; lines++; } } else { new line = GetEmptySystemLine(playerid); strmid(separated, text, 0, strlen(text)); if(line != 999) format(SysInfo[playerid][line][chattext], 128, "%s", separated); else { format(SysInfo[playerid][6][chattext], 128, "%s", separated); MoveSystemMessages(playerid); } } format(SystemString, 1024, "%s~n~%s~n~%s~n~%s~n~%s~n~%s~n~%s", SysInfo[playerid][0][chattext],SysInfo[playerid][1][chattext],SysInfo[playerid][2][chattext],SysInfo[playerid][3][chattext],SysInfo[playerid][4][chattext],SysInfo[playerid][5][chattext],SysInfo[playerid][6][chattext]); PlayerTextDrawSetString(playerid, SystemInfo[playerid], SystemString); }
Код:
stock GetEmptySystemLine(playerid) { new id=999; foreachEx(i, 7) { if(isnull(SysInfo[playerid][i][chattext])) { id = i; break; } } return id; } stock MoveSystemMessages(playerid) { foreachEx(i, 6) { if(i < 7) { format(SysInfo[playerid][i][chattext], 128, "%s", SysInfo[playerid][i+1][chattext]); } else break; } }
Код:
new SystemString[1024]; enum eSys { chattext[128] }; new SysInfo[MAX_PLAYERS][9][eSys];