Mysql help
#1

I just found an old vendor system from an old gamemode i was scripting, but i get this errors:

Quote:

undefined symbol "cache_get_data"
undefined symbol "cache_get_value_int_ovrld"
undefined symbol "cache_get_value_int_ovrld"
undefined symbol "cache_get_field_float"
undefined symbol "cache_get_field_float"
undefined symbol "cache_get_field_float"
undefined symbol "cache_get_field_float"
undefined symbol "cache_get_value_int_ovrld"
undefined symbol "cache_get_value_int_ovrld"

The old gamemode was using an old mysql plugins so that's why the errors. Currently in this gamemode im making i'm using latest blueg's mysql plugin (R41-4).

How to fix it with new mysql?

Code:

pawn Код:
function Vendor_Load()
{
    static rows, fields;

    cache_get_data(rows, fields, g_iHandle);

    for (new i = 0; i < rows; i ++) if (i < MAX_VENDORS)
    {
        VendorData[i][vendorExists] = true;
        VendorData[i][vendorID] = cache_get_value_int(i, "vendorID");
        VendorData[i][vendorType] = cache_get_value_int(i, "vendorType");
        VendorData[i][vendorPos][0] = cache_get_field_float(i, "vendorX");
        VendorData[i][vendorPos][1] = cache_get_field_float(i, "vendorY");
        VendorData[i][vendorPos][2] = cache_get_field_float(i, "vendorZ");
        VendorData[i][vendorPos][3] = cache_get_field_float(i, "vendorA");
        VendorData[i][vendorInterior] = cache_get_value_int(i, "vendorInterior");
        VendorData[i][vendorWorld] = cache_get_value_int(i, "vendorWorld");

        Vendor_Refresh(i);
    }
    return 1;
}
Reply
#2

You can't make them like that anymore afaik, you have to do this now:

pawn Код:
cache_get_value_int(i,"vendorID",VendorData[i][vendorID]); //you do this for every one of them
Reply
#3

Ok thanks, what about vendorY,Z and A?
Reply
#4

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Ok thanks, what about vendorY,Z and A?
Same way as the others.
Reply
#5

cache_get_value_int? No float? And what about cache_get_data since i'm getting undefined symbol?
Reply
#6

No, you use the appropriate function for the type of data you're trying to retrieve, so cache_get_value_float for float values.

As for cache_get_data, that function might not be present in R41-4 anymore. For me, I use cache_num_rows() to gather the row count and to check if there are any rows returned from a query.
Reply
#7

So i shall use cache_num_rows instead of cache_get_data?
Reply
#8

Yes.
Reply
#9

I found a way to fix it. Now got another problem. In mysql log file i see "invalid connection handle" referred to this:

pawn Код:
mysql_tquery(g_SQL, "SELECT * FROM `vendors`", "Vendor_Load", "");
(OnGameModeInit to load vending machines)

Vendor_Load (after my fix):

pawn Код:
public Vendor_Load()
{
    static rows, fields;

    for (new i = 0; i < rows; i ++) if (i < MAX_VENDORS)
    {
    if(cache_num_rows() > 0)
    {
        VendorData[i][vendorExists] = true;
        VendorData[i][vendorID] = cache_get_value_int(i,"vendorID",VendorData[i][vendorID]);
        VendorData[i][vendorType] = cache_get_value_int(i,"vendorType",VendorData[i][vendorType]);
        VendorData[i][vendorPos][0] = cache_get_value_float(i, "vendorX",VendorData[i][vendorPos][0]);
        VendorData[i][vendorPos][1] = cache_get_value_float(i, "vendorY",VendorData[i][vendorPos][1]);
        VendorData[i][vendorPos][2] = cache_get_value_float(i, "vendorZ",VendorData[i][vendorPos][2]);
        VendorData[i][vendorPos][3] = cache_get_value_float(i, "vendorA",VendorData[i][vendorPos][3]);
        VendorData[i][vendorInterior] = cache_get_value_int(i,"vendorInterior",VendorData[i][vendorInterior]);
        VendorData[i][vendorWorld] = cache_get_value_int(i,"vendorWorld",VendorData[i][vendorWorld]);

        Vendor_Refresh(i);
    }
    }
    return 1;
}
Already checked, vending machines are created perfectly in mysql table. What's the problem?
Reply
#10

try now
PHP код:
public Vendor_Load()
{
    for(new 
icache_num_rows(); != ji++)
    {
        if(
MAX_VENDORS)
        {
             
VendorData[i][vendorExists] = true;
                
cache_get_value_int(i,"vendorID",VendorData[i][vendorID]);
                
cache_get_value_int(i,"vendorType",VendorData[i][vendorType]);
                
cache_get_value_float(i"vendorX",VendorData[i][vendorPos][0]);
                
cache_get_value_float(i"vendorY",VendorData[i][vendorPos][1]);
                
cache_get_value_float(i"vendorZ",VendorData[i][vendorPos][2]);
                
cache_get_value_float(i"vendorA",VendorData[i][vendorPos][3]);
                
cache_get_value_int(i,"vendorInterior",VendorData[i][vendorInterior]);
                
cache_get_value_int(i,"vendorWorld",VendorData[i][vendorWorld]);
                
Vendor_Refresh(i);
        }
    }
    return 
1;

Reply
#11

Quote:

[22:35:57] [DEBUG] mysql_tquery(0, "SELECT * FROM `vendors`", "Vendor_Load", "")

[22:35:57] [ERROR] mysql_tquery: invalid connection handle \'0\'

[22:35:57] [DEBUG] mysql_tquery: return value: \'0\'

Same.
Reply
#12

Try the mysql version that works with these commands,I\'ve had the same problem
Reply
#13

I can\'t change mysql version just for a vendor system...are you serious?
Reply
#14

Holy shit, i\'m stupid as fuck. I placed the
pawn Code:
mysql_tquery(g_SQL, "SELECT * FROM `vendors`", "Vendor_Load");
code BEFORE connecting to MySQL. Now everything loads perfectly.

WHY IM SO STUPID.

Thank you everyone.
Reply
#15

Just a question OP: How can you select something... before you connect to the mysql server?
Reply
#16

pawn Code:
[22:35:57] [ERROR] mysql_tquery: invalid connection handle \'0\'
You need to have a valid mysql connection before anything will work.
Reply
#17

Quote:
Originally Posted by denNorske
View Post
Just a question OP: How can you select something... before you connect to the mysql server?
Yeah i was a stupid.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)