Help to update MYSQL plugin
#1

I need some help to syntax to update my MYSQL include/plugin.
I got this bugs idk how to fix
Someone could help me?

GW.pwn(1585) : error 017: undefined symbol "mysql_function_query"
1584
Код:
mysql_format(ConnectMYSQL, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Username` = '%s'", Nome(playerid) ); //S
1585
Код:
mysql_function_query(ConnectMYSQL, query, true, "OnConnection","i",playerid);
GW.pwn(3005) : error 017: undefined symbol "cache_get_field_content_int"
3005
Код:
pInfo[playerid][UserID] = cache_get_field_content_int(0, "UserID");
GW.pwn(7059) : error 017: undefined symbol "mysql_function_query"
7058
Код:
mysql_format(ConnectMYSQL, rsquery, sizeof(rsquery), "SELECT Username FROM `accounts` WHERE `Username` = '%s'", refferername ); //S
7059
Код:
mysql_function_query(ConnectMYSQL, rsquery, true, "CheckRefferExist","is",playerid,refferername);
GW.pwn(9493) : error 017: undefined symbol "cache_get_data"
9493
Код:
cache_get_data(rows, fields);
GW.pwn(9492) : warning 203: symbol is never used: "fields"
GW.pwn(9492 -- 9503) : warning 213: tag mismatch
9492
Код:
new rows, fields;

GW.pwn(9520) : warning 203: symbol is never used: "fields"
Код:
new rows, fields;
GW.pwn(9521) : error 017: undefined symbol "cache_get_data"
Код:
cache_get_data(rows, fields);
from:
Код:
forward OnLogin(playerid); public OnLogin(playerid) {
	new rows, fields;
	cache_get_data(rows, fields);
	if(rows) {
		OnPlayerLogin(playerid);
	}
	else {
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Incorrect Password!", "Please enter a correct password in order to log-in\nPress log-in to continue", "Log-in", "Quit");
	}
	return 1;
}
Same:
GW.pwn(9534) : error 017: undefined symbol "cache_get_data"
9534
Код:
cache_get_data(rows, fields);
Reply
#2

I have some problems to use the new sintaxy, anyone could help me to fix my bugs on this new things?
https://github.com/pBlueG/SA-MP-MySQL/releases

For example, change:

Код:
cache_get_data(rows, fields);
To
Код:
cache_get_row_count(rows, fields);
Gave me this error:
Код:
warning 202: number of arguments does not match definition
Reply
#3

mysql_function_query was a macro. If you don't want to rename it to mysql_tquery and remove the 3rd parameter (true/false for cache) completely, you can use:
pawn Код:
#define mysql_function_query(%0,%1,%2,%3,"%4"%5)    mysql_tquery(%0,%1,%3,#%4%5)
All the rest are explained here: https://sampforum.blast.hk/showthread.php?tid=616103
Reply
#4

Change all the wrong ones to the new ones , it's written in the releases page/ forum thread!
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
mysql_function_query was a macro. If you don't want to rename it to mysql_tquery and remove the 3rd parameter (true/false for cache) completely, you can use:
pawn Код:
#define mysql_function_query(%0,%1,%2,%3,"%4"%5)    mysql_tquery(%0,%1,%3,#%4%5)
All the rest are explained here: https://sampforum.blast.hk/showthread.php?tid=616103
Thank you! This link help me a lot!
+rep

Quote:
Originally Posted by Gotham
Посмотреть сообщение
Change all the wrong ones to the new ones , it's written in the releases page/ forum thread!
Yes, I'm just a bit of trouble

================================================== ================================================


Looking this:
https://sampforum.blast.hk/showthread.php?tid=616103

Is this right?
Код:
new MySQL:ConnectMYSQL;
Код:
ConnectMYSQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
I solved more then 50 errors
Left only this 4 idk how to fix, pls someone could help me?

GW.pwn(1585) : error 017: undefined symbol "mysql_function_query"
Код:
mysql_function_query(ConnectMYSQL, query, true, "OnConnection","i",playerid);
from
Код:
    new query[512];
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_format(ConnectMYSQL, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Username` = '%s'", Nome(playerid) ); //SELECT * FROM accounts WHERE Name = %s TROQUE PELA QUAL ESTA NO SEU BANCO DE DADOS
    mysql_function_query(ConnectMYSQL, query, true, "OnConnection","i",playerid);
GW.pwn(7059) : error 017: undefined symbol "mysql_function_query"
Код:
mysql_function_query(ConnectMYSQL, rsquery, true, "CheckRefferExist","is",playerid,refferername);
from
Код:
else
{ // sucess
    new rsquery[160], refferername[MAX_PLAYER_NAME+1];
    reffer[playerid] = refferername;
    format(refferername,sizeof(refferername),"%s",inputtext);
    mysql_format(ConnectMYSQL, rsquery, sizeof(rsquery), "SELECT Username FROM `accounts` WHERE `Username` = '%s'", refferername ); //SELECT * FROM accounts WHERE Name = %s TROQUE PELA QUAL ESTA NO SEU BANCO DE DADOS
    mysql_function_query(ConnectMYSQL, rsquery, true, "CheckRefferExist","is",playerid,refferername);
}
[b]GW.pwn(9504) : warning 213: tag mismatch
Код:
if(cache_get_row_count(ConnectMYSQL) == 1) {
GW.pwn(9549) : error 017: undefined symbol "cache_get_field_content_int"
Код:
int_dest[10] = cache_get_field_content_int(0, "admin");                 admin[playerid] = int_dest[10];
Reply
#6

For mysql_function_query, add the macro I posted in a_mysql.inc or in your script.

cache_get_row_count has 1 parameter which is passed by reference (to store the number of rows) and it's not the connection handle. You can simply use cache_num_rows with no parameters as well:
pawn Код:
if (cache_num_rows())
{
    // there are rows..
}
and cache_get_field_content_int becomes cache_get_value_name_int or cache_get_value_int and it returns 0/1 for failure/success, this means that the result is passed by reference again:
pawn Код:
cache_get_value_int(0, "admin", admin[playerid]);
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
For mysql_function_query, add the macro I posted in a_mysql.inc or in your script.

cache_get_row_count has 1 parameter which is passed by reference (to store the number of rows) and it's not the connection handle. You can simply use cache_num_rows with no parameters as well:
pawn Код:
if (cache_num_rows())
{
    // there are rows..
}
and cache_get_field_content_int becomes cache_get_value_name_int or cache_get_value_int and it returns 0/1 for failure/success, this means that the result is passed by reference again:
pawn Код:
cache_get_value_int(0, "admin", admin[playerid]);
I'm trying to update too...
Ty to your helps, it help me too
+rep

But i have a question..

I got this problem:
to load
int =
Код:
cache_get_value_int(0, "rank1", FactionInfo[factionid][rank1]);
to load
floats =
Код:
cache_get_value_float(0, "HQposX", FactionInfo[factionid][HQposX]);
But and to load strings? (varcharts) what need to do?
I made it, but its return me errors
Код:
cache_get_value_name(0, "member1", FactionInfo[factionid][member1],1,30);
Reply
#8

For loading strings, there are two functions:
pawn Код:
native cache_get_value_name(row_idx, const column_name[], destination[], max_len = sizeof(destination));
native cache_get_value_index(row_idx, column_idx, destination[], max_len = sizeof(destination));
cache_get_value accepts both column name and index as 2nd parameter so:
pawn Код:
cache_get_value_name(0, "member1", FactionInfo[factionid][member1], 30);
Basically the difference is that the connection handle was removed as parameter.
Reply
#9

I'm sorry to too long @Konstantinos
I was trying to solve all bugs before ask to help again, now left just 3 that idk how to fix
Could you help me?
And thank you again to everything...

GW.pwn(10040) : warning 213: tag mismatch
Код:
cache_get_value_name(0, "exists", field, ConnectMYSQL);
GW.pwn(10060) : warning 202: number of arguments does not match definition
Код:
new facid = cache_insert_id(ConnectMYSQL);
GW.pwn(11429) : error 025: function heading differs from prototype
Код:
public OnQueryError(errorid, error[], callback[], query[], connectionHandle) {
from:
Код:
public OnQueryError(errorid, error[], callback[], query[], connectionHandle) {
	printf("[OnQueryError] errorid %i query %s", errorid, query);
	return 1;
}
Reply
#10

I'll link to samp wiki for R40 which explains all the functions and their parameters in case you need it: https://sampwiki.blast.hk/wiki/MySQL/R40

Quote:
Originally Posted by ubunttu
Посмотреть сообщение
GW.pwn(10040) : warning 213: tag mismatch
Код:
cache_get_value_name(0, "exists", field, ConnectMYSQL);
connection handle is no longer a parameter in cache_get_value_name, remove it.
Quote:
Originally Posted by ubunttu
Посмотреть сообщение
GW.pwn(10060) : warning 202: number of arguments does not match definition
Код:
new facid = cache_insert_id(ConnectMYSQL);
cache_insert_id does not have any parameter, remove connection handle.

Quote:
Originally Posted by ubunttu
Посмотреть сообщение
GW.pwn(11429) : error 025: function heading differs from prototype
Код:
public OnQueryError(errorid, error[], callback[], query[], connectionHandle) {
connection handle has now a tag:
pawn Код:
public OnQueryError(errorid, const error[], const callback[], const query[], MySQL:handle)
Quote:
Originally Posted by pdonald
Посмотреть сообщение
THANK YOU!

You know how to fix it?
PHP код:
 error 017undefined symbol "cache_get_value_int_ovrld" 
PHP код:
 format(sG,sizeof(sG), "{FFFFFF}%i- %s - %d\n"posrankname,cache_get_value_int(r"FISHINGskills")); 
PHP код:
else if(strcmp(params,"fishing",true) == 0) {
    new 
rowsfieldsposrank;
    
mysql_query(ConnectMYSQL,"SELECT * FROM `accounts` ORDER BY FISHINGskills DESC LIMIT 15");
    
cache_get_row_count(rows);
    
cache_get_field_count(fields);
    for(new 
rrowsr++) {
        
posrank 1;
        
cache_get_value_name(r"Username",name);
        
format(sG,sizeof(sG), "{FFFFFF}%i- %s - %d\n"posrankname,cache_get_value_int(r"FISHINGskills"));
        
strcat(DialogNGL,sG);
        
ShowPlayerDialog(playerid20000DIALOG_STYLE_MSGBOX"Raking Fishing"DialogNGL"Fechar""");
    }

cache_get_value_int has two usages:
pawn Код:
native cache_get_value_index_int(row_idx, column_idx, &destination);
native cache_get_value_name_int(row_idx, const column_name[], &destination);
Those do not return the value directly but pass it by reference, so you will need to change it to:
pawn Код:
new player_fishing_skills, Cache: result = mysql_query(ConnectMYSQL, "SELECT * FROM `accounts` ORDER BY FISHINGskills DESC LIMIT 15");

for (new r, rows = cache_num_rows(); r < rows; r++)
{
    cache_get_value(r, "Username", name);
    cache_get_value_int(r, "FISHINGskills", player_fishing_skills);
 
    format(sG, sizeof(sG), "{FFFFFF}%i- %s - %d\n", r + 1, name, player_fishing_skills);
    strcat(DialogNGL, sG);
}

ShowPlayerDialog(playerid, 20000, DIALOG_STYLE_MSGBOX, "Raking Fishing", DialogNGL, "Fechar", "");

cache_delete(result);
As it is non-threaded queries, you will need to store the cache-id and remove it from the memory to avoid memory leaks. Threaded queries are always recommended though so consider changing it eventually.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)