Impossible Bug
#1

Ok i have WEIRED bug in my "blank" script...
Here is the thing
pawn Код:
if(dialogid == 14)
    {
        if(!response) return SelectTextDraw(playerid, red);

        if(strlen(inputtext) < 4) return ShowPlayerDialog(playerid, 14, DIALOG_STYLE_INPUT, "Login - Password", embed_red"[GRESKA]"embed_grey"Password mora da ima makar 4 karaktera\nPassword:", "U redu", "Nazad");
        SetPVarString(playerid, "RegisterPassword", inputtext);
        SetPVarString(playerid, "RegisterPasswordRepeat", "");

        new tmpPassStr[10];
        for(new i = 0; i < strlen(inputtext) && i < 10; i++)
        {
            tmpPassStr[i] = ']';
        }
        SetPlayerTextDrawInputValue3(playerid, tmpPassStr);
        SetPlayerTextDrawInputValue4(playerid, "          ");//Clearing Repeat password

        SelectTextDraw(playerid, red);
        return 1;
    }
    if(dialogid == 15)
    {
        if(!response) return SelectTextDraw(playerid, red);

        if(strlen(inputtext) < 4) return ShowPlayerDialog(playerid, 15, DIALOG_STYLE_INPUT, "Login - Password", embed_red"[GRESKA]"embed_grey"Password mora da ima makar 4 karaktera\nPonoviti password:", "U redu", "Nazad");
        new string[24]; GetPVarString(playerid, "RegisterPassword", string);
        if(strcmp(inputtext, string) != 0 || strlen(string) == 0) return ShowPlayerDialog(playerid, 15, DIALOG_STYLE_INPUT, "Login - Password", embed_red"[GRESKA]"embed_grey"Passwordi se ne poklapaju\nPonoviti password:", "U redu", "Nazad");

        SetPVarString(playerid, "RegisterPasswordRepeat", inputtext);

        //Start of the problem
        new tmpPassStr2[10];
        for(new i = 0; i < strlen(inputtext) && i < 10; i++)
        {
            tmpPassStr2[i] = ']';
            SendDebugEx(playerid, "tmpPassStr[%d] = '%s'", i,tmpPassStr2);
        }
        //At these point tmpPassStr2 already have  ] * sizeof inputtext + inputtext characters
        SendDebugEx(playerid, "END - '%s'", tmpPassStr2);
        SetPlayerTextDrawInputValue4(playerid, tmpPassStr2);
        SelectTextDraw(playerid, red);
        return 1;
    }
And here is what debug prints...(Please pay atention at lenght of the tmpPasStr2)
Код:
[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[0] = ']'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[1] = ']]'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[2] = ']]]'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[3] = ']]]]'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[4] = ']]]]]'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[5] = ']]]]]]'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[6] = ']]]]]]]'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[7] = ']]]]]]]]'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[8] = ']]]]]]]]]'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[9] = ']]]]]]]]]]'

[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[10] = ']]]]]]]]]]]wewewewewewe'

[00:34:33] [DEBUG]{C0C0C0}END - ']]]]]]]]]]]wewewewewewe'
tmpPasStr2 is not mentioned anywhere except in these few lines and as i can see it has no connection with inputtext what so ever
Even more annoying thing is that it works perfect in dialog id 14 !
Oh and if i set tmpPasStr2 lenth to 11 its all fine...
Reply
#2

The only thing that doesn't fit with your code is that because the loop ends at 9
Quote:
Originally Posted by Sanady
Посмотреть сообщение
Код:
[00:34:33] [DEBUG]{C0C0C0}tmpPassStr[10] = ']]]]]]]]]]]wewewewewewe'
The case is easy, each string needs to end with a EOS (0) character
You overwrite the last cell and therefore it shows data beyond you array till it finds a 0

Since you created string before you will see the value of the "RegisterPassword"

Also if you want to create a plain array with only one sign you could do it like that
pawn Код:
new
    tmpPassStr2[11] = { ']', ... }
;
if(strlen(inputtext) < sizeof tmpPassStr2) {
    tmpPassStr2[strlen(inputtext)] = EOS;
} else {
    tmpPassStr2[sizeof tmpPassStr2 - 1] = EOS;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)