mysql_tquery not calling callback.
#1

hi, i'm having some issues with the following code:

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 
irowsji++){
            
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, -10);
            
printf("[CARS]: Loaded car id %d of modelid %d."Car[i][car_id], Car[i][car_modelid]);
        }
    }
    
printf("Loaded %d cars."rows);
    return 
true;

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:

PHP Code:
[03/23/20 22:54:24] [INFOConnection handle with id '1' successfully created.
[
03/23/20 22:54:24] [DEBUGCHandleManager::Create - new handle 0x8fb9f18
[03/23/20 22:54:24] [DEBUGmysql_connect: return value'1'
[03/23/20 22:54:24] [DEBUGmysql_errno(1)
[
03/23/20 22:54:24] [DEBUGCHandle::GetErrorId(this=0x8fb9f18)
[
03/23/20 22:54:24] [DEBUGCConnection::GetError(this=0x8f9e800connection=0x9006220)
[
03/23/20 22:54:24] [DEBUGCHandle::GetErrorId - return valuetrueerror id'0'error msg''
[03/23/20 22:54:24] [DEBUGmysql_errno: return value'0'
[03/23/20 22:54:24] [DEBUGmysql_tquery(1"SELECT * FROM `cars`""LoadCarData""")
[
03/23/20 22:54:24] [DEBUGCCallback::Create(amx=0x8fc7a10name='LoadCarData'format=''params=0xf5368f44param_offset=5)
[
03/23/20 22:54:24] [DEBUGCCallback::Create callback index for 'LoadCarData'24
[03/23/20 22:54:24] [INFOCallback 'LoadCarData' set up for delayed execution.
[
03/23/20 22:54:24] [DEBUGcreated delayed callback with 0 parameter
[03/23/20 22:54:24] [DEBUGCHandle::Execute(this=0x8fb9f18type=1query=0x9031c54)
[
03/23/20 22:54:24] [DEBUGCHandle::Execute - return valuetrue
[03/23/20 22:54:24] [DEBUGmysql_tquery: return value'1'
[03/23/20 22:54:24] [DEBUGCThreadedConnection::WorkerFunc(this=0xf2c0b008connection=0xf2c0b008)
[
03/23/20 22:54:24] [DEBUGCThreadedConnection::WorkerFunc(this=0xf348d008connection=0xf348d008)
[
03/23/20 22:54:24] [DEBUGCThreadedConnection::WorkerFunc(this=0xf3d0f008connection=0xf3d0f008
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.
Reply
#2

Remove the InitLoadCars(),
Code:
mysql_tquery(db, "SELECT * FROM cars", "LoadCarData");
// Under OnGameModeInit
Reply
#3

Quote:
Originally Posted by Adamoneoone
View Post
Remove the InitLoadCars(),
Code:
mysql_tquery(db, "SELECT * FROM cars", "LoadCarData");
// Under OnGameModeInit

EDIT: NVM: Your script isn't able to connect to the database, check the credentials again.
I tried the method you said, and it's still the same result. I don't think it's the database, though. When the script runs, it prints if it connected to the db sucessfully, and it does so right now.
Reply
#4

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?
Reply
#5

Quote:
Originally Posted by Adamoneoone
View Post
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?
PHP Code:
[03/23/20 23:26:46] [INFOchanged log level from 'warning, error' to 'debug, info, warning, error'
[03/23/20 23:26:46] [DEBUGmysql_connect("127.0.0.1""padmin""*****""sv"0)
[
03/23/20 23:26:46] [DEBUGCHandleManager::Create(this=0x8438500host='127.0.0.1'user='padmin'pass='****'db='sv'options=0x84e3cc0)
[
03/23/20 23:26:46] [INFOCreating new connection handle...
[
03/23/20 23:26:46] [DEBUGCConnection::CConnection(this=0x84c1800host='127.0.0.1'user='padmin'passw='****'db='sv'options=0x84e3cc0)
[
03/23/20 23:26:46] [DEBUGCConnection::CConnection - new connection 0x8529220
[03/23/20 23:26:46] [DEBUGCConnection::CConnection(this=0xf3d0f008host='127.0.0.1'user='padmin'passw='****'db='sv'options=0x84e3cc0)
[
03/23/20 23:26:46] [DEBUGCConnection::CConnection - new connection 0x85417e8
[03/23/20 23:26:46] [DEBUGCThreadedConnection::CThreadedConnection(this=0xf3d0f008connection=0xf3d0f008)
[
03/23/20 23:26:46] [DEBUGCConnectionPool::CConnectionPool(size=2this=0x8498580)
[
03/23/20 23:26:46] [DEBUGCConnection::CConnection(this=0xf348d008host='127.0.0.1'user='padmin'passw='****'db='sv'options=0x84e3cc0)
[
03/23/20 23:26:46] [DEBUGCConnection::CConnection - new connection 0x8547e88
[03/23/20 23:26:46] [DEBUGCThreadedConnection::CThreadedConnection(this=0xf348d008connection=0xf348d008)
[
03/23/20 23:26:46] [DEBUGCConnection::CConnection(this=0xf2c0b008host='127.0.0.1'user='padmin'passw='****'db='sv'options=0x84e3cc0)
[
03/23/20 23:26:46] [DEBUGCConnection::CConnection - new connection 0x854e4e8
[03/23/20 23:26:46] [DEBUGCThreadedConnection::CThreadedConnection(this=0xf2c0b008connection=0xf2c0b008)
[
03/23/20 23:26:46] [INFOConnection handle with id '1' successfully created.
[
03/23/20 23:26:46] [DEBUGCHandleManager::Create - new handle 0x84dcf18
[03/23/20 23:26:46] [DEBUGmysql_connect: return value'1'
[03/23/20 23:26:46] [DEBUGmysql_errno(1)
[
03/23/20 23:26:46] [DEBUGCHandle::GetErrorId(this=0x84dcf18)
[
03/23/20 23:26:46] [DEBUGCConnection::GetError(this=0x84c1800connection=0x8529220)
[
03/23/20 23:26:46] [DEBUGCHandle::GetErrorId - return valuetrueerror id'0'error msg''
[03/23/20 23:26:46] [DEBUGmysql_errno: return value'0'
[03/23/20 23:26:46] [DEBUGmysql_tquery(1"SELECT * FROM cars""LoadCarData""")
[
03/23/20 23:26:46] [DEBUGCCallback::Create(amx=0x84eaa10name='LoadCarData'format=''params=0xf5368eacparam_offset=5)
[
03/23/20 23:26:46] [DEBUGCCallback::Create callback index for 'LoadCarData'24
[03/23/20 23:26:46] [INFOCallback 'LoadCarData' set up for delayed execution.
[
03/23/20 23:26:46] [DEBUGcreated delayed callback with 0 parameter
[03/23/20 23:26:46] [DEBUGCHandle::Execute(this=0x84dcf18type=1query=0x8554c54)
[
03/23/20 23:26:46] [DEBUGCHandle::Execute - return valuetrue
[03/23/20 23:26:46] [DEBUGmysql_tquery: return value'1'
[03/23/20 23:26:46] [DEBUGCThreadedConnection::WorkerFunc(this=0xf2c0b008connection=0xf2c0b008)
[
03/23/20 23:26:46] [DEBUGCThreadedConnection::WorkerFunc(this=0xf348d008connection=0xf348d008)
[
03/23/20 23:26:46] [DEBUGCThreadedConnection::WorkerFunc(this=0xf3d0f008connection=0xf3d0f008
yes, i do have mysql_log(ALL);
Reply
#6

Code:
for(new i, j = rows; i < j; i++)
to
Code:
for (new i; i < rows; i++)
Reply
#7

Quote:
Originally Posted by Adamoneoone
View Post
Code:
for(new i, j = rows; i < j; i++)
to
Code:
for (new i; i < rows; i++)
Yeah, same result. This is honestly one of the most annoying bugs I've ever seen.
Reply
#8

Code:
InitLoadCars(){

    mysql_tquery(db, "SELECT * FROM `cars` ORDERBY `car_id`, "LoadCarData");
    return true;
}
Try this
Reply
#9

Quote:
Originally Posted by SiaReyes
View Post
Code:
InitLoadCars(){

    mysql_tquery(db, "SELECT * FROM `cars` ORDERBY `car_id`, "LoadCarData");
    return true;
}
Try this
Tried it, nothing. Adding a print in InitLoadCars shows that the function gets called, but nothing in the callback ever happens. This is soo wierd.
Reply
#10

Does "Loaded %d cars" is printed in console/server log?

Try this: put the mysql_tquery after the MySQL connection code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)