HELP I can't use no mysql script
#1

If i try to start any script (mtrp, sa:rp, cwrp) i take a biiiig crash. If i don't have this function in mtrp, it works.
How can i fix it?
pawn Код:
public LoadSQLCars() {
    MySQLCheckConnection();
    new sql[64], fields[25][40], row[255];
    new Float:park_x, Float:park_y, Float:park_z, Float:park_a;
//  new owner[MAX_PLAYER_NAME];

    format(sql, sizeof(sql), "SELECT COUNT(*) FROM cars");
    samp_mysql_query(sql);
    //if (DEBUG) SQLLog(sql);
    samp_mysql_store_result();
    samp_mysql_fetch_row(row);
    totalcars = strval(row);
    samp_mysql_free_result();
    for (new i=1; i<=totalcars; i++)
    {
    format(sql, sizeof(sql), "SELECT * FROM cars WHERE id=%d", i);
    samp_mysql_query(sql);
    //if (DEBUG) SQLLog(sql);
    samp_mysql_store_result();
    samp_mysql_fetch_row(row);
    split(row, fields, '|');
    samp_mysql_free_result();
//  carid = strval(fields[0]);
    CarInfo[i][cModel] = strval(fields[1]);
    CarInfo[i][cLocationx] = floatstr(fields[2]);
    CarInfo[i][cLocationy] = floatstr(fields[3]);
    CarInfo[i][cLocationz] = floatstr(fields[4]);
    CarInfo[i][cAngle]     = floatstr(fields[5]);
    park_x = floatstr(fields[6]);
    park_y = floatstr(fields[7]);
    park_z = floatstr(fields[8]);
    park_a = floatstr(fields[9]);

    if (park_x != 0 && park_y != 0 && park_z != 0)
        {
        CarInfo[i][cLocationx] = park_x;
        CarInfo[i][cLocationy] = park_y;
        CarInfo[i][cLocationz] = park_z;
        CarInfo[i][cAngle] = park_a;
        }

    CarInfo[i][cColorOne] = strval(fields[10]);
    CarInfo[i][cColorTwo] = strval(fields[11]);
    CarInfo[i][cOwned] = strval(fields[12]);
    memcpy(CarInfo[i][cOwner], fields[13], 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4);
    memcpy(CarInfo[i][cDescription], fields[17], 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4);
    CarInfo[i][cValue] = strval(fields[18]);
    CarInfo[i][cFamily] =  strval(fields[15]);
    CarInfo[i][cFaction] = strval(fields[14]);
    CarInfo[i][cType] = strval(fields[16]);
    CarInfo[i][cRespawnable] = strval(fields[19]);
    CarInfo[i][cRespawnTime] = 0;
    CarInfo[i][cLock] = strval(fields[20]); // Locked
    CarInfo[i][cHouse] = strval(fields[22]);
    if (carsreloaded==0) AddStaticVehicleEx(CarInfo[i][cModel], CarInfo[i][cLocationx], CarInfo[i][cLocationy], CarInfo[i][cLocationz]+0.25, CarInfo[i][cAngle], CarInfo[i][cColorOne], CarInfo[i][cColorTwo], CarInfo[i][cValue]);
        else CarRespawn(i);
    }
    carsreloaded++;
    format(row, sizeof(row), "LoadSQLCars(): %d cars loaded", totalcars);
    printf(row);
}
Reply
#2

Do you have a MySQL server running and do you have the required tables/database setup for the script?
Reply
#3

Yes, I do. I have the tables, some cars in the db, and i use wamp. That's crash, is not an error.
Reply
#4

Bump. I need help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)