08.10.2014, 12:40
Hi all. Can somebody help me debugging this code? When I call IndexDrawAddOption, the textdraw used in it is completely emptied out...
definitions:
and the function: (in this scenario, xStr empties out)
hope you can help
Regards - Anna SB
definitions:
Код:
enum KEY_LIST { keychar[2], keyname[64] } new Text:iTextDraw[MAX_IDRAWS] = { Text:NULL }; new iDrawTitle[MAX_IDRAWS][64]; new iDrawActive[MAX_SLOTS] = { NULL }; new iCancelKey[MAX_IDRAWS] = { KEY_FIRE }; new iDataSheet[MAX_IDRAWS][MAX_IDRAW_OPTIONS][KEY_LIST]; new iDrawColor[MAX_IDRAWS][3][12];
Код:
stock IndexDrawAddOption(idraw, keytitle[], keystate[]) { for (new i = 0; i < MAX_IDRAW_OPTIONS; i++) if (strcmp(iDataSheet[idraw][i][keychar], keystate) == 0 && strlen(iDataSheet[idraw][i][keychar]) != 0) { printf("IndexDrawer: iDraw Detected a Repeated KeyChar in iDraw #%i.", idraw); return -1; } for (new i = 0; i < MAX_IDRAW_OPTIONS; i++) if (strlen(iDataSheet[idraw][i][keychar]) == 0) { format(iDataSheet[idraw][i][keychar], strlen(iDataSheet[idraw][i][keychar]), keystate); format(iDataSheet[idraw][i][keyname], strlen(iDataSheet[idraw][i][keyname]), keytitle); // xSet new xStr[256]; format(xStr, sizeof xStr, "%s%s~n~", iDrawColor[idraw][0], iDrawTitle[idraw]); for (new h = 0; h < MAX_IDRAW_OPTIONS; h++) { if (strlen(iDataSheet[idraw][h][keychar])) { strcat(xStr, iDrawColor[idraw][1]); strcat(xStr, iDataSheet[idraw][h][keychar]); strcat(xStr, ". "); strcat(xStr, iDrawColor[idraw][2]); strcat(xStr, iDataSheet[idraw][h][keyname]); strcat(xStr, "~n~"); } } TextDrawSetString(iTextDraw[idraw], xStr); // ---- return i; } printf("IndexDrawer: iDraw Options Overflow for iDraw #%i. Maximum is 20 Per iDraw.", idraw); return -1; }
![Wink](images/smilies/wink.png)