SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 05/09/2010, 09:05 AM   #11
Thomas.
Big Clucker
 
Thomas.'s Avatar
 
Join Date: Aug 2010
Location: The Netherlands
Posts: 130
Reputation: 17
Default Re: Converting to MySQL issues

Yes, nothing in there that could describe the problem.
Thomas. is offline  
Old 05/09/2010, 09:14 AM   #12
pen_theGun
Big Clucker
 
pen_theGun's Avatar
 
Join Date: Jan 2008
Posts: 179
Reputation: 0
Default Re: Converting to MySQL issues

try this?!

pawn Code:
public LoadProperty()
{
    mysql_query("SELECT * FROM `property`");
    mysql_store_result();
   
    new buffer[255];
        new field[33][255];
        new idx;

    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(buffer))
        {
            split(buffer, field);
            idx = strval(field[0]);

            HouseInfo[idx][hEntrancex] = floatstr(field[1]);
            HouseInfo[idx][hEntrancey] = floatstr(field[2]);
            HouseInfo[idx][hEntrancez] = floatstr(field[3]);
            HouseInfo[idx][hExitx] = floatstr(field[4]);
            HouseInfo[idx][hExity] = floatstr(field[5]);
            HouseInfo[idx][hExitz] = floatstr(field[6]);
            HouseInfo[idx][hHealthx] = strval(field[7]);
            HouseInfo[idx][hHealthy] = strval(field[8]);
            HouseInfo[idx][hHealthz] = strval(field[9]);
            HouseInfo[idx][hArmourx] = strval(field[10]);
            HouseInfo[idx][hArmoury] = strval(field[11]);
            HouseInfo[idx][hArmourz] = strval(field[12]);
            //printf("HouseInfo hEntrancez %f",HouseInfo[idx][hEntrancez]);
            strmid(HouseInfo[idx][hOwner], field[12], 0, strlen(field[13]), 255);
            strmid(HouseInfo[idx][hDiscription], field[13], 0, strlen(field[14]), 255);
            HouseInfo[idx][hValue] = strval(field[15]);
            HouseInfo[idx][hHel] = strval(field[16]);
            HouseInfo[idx][hArm] = strval(field[17]);
            HouseInfo[idx][hInt] = strval(field[18]);
            HouseInfo[idx][hLock] = strval(field[19]);
            HouseInfo[idx][hOwned] = strval(field[20]);
            HouseInfo[idx][hRooms] = strval(field[21]);
            HouseInfo[idx][hRent] = strval(field[22]);
            HouseInfo[idx][hRentabil] = strval(field[23]);
            HouseInfo[idx][hTakings] = strval(field[24]);
            HouseInfo[idx][hVec] = strval(field[25]);
            if(HouseInfo[idx][hVec] == 457)
            {
                HouseInfo[idx][hVec] = 411;
            }
            HouseInfo[idx][hVcol1] = strval(field[26]);
            HouseInfo[idx][hVcol2] = strval(field[27]);
            HouseInfo[idx][hDate] = strval(field[28]);
            HouseInfo[idx][hLevel] = strval(field[29]);
            HouseInfo[idx][hWorld] = strval(field[30]);
            HouseInfo[idx][hSetted] = strval(field[31]);
            //printf("HouseInfo:%d Owner:%s hTakings %d hVec %d",idx,HouseInfo[idx][hOwner],HouseInfo[idx][hTakings],HouseInfo[idx][hVec]);
        }
        printf("[SCRIPT]: Loaded %d Houses from Database", idx);
    }

    mysql_free_result();

    return 1;
}
pen_theGun is offline  
Old 05/09/2010, 09:21 AM   #13
Thomas.
Big Clucker
 
Thomas.'s Avatar
 
Join Date: Aug 2010
Location: The Netherlands
Posts: 130
Reputation: 17
Default Re: Converting to MySQL issues

Unfortunately, it didn't solve the problem.
Thomas. is offline  
Old 05/09/2010, 11:53 AM   #14
Thomas.
Big Clucker
 
Thomas.'s Avatar
 
Join Date: Aug 2010
Location: The Netherlands
Posts: 130
Reputation: 17
Default Re: Converting to MySQL issues

I have found the problem, but I'm not sure how to fix it.

I inserted debug messages to see where it goes wrong, like this:

pawn Code:
public LoadProperty()
{
    print("LoadProperty(): I have been called!");
   
    print("LoadProperty(): Trying to execute query...");
    mysql_query("SELECT * FROM `property`");
    print("LoadProperty(): Query executed.");
    mysql_store_result();
    print("LoadProperty(): Results stored.");
   
    print("LoadProperty(): Setting up buffer...");

    new buffer[256];
    print("LoadProperty(): Buffer created!");
    print("LoadProperty(): Allocating field memory...");
    new field[33][256];
    print("LoadProperty(): Field memory allocated!");
    new idx;
...

The debug message "Field memory allocated!" is not being outputted.
So something is wrong with the field variable.

I'm not sure about what's wrong with it though... what could be the problem?

Last edited by Thomas.; 05/09/2010 at 12:15 PM.
Thomas. is offline  
Old 05/09/2010, 12:17 PM   #15
pen_theGun
Big Clucker
 
pen_theGun's Avatar
 
Join Date: Jan 2008
Posts: 179
Reputation: 0
Default Re: Converting to MySQL issues

lower from 256 to 64?!

pawn Code:
new field[33][64];
pen_theGun is offline  
Old 05/09/2010, 02:16 PM   #16
Thomas.
Big Clucker
 
Thomas.'s Avatar
 
Join Date: Aug 2010
Location: The Netherlands
Posts: 130
Reputation: 17
Default Re: Converting to MySQL issues

Working like a charm, thank you!

Rest me one more question, why can't the cell size of the variable be bigger than 64?
I mean, what if the data stored is bigger?
Thomas. is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL error (Plugin or DB issues) Jake__ Server Support 5 25/07/2010 02:58 AM
Converting A Map From MTA > SA:MP? GTAPod Help Archive 8 30/12/2009 11:59 AM
Help with converting map? DeltaAirlines12 Help Archive 11 19/12/2009 04:05 PM
about converting map help Sfinx_17 Help Archive 10 24/11/2009 06:10 PM


All times are GMT. The time now is 12:31 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.