MySQL loading problem
#1

So okay, I'm using the R7 and tried creating this loading:
pawn Код:
stock LoadHouses()
{
    new query[25];
    format(query,sizeof(query),"SELECT * FROM houses");
    mysql_function_query(dbHandle,query,true,"OnHouseLoad","");
    return 1;
}
forward OnHouseLoad();
public OnHouseLoad()
{
    new rows,fields;
    cache_get_data(rows,fields,dbHandle);
    for(new i; i < rows; i++)
    {
        new tmp[32];
        HouseInfo[i][houseid]=strval(tmp);
        cache_get_row(i,0,tmp,dbHandle); HouseInfo[i+1][houseid]=strval(tmp);
        cache_get_row(i,1,tmp,dbHandle); format(HouseInfo[i+1][Owner],sizeof(tmp),tmp);
        cache_get_row(i,2,tmp,dbHandle); HouseInfo[i+1][Owned]  = strval(tmp);
        cache_get_row(i,3,tmp,dbHandle); HouseInfo[i+1][Price]  = strval(tmp);
        cache_get_row(i,4,tmp,dbHandle); HouseInfo[i+1][enX] = floatstr(tmp);
        cache_get_row(i,5,tmp,dbHandle); HouseInfo[i+1][enY] = floatstr(tmp);
        cache_get_row(i,6,tmp,dbHandle); HouseInfo[i+1][enZ] = floatstr(tmp);
        cache_get_row(i,7,tmp,dbHandle); HouseInfo[i+1][exX] = floatstr(tmp);
        cache_get_row(i,8,tmp,dbHandle); HouseInfo[i+1][exY] = floatstr(tmp);
        cache_get_row(i,9,tmp,dbHandle); HouseInfo[i+1][exZ] = floatstr(tmp);
        cache_get_row(i,10,tmp,dbHandle); HouseInfo[i+1][Interior] = strval(tmp);
        cache_get_row(i,11,tmp,dbHandle); HouseInfo[i+1][VirtualWorld]  = strval(tmp);
        cache_get_row(i,13,tmp,dbHandle); HouseInfo[i+1][Locked]        = strval(tmp);
        new labelstring[128];
        printf("%d",HouseInfo[i][houseid]);
        if(HouseInfo[i+1][Owned]==0) {format(labelstring,sizeof(labelstring),"Kaina: %d",HouseInfo[i+1][Price]); }
        else if(HouseInfo[i+1][Owned]==1) {format(labelstring,sizeof(labelstring),"Savininkas: %s",HouseInfo[i+1][Owner]);}
        HouseInfo[i+1][HouseLabel]=Create3DTextLabel(labelstring,0x00FF00FF,HouseInfo[i+1][enX],HouseInfo[i+1][enY],HouseInfo[i+1][enZ],25,HouseInfo[i+1][VirtualWorld]);
        HouseCount++;
    }
    return 1;
}
But guess what, that printf prints out 0!

I'm sure that the first field is right in the table and not null. Any ideas? Or am i doing something wrong?
Reply
#2

Put

pawn Код:
mysql_debug(1);
Under OnGameModeInit and post the results for the house loading.
Reply
#3

I've seen someone who had a similar problem yesterday. Here's the quote of the solution:
Quote:
Originally Posted by iGetty
Посмотреть сообщение
pawn Код:
format(query, sizeof(query), "SELECT * FROM kasutajad WHERE nimi = '%s' AND parool = '%s' LIMIT 1", pName, inputtext);
                mysql_query(query);

                if(mysql_num_rows() == 1)
You're not storing the result.

After the query, type:

mysql_store_result();

It should then work, since it's getting data from nothing there.
Could this be the problem and solution? Otherwise I have no idea
Reply
#4

Kwarde it is not neccesary in R7

Here is the log
pawn Код:
[14:06:16] ProcessQueryThread(OnHouseLoad) - Executing query SELECT * FROM houses...
[14:06:16] ProcessQueryThread(OnHouseLoad) - Query was successful.
[14:06:16] ProcessQueryThread(OnHouseLoad) - Data caching enabled.
[14:06:16] CMySQLHandler::StoreResult() - Result was stored.
[14:06:16] CMySQLHandler::FreeResult() - Result was successfully freed.
[14:06:16] ProcessQueryThread(OnHouseLoad) - Data being passed to ProcessTick().
[14:06:16] OnHouseLoad() - Callback is being called...
[14:06:16] >> cache_get_data(Connection handle: 1)
[14:06:16] ProcessTick() - The cache has been cleared.
I should mention, that the next field (index 1) is printed out correctly. The problem is the houseid
Reply
#5

So all these house IDs are 0? But in the database (if you open that database with a program) they are correct?
Reply
#6

Yes. They are auto_incremented, and not 0s
Reply
#7

Hmm..
pawn Код:
HouseInfo[i][houseid]=strval(tmp);
        cache_get_row(i,0,tmp,dbHandle); HouseInfo[i+1][houseid]=strval(tmp);
Why are you assigning 2 houseids? For example:
First loop (through 'rows'):
-HouseInfo[0][houseid] = 0;
-HouseInfo[1][houseid] = 0; //This one I'm not sure of! Let's pretend it starts with 0 and then is +1 every loop
Second loop (through 'rows'):
-HouseInfo[1][houseid] = 0;
-HouseInfo[2][houseid] = 1; //Watch!
Third loop:
-HouseInfo[2][houseid] = 0; //0 again!
..etc

Perhaps you should try to remove 'HouseInfo[i][houseid] = strval(tmp);' after 'new tmp[32]'. The TMP string is re-created every loop, so it is 0 all the time! HouseIDs may be assigned as how it should be assigned, but the next loop they are reset to 0 (as far as I can see)
Reply
#8

Nop,nothing changed. Interesting try though
Reply
#9

Hmm.
Can you perhaps send all your server files (zipped) to kwarde@mail.com? I could try to run some diagnostics and try to fix it
(Nope, I won't release anything, if you'd send it)

Kind regards,
Kwarde

p.s.
If you're gonna do it, please start the title with SAMP, so that it automatically gets sorted in my SAMP folder
Reply
#10

Nah, i have trust issues.

I will wait for any other ideas....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)