MYSQL loading problem
#1

Hey guys i've just started creating my Garage system for my "server" that i started a few days back but when when it loads the garages up it only loads one correctly and in the correct position but the other three load one house down and onto of each other

Correct spawn: http://prntscr.com/1p3plh
Cluster of garages: http://prntscr.com/1p3phb

pawn Код:
stock LoadServerGarages()
{
    new row[512],idx;
    mysql_query("SELECT * FROM `garageinformation`");
    mysql_store_result();

    while(mysql_fetch_row(row))
    {

        mysql_fetch_field_row(row,"ID");
        GarageInfo[idx][gID] = strval(row);

        mysql_fetch_field_row(row,"Type");
        GarageInfo[idx][Type] = strval(row);

        mysql_fetch_field_row(row,"Price");
        GarageInfo[idx][Price] = strval(row);

        mysql_fetch_field_row(row,"IsOwned");
        GarageInfo[idx][IsOwned] = strval(row);

        mysql_fetch_field_row(GarageInfo[idx][Owner],"Owner");
       
        mysql_fetch_field_row(row,"Gar_X");
        GarageInfo[idx][Gar_X] = floatstr(row);

        mysql_fetch_field_row(row,"Gar_Y");
        GarageInfo[idx][Gar_Y] = floatstr(row);

        mysql_fetch_field_row(row,"Gar_Z");
        GarageInfo[idx][Gar_Z] = floatstr(row);

        if(GarageInfo[idx][IsOwned] == 0)
        {
            new string[100], TypeString[100];

            switch(GarageInfo[idx][Type])
            {
                case 1: { TypeString = "Small";  }
                case 2: { TypeString = "Medium"; }
                case 3: { TypeString = "Large";  }

            }
            print("Garaged Not Owned");
            format(string,sizeof(string),"{33AA33}[{FFFF82}GARAGE{33AA33}]\nType:{FFFF82}%s\n{33AA33}Buy Price:{FFFF82}%d",TypeString,GarageInfo[idx][Price]);
            GarageInfo[idx][g3DText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GarageInfo[idx][Gar_X], GarageInfo[idx][Gar_Y], GarageInfo[idx][Gar_Z], 10);
            GarageInfo[idx][gPickup] = CreateDynamicPickup(1318, 23, GarageInfo[idx][Gar_X], GarageInfo[idx][Gar_Y], GarageInfo[idx][Gar_Z], -1, -1, -1, 10);
        }
        else if(GarageInfo[idx][IsOwned] == 1)
        {

            new string[100], TypeString[100];

            switch(GarageInfo[idx][Type])
            {
                case 1: { TypeString = "Small";  }
                case 2: { TypeString = "Medium"; }
                case 3: { TypeString = "Large";  }

            }
            print("Garaged Owned");
            format(string,sizeof(string),"{33AA33}[{FFFF82}GARAGE{33AA33}]\nType:{FFFF82}%s\n{33AA33}Owner:{FFFF82}%s\n",TypeString,GarageInfo[idx][Owner]);
            GarageInfo[idx][g3DText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GarageInfo[idx][Gar_X], GarageInfo[idx][Gar_Y], GarageInfo[idx][Gar_Z], 10);
            GarageInfo[idx][gPickup] = CreateDynamicPickup(1318, 23, GarageInfo[idx][Gar_X], GarageInfo[idx][Gar_Y], GarageInfo[idx][Gar_Z], -1, -1, -1, 10);
           
        }
        idx++;
        printf("Loaded Garage: %d",GarageInfo[idx][gID]);
    }
}
Reply
#2

Try this maybe?

pawn Код:
stock LoadServerGarages()
{
    new row[512], strig[100], TypeString[8], idx;
    mysql_query("SELECT * FROM `garageinformation`");
    mysql_store_result();

    while (mysql_retrieve_row())
    {
        mysql_fetch_field_row(row,"ID");
        GarageInfo[idx][gID] = strval(row);

        mysql_fetch_field_row(row,"Type");
        GarageInfo[idx][Type] = strval(row);

        mysql_fetch_field_row(row,"Price");
        GarageInfo[idx][Price] = strval(row);

        mysql_fetch_field_row(row,"IsOwned");
        GarageInfo[idx][IsOwned] = strval(row);

        mysql_fetch_field_row(GarageInfo[idx][Owner],"Owner");

        mysql_fetch_field_row(row,"Gar_X");
        GarageInfo[idx][Gar_X] = floatstr(row);

        mysql_fetch_field_row(row,"Gar_Y");
        GarageInfo[idx][Gar_Y] = floatstr(row);

        mysql_fetch_field_row(row,"Gar_Z");
        GarageInfo[idx][Gar_Z] = floatstr(row);

        if(GarageInfo[idx][IsOwned] == 0)
        {
            switch(GarageInfo[idx][Type])
            {
                case 1: { TypeString = "Small";  }
                case 2: { TypeString = "Medium"; }
                case 3: { TypeString = "Large";  }
            }
            print("Garaged Not Owned");
            format(string,sizeof(string),"{33AA33}[{FFFF82}GARAGE{33AA33}]\nType:{FFFF82}%s\n{33AA33}Buy Price:{FFFF82}%d",TypeString,GarageInfo[idx][Price]);
            GarageInfo[idx][g3DText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GarageInfo[idx][Gar_X], GarageInfo[idx][Gar_Y], GarageInfo[idx][Gar_Z], 10);
            GarageInfo[idx][gPickup] = CreateDynamicPickup(1318, 23, GarageInfo[idx][Gar_X], GarageInfo[idx][Gar_Y], GarageInfo[idx][Gar_Z], -1, -1, -1, 10);
        }
        else if(GarageInfo[idx][IsOwned] == 1)
        {
            switch(GarageInfo[idx][Type])
            {
                case 1: { TypeString = "Small";  }
                case 2: { TypeString = "Medium"; }
                case 3: { TypeString = "Large";  }
            }
            print("Garaged Owned");
            format(string,sizeof(string),"{33AA33}[{FFFF82}GARAGE{33AA33}]\nType:{FFFF82}%s\n{33AA33}Owner:{FFFF82}%s\n",TypeString,GarageInfo[idx][Owner]);
            GarageInfo[idx][g3DText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GarageInfo[idx][Gar_X], GarageInfo[idx][Gar_Y], GarageInfo[idx][Gar_Z], 10);
            GarageInfo[idx][gPickup] = CreateDynamicPickup(1318, 23, GarageInfo[idx][Gar_X], GarageInfo[idx][Gar_Y], GarageInfo[idx][Gar_Z], -1, -1, -1, 10);
        }
        idx++;
        printf("Loaded Garage: %d",GarageInfo[idx][gID]);
    }
    mysql_free_result();
    return 1;
}
You should also free the result afterwards.
Reply
#3

Sorted the problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)