House password
#1

Hi, I'm creating my own home system, I add the key but can not do wrong when I enter the password nothing happens

SET HOUSE PASSWORD
pawn Код:
if(dialogid == DIALOG_HOUSE_PASSWORD + 1)
    {
        if(response)
        {
            if(strfind(inputtext, "%", false) != -1 || strfind(inputtext, "~", false) != -1) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Invalid, no use %, ~");
            if(strlen(inputtext) > 16)
            {
                SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} Your password is too long.");
                return 1;
            }
            if(strlen(inputtext) >= 3)
            {
                WP_Hash(hInfo[InHouse[playerid]][hpassword], 129, inputtext);
                format(fquery, sizeof(fquery), "UPDATE `HOUSEINFO` SET Password = '%s' WHERE `ID` = '%d'", hInfo[InHouse[playerid]][hpassword], InHouse[playerid]);
                db_query(HouseData, fquery); //Queries the SQLite database.
                format(fquery, sizeof(fquery), "[HOUSE]{FFFFFF} You have changed the password of the house to %s", inputtext);
                SendClientMessage(playerid, COLOR_SERVER, fquery);
            }
            else
            {
                SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} Your password is too short.");
            }
        }
    }
Entering password
pawn Код:
if(dialogid == DIALOG_HOUSE_PASSWORD + 2)
    {
        if(response)
        {
            new buf[129];
            WP_Hash(buf, 129, inputtext);
            if(!strcmp(buf, hInfo[InHouse[playerid]][hpassword], false))
            {
                SendClientMessageToAll(COLOR_SERVER, "WIII WORK *-* xd");
               
            }
        }
    }
FUCTION TO LOAD HOUSE
pawn Код:
forward FUNCTION_LoadHouses();
public FUNCTION_LoadHouses()
{
    new DBResult:HOUSE_RESULT;
    new ftd[75];
    HOUSE_RESULT = db_query(HouseData,  "SELECT * FROM `HOUSEINFO`");
    if(db_num_rows(HOUSE_RESULT) > 0) // Logged In
    {
        new id;
        for (new x=0; x<db_num_rows(HOUSE_RESULT); x++)
        {
            db_get_field_assoc(HOUSE_RESULT, "ID", ftd, 26);
            id = strval(ftd);

            db_get_field_assoc(HOUSE_RESULT, "Title", ftd, 100);
            format(hInfo[id][Hname], 100, "%s", ftd);

            db_get_field_assoc(HOUSE_RESULT, "Owner", ftd, 24);
            format(hInfo[id][owner], 24, "%s", ftd);
           
            db_get_field_assoc(HOUSE_RESULT, "Price", ftd, 30);
            hInfo[id][costprice] = strval(ftd);
           
            db_get_field_assoc(HOUSE_RESULT, "Password", ftd, 30);
            hInfo[id][hpassword] = strval(ftd);

            db_get_field_assoc(HOUSE_RESULT, "EnterX", ftd, 30);
            hInfo[id][hEnterPos][0] = floatstr(ftd);

            db_get_field_assoc(HOUSE_RESULT, "EnterY", ftd, 30);
            hInfo[id][hEnterPos][1] = floatstr(ftd);

            db_get_field_assoc(HOUSE_RESULT, "EnterZ", ftd, 30);
            hInfo[id][hEnterPos][2] = floatstr(ftd);

            db_get_field_assoc(HOUSE_RESULT, "Type", ftd, 30);
            hInfo[id][Type] = strval(ftd);

            //native CreateDynamicCP(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 100.0);
            hInfo[id][hcheckpointidx][0] =  CreateDynamicCP(hInfo[id][hEnterPos][0], hInfo[id][hEnterPos][1], hInfo[id][hEnterPos][2], 1.0, 0, -1, -1, 50.0);
            format(fquery, sizeof(fquery), HOUSE_LABEL, hInfo[id][Hname], id, hInfo[id][owner],  Comma(hInfo[id][costprice]));
            hInfo[id][htextid][0] = Create3DTextLabel(fquery, 0x00bbffFF, hInfo[id][hEnterPos][0], hInfo[id][hEnterPos][1], hInfo[id][hEnterPos][2] + 0.5, 15.0, 0, 0);
            switch(hInfo[id][Type])
            {
                case 0:
                {
                    hInfo[id][hcheckpointidx][1] = CreateDynamicCP(271.884979, 306.631988, 999.148437, 1.0, 15500000+id , 2, -1, 5.0); // Default house
                    hInfo[id][htextid][1] = Create3DTextLabel("[Exit]", 0x00bbffFF, 271.884979, 306.631988, 999.148437, 8.0, 15500000+id, 1);
                }
            }
            db_next_row(HOUSE_RESULT);
        }
    }
    houseid = db_num_rows(HOUSE_RESULT);
    return 1;
}
that can not do evil, help me please
Reply
#2

Quote:
Originally Posted by Cerealguy
Посмотреть сообщение
Entering password
pawn Код:
if(dialogid == DIALOG_HOUSE_PASSWORD + 2)
    {
        if(response)
        {
            new buf[129];
            WP_Hash(buf, 129, inputtext);
            if(!strcmp(buf, hInfo[InHouse[playerid]][hpassword], false))
            {
                SendClientMessageToAll(COLOR_SERVER, "WIII WORK *-* xd");
               
            }
        }
    }
It's this part you're having problems with right? Let's start with debugging. Let's print out the value of the hpassword string, and the contents of the buf string. Now we can see for ourselves if it works.

You'd get something like this:
pawn Код:
if(dialogid == DIALOG_HOUSE_PASSWORD + 2)
    {
        if(response)
        {
            new buf[129];
            WP_Hash(buf, 129, inputtext);
            if(!strcmp(buf, hInfo[InHouse[playerid]][hpassword], false))
            {
                SendClientMessageToAll(COLOR_SERVER, "WIII WORK *-* xd");
               
            }
            print("------- Buf contents -------\n");
            printf(" %s ",buf);
            print("\n------- hpass contents -------\n");
            printf(" %s ",hInfo[InHouse[playerid]][hpassword]);
            printf("END OF DEBUG");
        }
    }
Now when you enter the password, it will show both the contents of the hashed inputtext, and the hpassword string.
Try that, and check if they're the same. If not, then something's going wrong while saving (or loading) the password.
Reply
#3

[10:46:28] ------- Buf contents -------

[10:46:28] FD9D94340DBD72C11B37EBB0D2A19B4D05E00FD78E4E2CE892 3B9EA3A54E900DF181CFB112A8A73228D1F3551680E2AD9701 A4FCFB248FA7FA77B95180628BB2
[10:46:28]
------- hpass contents -------

no result friend :'c


Password in db :FD9D94340DBD72C11B37EBB0D2A19B4D05E00FD78E4E2CE89 23B9EA3A54E900DF181CFB112A8A73228D1F3551680E2AD970 1A4FCFB248FA7FA77B95180628BB2

are equal but as the problem is to load the data from the house (password) and that did not work
Reply
#4

small bump!
Reply
#5

small bump!
Reply
#6

pawn Код:
db_get_field_assoc(HOUSE_RESULT, "Password", ftd, 30);
            hInfo[id][hpassword] = strval(ftd);
Wouldn't that be making the password a number?

If I was to change anything, I would change that to:
pawn Код:
db_get_field_assoc(HOUSE_RESULT, "Password", ftd, 30);
            format(hInfo[id][hpassword], sizeof(hInfo[id][hpassword]), "%s", ftd);
Reply
#7

system password for the home, that's no good excuse friend. The problem is not the load but it siemplemente the Password data takes home as if there.

numeric and alfabetic
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)