[HELP] seting adress to house[mysql]
#1

Hello so I have command for setting adress in houses and know I set adress to house and ok label is update to adress which I set for example my adress but the problem is that is not set to database in that some id of house where is adress changed

so this is command

pawn Код:
CMD:aadresa(playerid,params[])
{
    if(gPlayerLogged[playerid] != 1)
    {
        SCM(playerid,SIVA,"{FFFFFF}[{F81414}G-Protect{FFFFFF}] {C3C3C3}Morate biti logirani za koristenje ove komande!");
        return 1;
    }
    if(PlayerInfo[playerid][Admin] >= 1338 || IsPlayerAdmin(playerid))
    {
        new i = -1,rows,fields;
        cache_get_data(rows,fields,mysql);
        if(rows)
        {
            for(new x = 0; x < sizeof(KucaInfo); x++)
            {
                if(IsPlayerInRangeOfPoint(playerid,3.0,KucaInfo[x][hUlazX],KucaInfo[x][hUlazY],KucaInfo[x][hUlazZ]))
                {
                    i = x;
                    AIzm[playerid] = x; -- this aizm for that I should get that id of house which I setting adress
                    break;
                }
            }
        }
        if(i == -1) return SCM(playerid,COLOR_GRAD2,"*Ne nalazite se u blizini kuce!");
        ShowPlayerDialog(playerid,39,DIALOG_STYLE_INPUT,"{0ed400}Adresa","{FFFFFF}Upisite novu adresu za ovu kucu:","Promijeni","Nazad");
    }
    else return SCM(playerid,COLOR_GRAD2,"{FFFFFF}[{F81414}G-Protect{FFFFFF}] {C3C3C3}Samo Admini!");
    return 1;
}
and response


pawn Код:
if(dialogid == 39)
    {
        if(response)
        {
            if(AIzm[playerid] == -1) return SCM(playerid,COLOR_GRAD2,"*Nepoznat ID kuce!");
            new adresa[128],upit[128];
            if(sscanf(inputtext,"s[128]",adresa)) return ShowPlayerDialog(playerid,39,DIALOG_STYLE_INPUT,"{0ed400}Adresa","{FFFFFF}Upisite novu adresu za ovu kucu:","Promijeni","Nazad");
            if(strlen(adresa) < 5)
            {
                SCM(playerid,COLOR_GRAD2,"*Adresa je prekratka!");
                ShowPlayerDialog(playerid,39,DIALOG_STYLE_LIST,"Izmena kuce","Upisite novu adresu za ovu kucu:","Promijeni","Nazad");
                return 1;
            }
            else if(strlen(adresa) > 128)
            {
                SCM(playerid,COLOR_GRAD2,"*Adresa je preduga!");
                ShowPlayerDialog(playerid,39,DIALOG_STYLE_LIST,"Izmena kuce","Upisite novu adresu za ovu kucu:","Promijeni","Nazad");
                return 1;
            }
            strmid(KucaInfo[AIzm[playerid]][hAdresa],adresa,0,strlen(adresa),255);
            UpdateLabels();
            SCMF(playerid,COLOR_WHITE,"{0ed400}[Kuca] {FFFFFF}Promijenio si adresu kuce. ID kuce: %d, Adresa: %s",AIzm[playerid],adresa);
            AIzm[playerid] = -1;
            mysql_format(mysql,upit,128,"UPDATE `kuce` SET `Adresa` = '%s' WHERE `ID` = '%d'",adresa,AIzm[playerid]--from this getting id of house where I change adress but it says in cmd aadresa that is id of house 0 but my houses go from ID 1,2,3 etc...);
            mysql_tquery(mysql,upit,"","");
        }
    }
    return 1;
}
Reply
#2

In the command, you were getting some amount of rows and fields while there was no query executed.
These would have no effect at all:
cache_get_data(rows,fields,mysql);
if(rows)

I deleted those in the code below:
pawn Код:
CMD:aadresa(playerid,params[])
{
    if(gPlayerLogged[playerid] != 1)
    {
        SCM(playerid,SIVA,"{FFFFFF}[{F81414}G-Protect{FFFFFF}] {C3C3C3}Morate biti logirani za koristenje ove komande!");
        return 1;
    }
    if(PlayerInfo[playerid][Admin] >= 1338 || IsPlayerAdmin(playerid))
    {
        new i = -1;

        for(new x = 0; x < sizeof(KucaInfo); x++)
        {
           if(IsPlayerInRangeOfPoint(playerid,3.0,KucaInfo[x][hUlazX],KucaInfo[x][hUlazY],KucaInfo[x][hUlazZ]))
           {
                i = x;
                AIzm[playerid] = x; // this aizm for that I should get that id of house which I setting adress
                break;
            }
        }
        if(i == -1) return SCM(playerid,COLOR_GRAD2,"*Ne nalazite se u blizini kuce!");
        ShowPlayerDialog(playerid,39,DIALOG_STYLE_INPUT,"{0ed400}Adresa","{FFFFFF}Upisite novu adresu za ovu kucu:","Promijeni","Nazad");
    }
    else return SCM(playerid,COLOR_GRAD2,"{FFFFFF}[{F81414}G-Protect{FFFFFF}] {C3C3C3}Samo Admini!");
    return 1;
}
And in your dialog-response, you have 2 problems:
- you chose DIALOG_STYLE_LIST instead of DIALOG_STYLE_INPUT 2 times
- you resetted the houseid (AIzm[playerid]) BEFORE the query, this should be placed after it, otherwise you would update the address of the house with id -1 which doesn't exist and no update will take place in MySQL.
pawn Код:
if(dialogid == 39)
    {
        if(response)
        {
            if(AIzm[playerid] == -1) return SCM(playerid,COLOR_GRAD2,"*Nepoznat ID kuce!");
            new adresa[128],upit[128];
            if(sscanf(inputtext,"s[128]",adresa)) return ShowPlayerDialog(playerid,39,DIALOG_STYLE_INPUT,"{0ed400}Adresa","{FFFFFF}Upisite novu adresu za ovu kucu:","Promijeni","Nazad");
            if(strlen(adresa) < 5)
            {
                SCM(playerid,COLOR_GRAD2,"*Adresa je prekratka!");
                ShowPlayerDialog(playerid,39,DIALOG_STYLE_INPUT,"Izmena kuce","Upisite novu adresu za ovu kucu:","Promijeni","Nazad");
                return 1;
            }
            else if(strlen(adresa) > 128)
            {
                SCM(playerid,COLOR_GRAD2,"*Adresa je preduga!");
                ShowPlayerDialog(playerid,39,DIALOG_STYLE_INPUT,"Izmena kuce","Upisite novu adresu za ovu kucu:","Promijeni","Nazad");
                return 1;
            }
            strmid(KucaInfo[AIzm[playerid]][hAdresa],adresa,0,strlen(adresa),255);
            UpdateLabels();
            SCMF(playerid,COLOR_WHITE,"{0ed400}[Kuca] {FFFFFF}Promijenio si adresu kuce. ID kuce: %d, Adresa: %s",AIzm[playerid],adresa);
            mysql_format(mysql,upit,128,"UPDATE `kuce` SET `Adresa` = '%s' WHERE `ID` = '%d'",adresa,AIzm[playerid]--from this getting id of house where I change adress but it says in cmd aadresa that is id of house 0 but my houses go from ID 1,2,3 etc...);
            mysql_tquery(mysql,upit,"","");
            AIzm[playerid] = -1;
        }
    }
    return 1;
}
Reply
#3

I try and nothing adress update to label and I check database houses and that house and it's not changed and it says that is id of house 0 but in database houses go from 1,2 etc... and when I created house 2 then I change adress and it's updated to database


edit: I was setting adress on house id 2 and that adress is set to house 1 ? why
Reply
#4

anyone? I was set adress to house id 2 and that adress is transfer somehow to house 1?thanks again
Reply
#5

anyone?thanks very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)