InitLoadCars(){
mysql_tquery(db, "SELECT * FROM cars", "LoadCarData", "");
return true;
}
forward LoadCarData();
public LoadCarData(){
new rows;
cache_get_row_count(rows);
if(!rows)
return print("No cars loaded.");
if(rows){
for(new i, j = rows; i < j; i++){
cache_get_value_name_int(i, "car_id", Car[i][car_id]);
cache_get_value_name_int(i, "car_modelid", Car[i][car_modelid]);
//cache_get_value_name(i, "car_name", Car[i][car_name], 65);
cache_get_value_name_int(i, "car_ownerid", Car[i][car_ownerid]); // should be owner's account_id;
cache_get_value_name_float(i, "car_spawnX", Car[i][car_spawnX]);
cache_get_value_name_float(i, "car_spawnY", Car[i][car_spawnY]);
cache_get_value_name_float(i, "car_spawnZ", Car[i][car_spawnZ]);
cache_get_value_name_float(i, "car_rot", Car[i][car_rot]);
cache_get_value_name(i, "car_licensePlate", Car[i][car_licensePlate], 16);
cache_get_value_name_int(i, "car_property", Car[i][car_property]);
cache_get_value_name_float(i, "car_km", Car[i][car_km]);
//Car[i][car_lockStatus] = true;
Car[i][car_obj] = CreateVehicle(Car[i][car_modelid], Car[i][car_spawnX], Car[i][car_spawnY], Car[i][car_spawnZ], Car[i][car_rot], -1, -1, 0);
printf("[CARS]: Loaded car id %d of modelid %d.", Car[i][car_id], Car[i][car_modelid]);
}
}
printf("Loaded %d cars.", rows);
return true;
}
[03/23/20 22:54:24] [INFO] Connection handle with id '1' successfully created.
[03/23/20 22:54:24] [DEBUG] CHandleManager::Create - new handle = 0x8fb9f18
[03/23/20 22:54:24] [DEBUG] mysql_connect: return value: '1'
[03/23/20 22:54:24] [DEBUG] mysql_errno(1)
[03/23/20 22:54:24] [DEBUG] CHandle::GetErrorId(this=0x8fb9f18)
[03/23/20 22:54:24] [DEBUG] CConnection::GetError(this=0x8f9e800, connection=0x9006220)
[03/23/20 22:54:24] [DEBUG] CHandle::GetErrorId - return value: true, error id: '0', error msg: ''
[03/23/20 22:54:24] [DEBUG] mysql_errno: return value: '0'
[03/23/20 22:54:24] [DEBUG] mysql_tquery(1, "SELECT * FROM `cars`", "LoadCarData", "")
[03/23/20 22:54:24] [DEBUG] CCallback::Create(amx=0x8fc7a10, name='LoadCarData', format='', params=0xf5368f44, param_offset=5)
[03/23/20 22:54:24] [DEBUG] CCallback::Create - callback index for 'LoadCarData': 24
[03/23/20 22:54:24] [INFO] Callback 'LoadCarData' set up for delayed execution.
[03/23/20 22:54:24] [DEBUG] created delayed callback with 0 parameter
[03/23/20 22:54:24] [DEBUG] CHandle::Execute(this=0x8fb9f18, type=1, query=0x9031c54)
[03/23/20 22:54:24] [DEBUG] CHandle::Execute - return value: true
[03/23/20 22:54:24] [DEBUG] mysql_tquery: return value: '1'
[03/23/20 22:54:24] [DEBUG] CThreadedConnection::WorkerFunc(this=0xf2c0b008, connection=0xf2c0b008)
[03/23/20 22:54:24] [DEBUG] CThreadedConnection::WorkerFunc(this=0xf348d008, connection=0xf348d008)
[03/23/20 22:54:24] [DEBUG] CThreadedConnection::WorkerFunc(this=0xf3d0f008, connection=0xf3d0f008)
mysql_tquery(db, "SELECT * FROM cars", "LoadCarData");
Remove the InitLoadCars(),
Code:
mysql_tquery(db, "SELECT * FROM cars", "LoadCarData"); EDIT: NVM: Your script isn't able to connect to the database, check the credentials again. |
NVM I just checked my mysql logs and it's the right thing you're right, do you have mysql_log(ALL)? can you post the whole mysql log?
|
[03/23/20 23:26:46] [INFO] changed log level from 'warning, error' to 'debug, info, warning, error'
[03/23/20 23:26:46] [DEBUG] mysql_connect("127.0.0.1", "padmin", "*****", "sv", 0)
[03/23/20 23:26:46] [DEBUG] CHandleManager::Create(this=0x8438500, host='127.0.0.1', user='padmin', pass='****', db='sv', options=0x84e3cc0)
[03/23/20 23:26:46] [INFO] Creating new connection handle...
[03/23/20 23:26:46] [DEBUG] CConnection::CConnection(this=0x84c1800, host='127.0.0.1', user='padmin', passw='****', db='sv', options=0x84e3cc0)
[03/23/20 23:26:46] [DEBUG] CConnection::CConnection - new connection = 0x8529220
[03/23/20 23:26:46] [DEBUG] CConnection::CConnection(this=0xf3d0f008, host='127.0.0.1', user='padmin', passw='****', db='sv', options=0x84e3cc0)
[03/23/20 23:26:46] [DEBUG] CConnection::CConnection - new connection = 0x85417e8
[03/23/20 23:26:46] [DEBUG] CThreadedConnection::CThreadedConnection(this=0xf3d0f008, connection=0xf3d0f008)
[03/23/20 23:26:46] [DEBUG] CConnectionPool::CConnectionPool(size=2, this=0x8498580)
[03/23/20 23:26:46] [DEBUG] CConnection::CConnection(this=0xf348d008, host='127.0.0.1', user='padmin', passw='****', db='sv', options=0x84e3cc0)
[03/23/20 23:26:46] [DEBUG] CConnection::CConnection - new connection = 0x8547e88
[03/23/20 23:26:46] [DEBUG] CThreadedConnection::CThreadedConnection(this=0xf348d008, connection=0xf348d008)
[03/23/20 23:26:46] [DEBUG] CConnection::CConnection(this=0xf2c0b008, host='127.0.0.1', user='padmin', passw='****', db='sv', options=0x84e3cc0)
[03/23/20 23:26:46] [DEBUG] CConnection::CConnection - new connection = 0x854e4e8
[03/23/20 23:26:46] [DEBUG] CThreadedConnection::CThreadedConnection(this=0xf2c0b008, connection=0xf2c0b008)
[03/23/20 23:26:46] [INFO] Connection handle with id '1' successfully created.
[03/23/20 23:26:46] [DEBUG] CHandleManager::Create - new handle = 0x84dcf18
[03/23/20 23:26:46] [DEBUG] mysql_connect: return value: '1'
[03/23/20 23:26:46] [DEBUG] mysql_errno(1)
[03/23/20 23:26:46] [DEBUG] CHandle::GetErrorId(this=0x84dcf18)
[03/23/20 23:26:46] [DEBUG] CConnection::GetError(this=0x84c1800, connection=0x8529220)
[03/23/20 23:26:46] [DEBUG] CHandle::GetErrorId - return value: true, error id: '0', error msg: ''
[03/23/20 23:26:46] [DEBUG] mysql_errno: return value: '0'
[03/23/20 23:26:46] [DEBUG] mysql_tquery(1, "SELECT * FROM cars", "LoadCarData", "")
[03/23/20 23:26:46] [DEBUG] CCallback::Create(amx=0x84eaa10, name='LoadCarData', format='', params=0xf5368eac, param_offset=5)
[03/23/20 23:26:46] [DEBUG] CCallback::Create - callback index for 'LoadCarData': 24
[03/23/20 23:26:46] [INFO] Callback 'LoadCarData' set up for delayed execution.
[03/23/20 23:26:46] [DEBUG] created delayed callback with 0 parameter
[03/23/20 23:26:46] [DEBUG] CHandle::Execute(this=0x84dcf18, type=1, query=0x8554c54)
[03/23/20 23:26:46] [DEBUG] CHandle::Execute - return value: true
[03/23/20 23:26:46] [DEBUG] mysql_tquery: return value: '1'
[03/23/20 23:26:46] [DEBUG] CThreadedConnection::WorkerFunc(this=0xf2c0b008, connection=0xf2c0b008)
[03/23/20 23:26:46] [DEBUG] CThreadedConnection::WorkerFunc(this=0xf348d008, connection=0xf348d008)
[03/23/20 23:26:46] [DEBUG] CThreadedConnection::WorkerFunc(this=0xf3d0f008, connection=0xf3d0f008)
for(new i, j = rows; i < j; i++)
for (new i; i < rows; i++)
Code:
for(new i, j = rows; i < j; i++) Code:
for (new i; i < rows; i++) |
InitLoadCars(){ mysql_tquery(db, "SELECT * FROM `cars` ORDERBY `car_id`, "LoadCarData"); return true; }
Code:
InitLoadCars(){ mysql_tquery(db, "SELECT * FROM `cars` ORDERBY `car_id`, "LoadCarData"); return true; } |