#1

I have building system on MySQL but the bulilding id 10 wont come in come and the script load 10 buildings

10 Buildings loaded from database

MySQL load

pawn Код:
}

forward LoadBuilding();
public LoadBuilding()
{
    new arrCoords[11][64];
    new sql[80], row[512];
    format(sql, sizeof(sql), "SELECT COUNT(*) FROM Buildings");
    mysql_query(sql);
    mysql_store_result();
    mysql_fetch_row(row);
    totalbuildings = 10;
    mysql_free_result();

    for (new idx=0; idx<totalbuildings; idx++)
    {
        format(sql, sizeof(sql), "SELECT * FROM Buildings WHERE BuildingID=%d", idx);
        mysql_query(sql);
        mysql_store_result();
        if (mysql_num_rows() > 0)
        {
            mysql_fetch_row(row);
            split(row, arrCoords, '|');
            mysql_free_result();
            Building[idx][EnterX] = floatstr(arrCoords[1]);
            Building[idx][EnterY] = floatstr(arrCoords[2]);
            Building[idx][EnterZ] = floatstr(arrCoords[3]);
            Building[idx][PickupID] = strval(arrCoords[4]);
            Building[idx][ExitX] = floatstr(arrCoords[5]);
            Building[idx][ExitY] = floatstr(arrCoords[6]);
            Building[idx][ExitZ] = floatstr(arrCoords[7]);
            strmid(Building[idx][BuildingName], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            Building[idx][ExitInterior] = strval(arrCoords[9]);
            Building[idx][Custom] = strval(arrCoords[10]);

            //Building[idx][PickupID] = CreateStreamPickup(1239, 1, Building[idx][EnterX], Building[idx][EnterY], Building[idx][EnterZ],15);
            CreateDynamicPickup(1318, 1, Building[idx][EnterX], Building[idx][EnterY], Building[idx][EnterZ], -1, -1, -1, 40.0);
        }
    }
    mysql_free_result();
    printf("%d Buildings loaded from database", totalbuildings);
    return true;
}
Reply
#2

Код:
totalbuildings = 11;
Or just use <= instead of <.
Reply
#3

Quote:
Originally Posted by WackoX
Посмотреть сообщение
Код:
totalbuildings = 11;
Or just use <= instead of <.
Still same, anyone else can help me?
Reply
#4

pawn Код:
mysql_query(sql);
mysql_store_result();
totalbuildings = mysql_fetch_int();
mysql_free_result();
Reply
#5

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
pawn Код:
mysql_query(sql);
mysql_store_result();
totalbuildings = mysql_fetch_int();
mysql_free_result();
Same, what is the problem ?
Reply
#6

Quote:
Originally Posted by N0FeaR
Посмотреть сообщение
Same, what is the problem ?
You tell me.
Reply
#7

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
You tell me.
Is not working building 10 is no come up in game but says they load 10 buildings.

Here is the load again

pawn Код:
forward LoadBuilding();
public LoadBuilding()
{
    new arrCoords[11][64];
    new sql[80], row[512];
    format(sql, sizeof(sql), "SELECT COUNT(*) FROM Buildings");
    mysql_query(sql);
    mysql_fetch_row(row);
    mysql_store_result();
    totalbuildings = mysql_fetch_int();
    mysql_free_result();

    for (new idx=0; idx<totalbuildings; idx++)
    {
        format(sql, sizeof(sql), "SELECT * FROM Buildings WHERE BuildingID=%d", idx);
        mysql_query(sql);
        mysql_store_result();
        if (mysql_num_rows() > 0)
        {
            mysql_fetch_row(row);
            split(row, arrCoords, '|');
            mysql_free_result();
            Building[idx][EnterX] = floatstr(arrCoords[1]);
            Building[idx][EnterY] = floatstr(arrCoords[2]);
            Building[idx][EnterZ] = floatstr(arrCoords[3]);
            Building[idx][PickupID] = strval(arrCoords[4]);
            Building[idx][ExitX] = floatstr(arrCoords[5]);
            Building[idx][ExitY] = floatstr(arrCoords[6]);
            Building[idx][ExitZ] = floatstr(arrCoords[7]);
            strmid(Building[idx][BuildingName], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            Building[idx][ExitInterior] = strval(arrCoords[9]);
            Building[idx][Custom] = strval(arrCoords[10]);

            //Building[idx][PickupID] = CreateStreamPickup(1239, 1, Building[idx][EnterX], Building[idx][EnterY], Building[idx][EnterZ],15);
            CreateDynamicPickup(1318, 1, Building[idx][EnterX], Building[idx][EnterY], Building[idx][EnterZ], -1, -1, -1, 40.0);
        }
    }
    mysql_free_result();
    printf("%d Buildings loaded from database", totalbuildings);
    return true;
}
Reply
#8

Are you sure buildings don't start off at 0?
Reply
#9

Quote:
Originally Posted by Calgon
Посмотреть сообщение
Are you sure buildings don't start off at 0?
Nope, start with 1
Reply
#10

Quote:
Originally Posted by N0FeaR
Посмотреть сообщение
Nope, start with 1
They start with 0 here

pawn Код:
for (new idx=0; idx<totalbuildings; idx++)
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)