23.03.2020, 21:53
hi, i'm having some issues with the following code:
i'm calling InitLoadCars in main(), and the function gets called. i have tried moving either above or below, nothing. i called InitLoadCars in OnGameModeInit, nothing. I messed around as much as possible even went as far as making only one function with an inline, but even then got the same results. LoadCarData simply won't call.
here's some of the mysql log:
Any actual help will be very much appreciated, I've been stuck on this for a while and just can't put my finger on it.
PHP Code:
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;
}
here's some of the mysql log:
PHP Code:
[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)