SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 11/08/2012, 01:49 PM   #2711
D_Malfoy
Little Clucker
 
Join Date: Jul 2010
Posts: 42
Reputation: 15
Default Re: [REL] MySQL Plugin (R7 released)

Quote:
Originally Posted by D_Malfoy View Post
Sorry of it was stated already,but is it possible to get R7. For centos?
nvm this worked AndreT compiled version - http://www.sf-se.net/dev/mysql-r7_2-zeexfix.so .. (tested on CentOS)
__________________


===================================
Have I helped or assisted you in anyway? Click to give me a reputation.
===================================
My Work:
Quote:
[Filterscripts] : Boombox - iPod Player | [Maps] LS Restaurant - Pershing Hall + C.H. - Island
D_Malfoy is offline   Reply With Quote
Old 13/08/2012, 12:53 PM   #2712
steki.
High-roller
 
steki.'s Avatar
 
Join Date: Nov 2010
Location: São Paulo, Brasil
Posts: 2,557
Reputation: 317
Default Re: [REL] MySQL Plugin (R7 released)

Is there an way to execute stored procedures?
steki. is offline   Reply With Quote
Old 13/08/2012, 02:54 PM   #2713
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,938
Reputation: 538
Default Re: [REL] MySQL Plugin (R7 released)

On windows I'm getting alot of 'bad heap releases' from the latest crashdetect..
Kar is offline   Reply With Quote
Old 13/08/2012, 04:07 PM   #2714
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Posts: 1,216
Reputation: 141
Default Re: [REL] MySQL Plugin (R7 released)

Quote:
[13 16:14:18]Error id 2013: Lost connection to MySQL server during query('SELECT 1 FROM `Account` WHERE `Xp`>0 AND `IP`='SOME_IP_HERE'')
I get a few of this errors everyday.
In R6, I could fix it using this:
pawn Code:
public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
{
    if(errorid==CR_SERVER_LOST) mysql_query(query);
}
But now, in R7, I can't, because there are additional parameters, that I can't get with this callback(like playerid).
Any ideas on how to fix this?

Note: I have mutex disabled, because I think it caused some random crashes earlier.
Note2: I connect to mysql using the external IP, not 127.0.0.1. That way, I can test my gamemode on my local pc.
wups is offline   Reply With Quote
Old 13/08/2012, 08:31 PM   #2715
Hiddos
High-roller
 
Hiddos's Avatar
 
Join Date: Sep 2008
Posts: 3,304
Reputation: 2184
Default Re: [REL] MySQL Plugin (R7 released)

So right know I've got this code:
pawn Code:
new str[128];
format(str, sizeof str, "SELECT player_password FROM players WHERE player_name = '%s' LIMIT 1", p_info[playerid][player_name]);
printf("query: %s", str);
mysql_function_query(mysql_conn, str, true, "mysql_logreg", "is", playerid, inputtext);

This query, however, fails for some odd reason. When I check the logs for the printed string, it gives me the correct data:
Code:
query: SELECT player_password FROM players WHERE player_name = 'krispykreme' LIMIT 1
In the MySQL logs, however, it shows me this:
Code:
Passing query SELECT player_password FROM players WHERE player_name = 'krispykreme' LIMIT 1 | is
I have no idea why it does this. So far, I've noticed that the 'is' part directs back to the format parameter in mysql_function_query.

Could anyone help me out on this one?
__________________
Quote:
Originally Posted by DeWolf View Post
For fuck's sake people, this whole thread is fucked up now.
Hiddos is offline   Reply With Quote
Old 13/08/2012, 08:49 PM   #2716
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 966
Reputation: 414
Default Re: [REL] MySQL Plugin (R7 released)

I cannot see an obvious mistake there, perhaps it is because it is already quite late and I've been trying out stuff in C++ for the past few hours. But yes, the design is to debug like that, the debug message looks fine to me as well. So question: is mysql_logreg fired?

On a side note, cache_get_row_int(row, index)
I have been fiddling around with the plugin code numerous times in the past, but today, as I was styling up my gamemode's MySQL-related functions, I thought of creating a function that would return an integer instead of storing a string.

Code:
// native cache_get_row_int(row, idx, connectionHandle = 1);
cell AMX_NATIVE_CALL Natives::n_cache_get_row_int(AMX* amx, cell* params)
{
	unsigned int cID = params[3] - 1;
	Mutex::getInstance()->_lockMutex();
	VALID_CONNECTION_HANDLE("cache_get_row_int", cID);
	CMySQLHandler *cHandle = SQLHandle[cID];

	unsigned int a = params[1];
	if(a > cHandle->m_sCache.size())
		return 0;

	int val = atoi(cHandle->m_sCache[a][params[2]]);

	Mutex::getInstance()->_unlockMutex();
	return val;
}
This is what I came up with in C++. Now I am not advanced in the language in any way (as some might already notice from a short read), but I followed the syntax of other natives in CScripting.cpp.

This also requires that you modify the Natives class in CScripting.h and add the line:
Code:
class Natives
{
public:
    // ...
    static cell AMX_NATIVE_CALL n_cache_get_row_int(AMX* amx, cell* params);
    // ...
}
and also register the native for AMX in main.cpp:
Code:
const AMX_NATIVE_INFO MySQLNatives[] = 
{
    // ...
    {"cache_get_row_int",		Natives::getInstance()->n_cache_get_row_int},
    // ...
    {NULL, NULL}
};
I also ran a quick speedtest, comparing these 2 codes:
pawn Code:
goldpot_MaxID = cache_get_row_int(0, 0);
pawn Code:
cache_get_row(0, 0, str), goldpot_MaxID = strval(str);
It appears that the cache_get_row_int is 1,5 times faster than first using cache_get_row and then strval.

This function very much pleases me as it makes my job a lot easier, so huh, thought I'd share. Cannot share a working compiled version though since my version of the plugin is too heavily modified (and possibly a bit bugged in other areas).
AndreT is offline   Reply With Quote
Old 13/08/2012, 08:58 PM   #2717
Hiddos
High-roller
 
Hiddos's Avatar
 
Join Date: Sep 2008
Posts: 3,304
Reputation: 2184
Default Re: [REL] MySQL Plugin (R7 released)

Quote:
Originally Posted by AndreT View Post
I cannot see an obvious mistake there, perhaps it is because it is already quite late and I've been trying out stuff in C++ for the past few hours. But yes, the design is to debug like that, the debug message looks fine to me as well. So question: is mysql_logreg fired?
I already fixed it, but thank you anyway . I made a very silly mistake because my field name was spelled differently.
__________________
Quote:
Originally Posted by DeWolf View Post
For fuck's sake people, this whole thread is fucked up now.
Hiddos is offline   Reply With Quote
Old 14/08/2012, 10:43 AM   #2718
xxmitsu
Gangsta
 
Join Date: Feb 2009
Posts: 622
Reputation: 36
Default Re: [REL] MySQL Plugin (R7 released)

@AndreT, good job. I guess, same thing you could do with floats instead of using floatstr in pawn.
__________________
aka xanto - Retired - Former eGaming.ro technical staff.
xxmitsu is offline   Reply With Quote
Old 15/08/2012, 03:52 AM   #2719
Sabio
Little Clucker
 
Join Date: May 2012
Posts: 25
Reputation: 0
Default Respuesta: [REL] MySQL Plugin (R7 released)

Mysql RC7 centos pls? (Linux)
Sabio is offline   Reply With Quote
Old 15/08/2012, 04:59 AM   #2720
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 3,933
Reputation: 415
Default Re: [REL] MySQL Plugin (R7 released)

It's on the page before this.. Learn to read before posting. http://www.sf-se.net/dev/mysql-r7_2-zeexfix.so
__________________
Luis- 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
****** Project: Glass int3s0 Everything and Nothing 99 26/02/2013 04:22 PM
MySQL Plugin R5 plugin problem dud Scripting Help 12 05/12/2011 06:28 PM
Strikens Mysql vs BlueG's Mysql plugin PrawkC Scripting Help 4 30/09/2011 10:30 AM
[help][plugin] Can't load mysql plugin mariomako Help Archive 8 16/07/2011 02:37 PM
mysql plugin. loading plugin failed ikkentim Help Archive 2 10/02/2011 02:32 PM


All times are GMT. The time now is 12:44 AM.


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