Only one 3D text label appears
#1

Good morning,

I got this code for loading houses:
pawn Код:
forward OnHouseLoad();
public OnHouseLoad()
{
    new rows,fields;
    cache_get_data(rows,fields,dbHandle);
    for(new i; i < rows; i++)
    {
        new tmp[16];
        HouseInfo[i][houseid]=strval(tmp);
        cache_get_row(0,1,HouseInfo[i][Owner],dbHandle);
        cache_get_row(0,2,tmp,dbHandle);
        HouseInfo[i][Owned] = strval(tmp);
        cache_get_row(0,3,tmp,dbHandle);
        HouseInfo[i][Price] = strval(tmp);
        cache_get_row(0,4,tmp,dbHandle);
        HouseInfo[i][enX] = floatstr(tmp);
        cache_get_row(0,5,tmp,dbHandle);
        HouseInfo[i][enY] = floatstr(tmp);
        cache_get_row(0,6,tmp,dbHandle);
        HouseInfo[i][enZ] = floatstr(tmp);
        cache_get_row(0,7,tmp,dbHandle);
        HouseInfo[i][exX] = floatstr(tmp);
        cache_get_row(0,8,tmp,dbHandle);
        HouseInfo[i][exY] = floatstr(tmp);
        cache_get_row(0,9,tmp,dbHandle);
        HouseInfo[i][exZ] = floatstr(tmp);
        cache_get_row(0,10,tmp,dbHandle);
        HouseInfo[i][Interior] = strval(tmp);
        cache_get_row(0,11,tmp,dbHandle);
        HouseInfo[i][VirtualWorld]  = strval(tmp);
        cache_get_row(0,13,tmp,dbHandle);
        HouseInfo[i][Locked]        = strval(tmp);
        new  labelstring[128];
        if(HouseInfo[i][Owned]==0) {format(labelstring,sizeof(labelstring),"Kaina: %d",HouseInfo[i][Price]);}
        else if(HouseInfo[i][Owned]==1) {format(labelstring,sizeof(labelstring),"Savininkas: %s",HouseInfo[i][Owner]);}
        HouseInfo[i][HouseLabel]=Create3DTextLabel(labelstring,0x00FF00FF,HouseInfo[i][enX],HouseInfo[i][enY],HouseInfo[i][enZ],25,HouseInfo[i][VirtualWorld]);
        HouseCount++;
        printf("%d",HouseCount);
    }
    return 1;
}
And the thing is that only 1 text label appears. HouseCount prints 8 (correct). There are more houses that one.
Reply
#2

Try printing the values returned by the database to check if the data is being loaded correctly. Just adding a single print isn't sufficient for debugging.

The code looks OK to me.
Reply
#3

Take another look at the cahe_get_row function. The first parameter is for the row ID. In this case, you're always loading the data from row 0 (the first row). So, cache_get_row(0, ...) should be cache_get_row(i, ...)
Reply
#4

hmm.i printed coordinates..They are all the same! But they are not in my DB...what the f?

EDIT:realcop. checking it now.

Aaaand you save the day! BUT,
pawn Код:
cache_get_row(i,1,HouseInfo[i][Owner],dbHandle);
this prints an empty row? what's wrong with it? In the enum it has 32cells,that should be enough. But it still is empty.
Reply
#5

Quote:
Originally Posted by dusk
Посмотреть сообщение
hmm.i printed coordinates..They are all the same! But they are not in my DB...what the f?

EDIT:realcop. checking it now.

Aaaand you save the day! BUT,
pawn Код:
cache_get_row(i,1,HouseInfo[i][Owner],dbHandle);
this prints an empty row? what's wrong with it? In the enum it has 32cells,that should be enough. But it still is empty.
r7+ doesn't load strings like it should be.

So you need to format it in order to work.

Increase tmp to like 32 or 24 (so that if someone has a name with 16 or more characters it doesn't cut the name)

And then use this line :

pawn Код:
cache_get_row(i,1,tmp,dbHandle); format(HouseInfo[i][Owner],sizeof(tmp),tmp);
Reply
#6

It works! Thankyou of course.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)