SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 24/03/2020, 07:32 AM   #11
RazvyShel
Little Clucker
 
Join Date: Jul 2015
Posts: 14
Reputation: 0
Default Re: mysql_tquery not calling callback.

Think I found it.

PHP Code:
[08:33:43called initloadcars()
[
08:33:43]  * [SQLConnected to database 
Why does it get called before the db connects? InitLoadCars is called OnGameModeInit while I connect the db through a function from an include in main().
RazvyShel is offline   Reply With Quote
Old 24/03/2020, 07:34 AM   #12
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 618
Reputation: 57
Default Re: mysql_tquery not calling callback.

Check the edit I made in my previous reply.
SiaReyes is offline   Reply With Quote
Old 24/03/2020, 07:37 AM   #13
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
Does "Loaded %d cars" is printed in console/server log?

Try this: put the mysql_tquery after the MySQL connection code.
Now, it prints out:
PHP Code:
[08:38:05]  * [SQLConnected to database 
[08:38:05called initloadcars() 
If the callback would ever be called, there would be a print at the top of it saying it was called, but it never was. Neither is there any message 'Loaded x cars'.
RazvyShel is offline   Reply With Quote
Old 24/03/2020, 08:06 AM   #14
RazvyShel
Little Clucker
 
Join Date: Jul 2015
Posts: 14
Reputation: 0
Default Re: mysql_tquery not calling callback.

still stuck on it, added some more code to see if the query went right.

PHP Code:
[09:04:30]  * [SQLConnected to database 
[09:04:30calling InitCarData()
[
09:04:30finished InitCarData() and sent query 'SELECT * FROM cars' 
RazvyShel is offline   Reply With Quote
Old 24/03/2020, 08:08 AM   #15
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 618
Reputation: 57
Default Re: mysql_tquery not calling callback.

Do you have datas in car table?
SiaReyes is offline   Reply With Quote
Old 24/03/2020, 08:10 AM   #16
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
Do you have datas in car table?
yep.

https://gyazo.com/d519149414164f7b4e054dda4090b9b0
RazvyShel is offline   Reply With Quote
Old 24/03/2020, 08:13 AM   #17
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 618
Reputation: 57
Default Re: mysql_tquery not calling callback.

You mean the LoadCarData is called but no data is loaded?
SiaReyes is offline   Reply With Quote
Old 24/03/2020, 08:18 AM   #18
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
You mean the LoadCarData is called but no data is loaded?
PHP Code:
forward LoadCarData();
public 
LoadCarData(){

    print(
"calling LoadCarData()");

    new 
rows;
    
cache_get_row_count(rows);

    if(!
rows)
        return print(
"No rows found when loading cars.");

    if(
rows){

        for(new 
irowsi++){

            
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_int(i"car_ownerid"Car[i][car_ownerid]);

            
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_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;

basically, the tquery that is calling this goes through, but there is no actual loading happening. the print at the top never appears.
RazvyShel is offline   Reply With Quote
Old 24/03/2020, 08:21 AM   #19
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 618
Reputation: 57
Default Re: mysql_tquery not calling callback.

Try mysql_pquery instead mysql_tquery.
SiaReyes is offline   Reply With Quote
Old 24/03/2020, 08:25 AM   #20
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
Try mysql_pquery instead mysql_tquery.
damn, still the same thing.
RazvyShel 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:09 AM.


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