SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 23/03/2020, 09:53 PM   #1
RazvyShel
Little Clucker
 
Join Date: Jul 2015
Posts: 14
Reputation: 0
Default mysql_tquery not calling callback.

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.
RazvyShel is offline   Reply With Quote
Old 23/03/2020, 10:05 PM   #2
Adamoneoone
Huge Clucker
 
Join Date: Sep 2014
Posts: 488
Reputation: 37
Default Re: mysql_tquery not calling callback.

Remove the InitLoadCars(),
Code:
mysql_tquery(db, "SELECT * FROM cars", "LoadCarData");
// Under OnGameModeInit
Adamoneoone is offline   Reply With Quote
Old 23/03/2020, 10:15 PM   #3
RazvyShel
Little Clucker
 
Join Date: Jul 2015
Posts: 14
Reputation: 0
Default Re: mysql_tquery not calling callback.

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.
RazvyShel is offline   Reply With Quote
Old 23/03/2020, 10:18 PM   #4
Adamoneoone
Huge Clucker
 
Join Date: Sep 2014
Posts: 488
Reputation: 37
Default Re: mysql_tquery not calling callback.

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?
Adamoneoone is offline   Reply With Quote
Old 23/03/2020, 10:24 PM   #5
RazvyShel
Little Clucker
 
Join Date: Jul 2015
Posts: 14
Reputation: 0
Default Re: mysql_tquery not calling callback.

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);
RazvyShel is offline   Reply With Quote
Old 23/03/2020, 10:27 PM   #6
Adamoneoone
Huge Clucker
 
Join Date: Sep 2014
Posts: 488
Reputation: 37
Default Re: mysql_tquery not calling callback.

Code:
for(new i, j = rows; i < j; i++)
to
Code:
for (new i; i < rows; i++)
Adamoneoone is offline   Reply With Quote
Old 23/03/2020, 10:33 PM   #7
RazvyShel
Little Clucker
 
Join Date: Jul 2015
Posts: 14
Reputation: 0
Default Re: mysql_tquery not calling callback.

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.
RazvyShel is offline   Reply With Quote
Old 24/03/2020, 04:50 AM   #8
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 618
Reputation: 57
Cool Re: mysql_tquery not calling callback.

Code:
InitLoadCars(){

    mysql_tquery(db, "SELECT * FROM `cars` ORDERBY `car_id`, "LoadCarData");
    return true;
}
Try this
SiaReyes is offline   Reply With Quote
Old 24/03/2020, 07:29 AM   #9
RazvyShel
Little Clucker
 
Join Date: Jul 2015
Posts: 14
Reputation: 0
Default Re: mysql_tquery not calling callback.

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.
RazvyShel is offline   Reply With Quote
Old 24/03/2020, 07:32 AM   #10
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 618
Reputation: 57
Default Re: mysql_tquery not calling callback.

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

Try this: put the mysql_tquery after the MySQL connection code.
SiaReyes is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql_tquery - No callback specified, skipping result saving Jonesy96 Scripting Help 3 01/06/2016 06:45 PM
mysql_tquery, callback didn't call Dutheil Scripting Help 1 24/07/2015 10:52 PM
Mysql_tquery callback return 1; Banditukas Scripting Help 2 25/12/2014 11:21 AM
Callback not called by mysql_tquery S4t3K Scripting Help 12 14/06/2014 07:42 PM
Calling a callback by myself? dusk Scripting Help 3 30/05/2014 12:05 PM


All times are GMT. The time now is 03:42 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.