SA-MP Forums Archive
Problem to Load houses MYSQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem to Load houses MYSQL (/showthread.php?tid=522230)



Problem to Load houses MYSQL - Cam972 - 26.06.2014

hi,

I need to load my houses from mysql database

I have created the function to load the houses but she doesn't work

http://pastebin.com/q9n2D2FT


Re: Problem to Load houses MYSQL - Konstantinos - 26.06.2014

Assuming LoadProperty callback is from the mysql function that executes the query, you only load the row 0.
pawn Код:
public LoadProperty()
{
    for (new idx = 0, rows = cache_get_row_count(); idx != rows; ++idx)
    {
        if (idx == sizeof (HouseInfo)) break;
        HouseInfo[idx][hEntrancex] = cache_get_field_content_float(idx, "hEntrancex");
        HouseInfo[idx][hEntrancey] = cache_get_field_content_float(idx, "hEntrancey");
        HouseInfo[idx][hEntrancez] =cache_get_field_content_float(idx, "hEntrancez");
        HouseInfo[idx][hExitx] = cache_get_field_content_float(idx, "hExitx");
        HouseInfo[idx][hExity] = cache_get_field_content_float(idx, "hExity");
        HouseInfo[idx][hExitz] = cache_get_field_content_float(idx, "hExitz");
        HouseInfo[idx][hHealthx] = cache_get_field_content_int(idx, "hHealthx");
        HouseInfo[idx][hHealthy] = cache_get_field_content_int(idx, "hHealthy");
        HouseInfo[idx][hHealthz] = cache_get_field_content_int(idx, "hHealthz");
        HouseInfo[idx][hArmourx] = cache_get_field_content_int(idx, "hArmourx");
        HouseInfo[idx][hArmoury] = cache_get_field_content_int(idx, "hArmoury");
        HouseInfo[idx][hArmourz] = cache_get_field_content_int(idx, "hArmourz");
        cache_get_field_content(idx, "hOwner", HouseInfo[idx][hOwner], 1, MAX_PLAYER_NAME);
        cache_get_field_content(idx, "hDiscription", HouseInfo[idx][hDiscription], 128);
        HouseInfo[idx][hValue] = cache_get_field_content_int(idx, "hValue");
        HouseInfo[idx][hHel] = cache_get_field_content_int(idx, "hHel");
        HouseInfo[idx][hArm] = cache_get_field_content_int(idx, "hArm");
        HouseInfo[idx][hInt] = cache_get_field_content_int(idx, "hInt");
        HouseInfo[idx][hLock] = cache_get_field_content_int(idx, "hLock");
        HouseInfo[idx][hOwned] = cache_get_field_content_int(idx, "hOwned");
        HouseInfo[idx][hRooms] =cache_get_field_content_int(idx, "hRooms");
        HouseInfo[idx][hRent] = cache_get_field_content_int(idx, "hRent");
        HouseInfo[idx][hRentabil] = cache_get_field_content_int(idx, "hRentabil");
        HouseInfo[idx][hTakings] = cache_get_field_content_int(idx, "hTakings");
        HouseInfo[idx][hDate] = cache_get_field_content_int(idx, "hDate");
        HouseInfo[idx][hLevel] = cache_get_field_content_int(idx, "hLevel");
        HouseInfo[idx][hWorld] = cache_get_field_content_int(idx, "hWorld");
        HouseInfo[idx][hSecurity] = cache_get_field_content_int(idx, "hSecurity");
        HouseInfo[idx][hCoffre] = cache_get_field_content_int(idx, "hCoffre");
        Create3DTextLabel(HouseInfo[idx][hDiscription],0xB40100FF, HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez]+1,20,0);
        printf("HouseInfo:%d Owner:%s hTakings %d",idx,HouseInfo[idx][hOwner],HouseInfo[idx][hTakings]);
    }
}



Re : Problem to Load houses MYSQL - Cam972 - 26.06.2014

thanks but nothing :/


Re: Problem to Load houses MYSQL - Konstantinos - 26.06.2014

Are you sure there're rows in the table? What does it print to the console/server log?
pawn Код:
new rows = cache_get_row_count();
printf("rows: %i", rows);
for (new idx; idx != rows; ++idx)



Re: Problem to Load houses MYSQL - DogeMan - 26.06.2014

pawn Код:
public LoadProperty()
{
    //I DONT KNOW YOUR 'MAX_HOUSES'
    new HouseInfo[MAX_HOUSES];
    for (new idx = 0, idx != cache_get_row_count() + 1; idx++)
    {
        HouseInfo[idx][hEntrancex] = cache_get_field_content_float(idx, "hEntrancex");
        HouseInfo[idx][hEntrancey] = cache_get_field_content_float(idx, "hEntrancey");
        HouseInfo[idx][hEntrancez] =cache_get_field_content_float(idx, "hEntrancez");
        HouseInfo[idx][hExitx] = cache_get_field_content_float(idx, "hExitx");
        HouseInfo[idx][hExity] = cache_get_field_content_float(idx, "hExity");
        HouseInfo[idx][hExitz] = cache_get_field_content_float(idx, "hExitz");
        HouseInfo[idx][hHealthx] = cache_get_field_content_int(idx, "hHealthx");
        HouseInfo[idx][hHealthy] = cache_get_field_content_int(idx, "hHealthy");
        HouseInfo[idx][hHealthz] = cache_get_field_content_int(idx, "hHealthz");
        HouseInfo[idx][hArmourx] = cache_get_field_content_int(idx, "hArmourx");
        HouseInfo[idx][hArmoury] = cache_get_field_content_int(idx, "hArmoury");
        HouseInfo[idx][hArmourz] = cache_get_field_content_int(idx, "hArmourz");
        cache_get_field_content(idx, "hOwner", HouseInfo[idx][hOwner], 1, MAX_PLAYER_NAME);
        cache_get_field_content(idx, "hDiscription", HouseInfo[idx][hDiscription], 128);
        HouseInfo[idx][hValue] = cache_get_field_content_int(idx, "hValue");
        HouseInfo[idx][hHel] = cache_get_field_content_int(idx, "hHel");
        HouseInfo[idx][hArm] = cache_get_field_content_int(idx, "hArm");
        HouseInfo[idx][hInt] = cache_get_field_content_int(idx, "hInt");
        HouseInfo[idx][hLock] = cache_get_field_content_int(idx, "hLock");
        HouseInfo[idx][hOwned] = cache_get_field_content_int(idx, "hOwned");
        HouseInfo[idx][hRooms] =cache_get_field_content_int(idx, "hRooms");
        HouseInfo[idx][hRent] = cache_get_field_content_int(idx, "hRent");
        HouseInfo[idx][hRentabil] = cache_get_field_content_int(idx, "hRentabil");
        HouseInfo[idx][hTakings] = cache_get_field_content_int(idx, "hTakings");
        HouseInfo[idx][hDate] = cache_get_field_content_int(idx, "hDate");
        HouseInfo[idx][hLevel] = cache_get_field_content_int(idx, "hLevel");
        HouseInfo[idx][hWorld] = cache_get_field_content_int(idx, "hWorld");
        HouseInfo[idx][hSecurity] = cache_get_field_content_int(idx, "hSecurity");
        HouseInfo[idx][hCoffre] = cache_get_field_content_int(idx, "hCoffre");
        Create3DTextLabel(HouseInfo[idx][hDiscription],0xB40100FF, HouseInfo[idx][hEntrancex],HouseInfo[idx][hEntrancey],HouseInfo[idx][hEntrancez]+1,20,0);
        printf("HouseInfo:%d Owner:%s hTakings %d",idx,HouseInfo[idx][hOwner],HouseInfo[idx][hTakings]);
    }
}
Look your mysql log file


Re : Problem to Load houses MYSQL - Cam972 - 26.06.2014

This is my public CreateHouse()

http://pastebin.com/QkeM6ehJ

and mysql




Re : Problem to Load houses MYSQL - Cam972 - 27.06.2014

up :/


Re: Problem to Load houses MYSQL - Konstantinos - 27.06.2014

You showed a picture of updating a row only, not all the rows and the create is not the issue.

As I said:
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Are you sure there're rows in the table? What does it print to the console/server log?
pawn Код:
new rows = cache_get_row_count();
printf("rows: %i", rows);
for (new idx; idx != rows; ++idx)



Re : Problem to Load houses MYSQL - Cam972 - 27.06.2014

nothing :/ , the printf : rows: 0


Re: Problem to Load houses MYSQL - Konstantinos - 27.06.2014

It says that are 0 rows so it cannot retrieve any data since there are no rows. In case there are rows, then the query you executed is probably wrong so post it here.