SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 13/04/2012, 10:22 PM   #2331
Legö
Little Clucker
 
Join Date: Apr 2010
Posts: 25
Reputation: 1
Default HELP: [REL] MySQL Plugin (R7 released)

Hello, i´ve changed my MYSQLplugin to MYSQL Plugin R6.

with windows samp server 0.3d ther is no problems. But with samp 0.3d RC2.
I connect to server and if the first mysql_ called close the server the connection.

Thats the parts they calld if a player connect...
Code:
public OnPlayerConnect(playerid)
{
    //ReconnectMySQL();
    CheckMySQL();
    GetPlayerName(playerid,PlayerName[playerid],MAX_PLAYER_NAME);
	new namestring = strfind(PlayerName[playerid], "$", true); //what is plname?
	checkban(playerid);
	if(CheckAccountExists(playerid) == 0)
	{
		AccountExists[playerid] = 0;//nein
	}
	else if(CheckAccountExists(playerid) == 1)
	{
		AccountExists[playerid] = 1;//ja
	}
        PlayerCountry[playerid] = GetPlayerCountryName(playerid);
 	if(namestring != -1)
	{
		SendClientMessage(playerid, COLOR_RED, "Please remove the $ from your name!");
		Kick(playerid);
		return 1;
	}
        if(!IsPlayerNPC(playerid))
	{
		new connectstring[256];
		format(connectstring, sizeof(connectstring), "* %s (%s) hat unseren Server betreten!", PlayerName[playerid], PlayerCountry[playerid]);
		printf(connectstring);
		SendClientMessageToAll(COLOR_GREY, connectstring);
                SendClientMessage(playerid, COLOR_GREY, "\n");
                SendClientMessage(playerid, COLOR_GREY, "\n");
                SendClientMessage(playerid, COLOR_GREY, "\n");
                SendClientMessage(playerid, COLOR_GREY, "\n");
                SendClientMessage(playerid, COLOR_GREY, "\n");
                SendClientMessage(playerid, COLOR_GREY, "\n");
                SendClientMessage(playerid, COLOR_GREY, "\n");
                SendClientMessage(playerid, COLOR_GREY, "\n");
                SendClientMessage(playerid, COLOR_GREY, "\n");
                SendClientMessage(playerid, COLOR_GREY, "\n");
	}
      ...
}
Code:
public checkban(playerid)
{
	new query[256],data[255],timestamp;
	format(query,sizeof(query),"SELECT * FROM ban WHERE name = '%s'", PlayerName[playerid]);
	mysql_query(query);
	//mysql_format(1,query, "SELECT * FROM ban WHERE name = '%s'");
    //mysql_function_query(1, query, false, "OnQueryFinish", "i", 1);
	mysql_store_result();
	if(mysql_num_rows())
	{
		mysql_get_field("dauer", data);
		timestamp=strval(data);
		if(mktime()<timestamp)
		{
			new zahl=timestamp-mktime();
			zahl=zahl/60;
			format(string,128,"SERVER: Du bist noch für %d Minuten gebannt",zahl);
			SendClientMessage(playerid,COLOR_LIGHTRED,string);
			GameTextForPlayer(playerid, "~b~Du bist: ~n~~r~gebannt", 600000, 3);
			return Kick(playerid);
		}
		else
		{
			
			format(query,sizeof(query),"DELETE FROM ban WHERE name =' %s'", PlayerName[playerid]);
			mysql_query(query);
    		//mysql_function_query(1, query, false, "OnQueryFinish", "i", 2);
		}
	}
	mysql_free_result();
	return 1;
}
Code:
public CheckAccountExists(playerid)
{
	format(string, sizeof(string), "SELECT * FROM users WHERE name = '%s'", PlayerName[playerid]);
	mysql_query(string);
	mysql_store_result();
	new value;
	value = mysql_num_rows();
	mysql_free_result();
	return value;
}
The Debug

Quote:
[00:09:54] >> mysql_ping( Connection handle: 1 )

[00:09:54] CMySQLHandler::Ping() - Connection is still alive.

[00:09:54] >> mysql_query( Connection handle: 1 )

[00:09:54] CMySQLHandler::Query(SELECT * FROM ban WHERE name = 'Lego') - Successfully executed.

[00:09:54] >> mysql_store_result( Connection handle: 1 )

[00:09:54] CMySQLHandler::StoreResult() - Result was stored.

[00:09:54] >> mysql_num_rows( Connection handle: 1 )

[00:09:54] CMySQLHandler::NumRows() - Returned 0 row(s)

[00:09:54] >> mysql_free_result( Connection handle: 1 )

[00:09:54] CMySQLHandler::FreeResult() - Result was successfully free'd.

[00:09:54] >> mysql_query( Connection handle: 1 )

[00:09:54] CMySQLHandler::Query(SELECT * FROM users WHERE name = 'Lego') - Successfully executed.

[00:09:54] >> mysql_store_result( Connection handle: 1 )

[00:09:54] CMySQLHandler::StoreResult() - Result was stored.

[00:09:54] >> mysql_num_rows( Connection handle: 1 )

[00:09:54] CMySQLHandler::NumRows() - Returned 1 row(s)

[00:09:54] >> mysql_free_result( Connection handle: 1 )

[00:09:54] CMySQLHandler::FreeResult() - Result was successfully free'd.

[00:09:54] >> mysql_query( Connection handle: 1 )

[00:09:54] CMySQLHandler::Query(SELECT * FROM users WHERE name = 'Lego') - Successfully executed.

[00:09:54] >> mysql_store_result( Connection handle: 1 )

[00:09:54] CMySQLHandler::StoreResult() - Result was stored.

[00:09:54] >> mysql_num_rows( Connection handle: 1 )

[00:09:54] CMySQLHandler::NumRows() - Returned 1 row(s)

[00:09:54] >> mysql_free_result( Connection handle: 1 )

[00:09:54] CMySQLHandler::FreeResult() - Result was successfully free'd.

[00:10:09] >> mysql_ping( Connection handle: 1 )

[00:10:09] CMySQLHandler::Ping() - Connection is still alive.
The Server_Log
Quote:
[00:09:54] Incoming connection: ****
[00:09:54] [join] Lego has joined the server (****)
[00:09:54] * Lego (Private IP) hat unseren Server betreten!
[00:09:58] [part] Lego has left the server (8:2)
[00:09:58] Lego Spawnt...
[00:09:58] Acc prüfung von Lego
[00:09:58] Lego hat ein Acc
[00:09:58] Setze zusätzliche Informationen und blende Gametexte für Lego ein.
__________________
Legö is offline   Reply With Quote
Old 13/04/2012, 11:18 PM   #2332
WooTFTW
Huge Clucker
 
WooTFTW's Avatar
 
Join Date: May 2011
Location: = GetPlayerPos(WooTFTW);
Posts: 260
Reputation: 35
Default Re: [REL] MySQL Plugin (R7 released)

Code:
[02:23:43] ERROR Commands out of sync; you can't run this command now on query SELECT COUNT(*) FROM accounts
[02:23:43] Commands out of sync for thread ID: -1
pawn Code:
mysql_query("SELECT COUNT(*) FROM accounts");
        mysql_store_result();

        count = mysql_fetch_int();
        mysql_free_result();
This sometimes goes out of sync, and sometimes it does not.
WooTFTW is offline   Reply With Quote
Old 14/04/2012, 09:51 AM   #2333
AndreT
High-roller
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 1,027
Reputation: 402
Default Re: [REL] MySQL Plugin (R7 released)

You should check any other queries that are executed prior to that for any possible unfreed memory.

Here's a common example:
pawn Code:
mysql_query("SELECT ... FROM ...");
mysql_store_result();
if(!mysql_num_rows())
{
    return false;
    // memory left unfreed!
}
mysql_fetch_row(line);
mysql_free_result();
AndreT is offline   Reply With Quote
Old 14/04/2012, 02:17 PM   #2334
bashar0151
Big Clucker
 
Join Date: Aug 2009
Location: Liverpool uk
Posts: 110
Reputation: 9
Default Re: [REL] MySQL Plugin (R7 released)

cool
bashar0151 is offline   Reply With Quote
Old 14/04/2012, 02:40 PM   #2335
Thomas.
Big Clucker
 
Join Date: Aug 2010
Location: The Netherlands
Posts: 125
Reputation: 15
Default Re: [REL] MySQL Plugin (R7 released)

Is anyone else experiencing random server crashes using R7 on Windows? (Without mysql_format())
Thomas. is offline   Reply With Quote
Old 15/04/2012, 02:29 AM   #2336
Delavor
Little Clucker
 
Join Date: Jul 2010
Location: Poland, Warsaw
Posts: 7
Reputation: 0
Default Re: [REL] MySQL Plugin (R7 released)

I have some problem with version R7 on my Debian 6 x64
Plugin is loaded but after send any query i got server crash.

Code:
*** buffer overflow detected ***: ./samp03svr terminated
======= Backtrace: =========
/lib32/libc.so.6(__fortify_fail+0x50)[0xf757ff80]
/lib32/libc.so.6(+0xe1eba)[0xf757eeba]
plugins/mysql.so(_ZN7Natives14n_mysql_formatEP6tagAMXPi+0x76f)[0xf749025f]
./samp03svr[0x80503e4]
./samp03svr[0x8051e85]
./samp03svr[0x80709ff]
./samp03svr[0x808127c]
./samp03svr[0x80ad6e1]
./samp03svr[0x80ad7d2]
./samp03svr[0x80b74c0]
./samp03svr[0x807d736]
./samp03svr[0x807d962]
./samp03svr[0x8077c23]
/lib32/libc.so.6(__libc_start_main+0xe6)[0xf74b3ca6]
./samp03svr(__gxx_personality_v0+0xf5)[0x804b4c1]
======= Memory map: ========
08048000-0816e000 r-xp 00000000 08:01 4572788                            /home/d                                              elavor/samp/samp03svr
0816e000-0818b000 rw-p 00125000 08:01 4572788                            /home/d                                              elavor/samp/samp03svr
0818b000-08195000 rw-p 00000000 00:00 0
09322000-09541000 rw-p 00000000 00:00 0                                  [heap]
f5c33000-f6108000 rw-p 00000000 00:00 0
f6108000-f6109000 ---p 00000000 00:00 0
f6109000-f6a05000 rw-p 00000000 00:00 0
f6a05000-f6a11000 r-xp 00000000 08:01 4572791                            /home/d                                              elavor/samp/plugins/sscanf.so
f6a11000-f6a12000 rw-p 0000c000 08:01 4572791                            /home/d                                              elavor/samp/plugins/sscanf.so
f6a12000-f6a1c000 r-xp 00000000 08:01 6176771                            /lib32/                                              libnss_files-2.11.3.so
f6a1c000-f6a1d000 r--p 00009000 08:01 6176771                            /lib32/                                              libnss_files-2.11.3.so
f6a1d000-f6a1e000 rw-p 0000a000 08:01 6176771                            /lib32/                                              libnss_files-2.11.3.so
f6a1e000-f6a1f000 ---p 00000000 00:00 0
f6a1f000-f721f000 rw-p 00000000 00:00 0
f721f000-f7232000 r-xp 00000000 08:01 12176489                           /usr/li                                              b32/libz.so.1.2.3.4
f7232000-f7233000 rw-p 00013000 08:01 12176489                           /usr/li                                              b32/libz.so.1.2.3.4
f7233000-f7246000 r-xp 00000000 08:01 6176807                            /lib32/                                              libnsl-2.11.3.so
f7246000-f7247000 r--p 00012000 08:01 6176807                            /lib32/                                              libnsl-2.11.3.so
f7247000-f7248000 rw-p 00013000 08:01 6176807                            /lib32/                                              libnsl-2.11.3.so
f7248000-f724a000 rw-p 00000000 00:00 0
f724a000-f7253000 r-xp 00000000 08:01 6176811                            /lib32/                                              libcrypt-2.11.3.so
f7253000-f7254000 r--p 00008000 08:01 6176811                            /lib32/                                              libcrypt-2.11.3.so
f7254000-f7255000 rw-p 00009000 08:01 6176811                            /lib32/                                              libcrypt-2.11.3.so
f7255000-f727c000 rw-p 00000000 00:00 0
f727c000-f742f000 r-xp 00000000 08:01 12173325                           /usr/li                                              b32/libmysqlclient_r.so.16.0.0
f742f000-f7433000 r--p 001b2000 08:01 12173325                           /usr/li                                              b32/libmysqlclient_r.so.16.0.0
f7433000-f7478000 rw-p 001b6000 08:01 12173325                           /usr/li                                              b32/libmysqlclient_r.so.16.0.0
f7478000-f7479000 rw-p 00000000 00:00 0
f7482000-f7499000 r-xp 00000000 08:01 4572689                            /home/d                                              elavor/samp/plugins/mysql.so
f7499000-f749a000 r--p 00017000 08:01 4572689                            /home/d                                              elavor/samp/plugins/mysql.so
f749a000-f749b000 rw-p 00018000 08:01 4572689                            /home/d                                              elavor/samp/plugins/mysql.so
f749b000-f749d000 rw-p 00000000 00:00 0
f749d000-f75dd000 r-xp 00000000 08:01 6176792                            /lib32/                                              libc-2.11.3.so
f75dd000-f75de000 ---p 00140000 08:01 6176792                            /lib32/                                              libc-2.11.3.so
f75de000-f75e0000 r--p 00140000 08:01 6176792                            /lib32/                                              libc-2.11.3.so
f75e0000-f75e1000 rw-p 00142000 08:01 6176792                            /lib32/                                              libc-2.11.3.so
f75e1000-f75e4000 rw-p 00000000 00:00 0
f75e4000-f7601000 r-xp 00000000 08:01 12176477                           /usr/li                                              b32/libgcc_s.so.1
f7601000-f7602000 rw-p 0001c000 08:01 12176477                           /usr/li                                              b32/libgcc_s.so.1
f7602000-f7626000 r-xp 00000000 08:01 6176823                            /lib32/                                              libm-2.11.3.so
f7626000-f7627000 r--p 00023000 08:01 6176823                            /lib32/                                              libm-2.11.3.so
f7627000-f7628000 rw-p 00024000 08:01 6176823                            /lib32/                                              libm-2.11.3.so
f7628000-f7711000 r-xp 00000000 08:01 11010070                           /usr/li                                              b32/libstdc++.so.6.0.13
f7711000-f7715000 r--p 000e9000 08:01 11010070                           /usr/li                                              b32/libstdc++.so.6.0.13
f7715000-f7716000 rw-p 000ed000 08:01 11010070                           /usr/li                                              b32/libstdc++.so.6.0.13
f7716000-f771e000 rw-p 00000000 00:00 0
f771e000-f7733000 r-xp 00000000 08:01 6176778                            /lib32/                                              libpthread-2.11.3.so
f7733000-f7734000 r--p 00014000 08:01 6176778                            /lib32/                                              libpthread-2.11.3.so
f7734000-f7735000 rw-p 00015000 08:01 6176778                            /lib32/                                              libpthread-2.11.3.so
f7735000-f7737000 rw-p 00000000 00:00 0
f7737000-f7739000 r-xp 00000000 08:01 6176822                            /lib32/                                              libdl-2.11.3.so
f7739000-f773a000 r--p 00001000 08:01 6176822                            /lib32/                                              libdl-2.11.3.so
f773a000-f773b000 rw-p 00002000 08:01 6176822                            /lib32/                                              libdl-2.11.3.so
f7742000-f7746000 rw-p 00000000 00:00 0
f7746000-f7747000 r-xp 00000000 00:00 0                                  [vdso]
f7747000-f7763000 r-xp 00000000 08:01 6176779                            /lib32/                                              ld-2.11.3.so
f7763000-f7764000 r--p 0001b000 08:01 6176779                            /lib32/                                              ld-2.11.3.so
f7764000-f7765000 rw-p 0001c000 08:01 6176779                            /lib32/                                              ld-2.11.3.so
ffaf8000-ffb0d000 rw-p 00000000 00:00 0                                  [stack]
Delavor is offline   Reply With Quote
Old 16/04/2012, 10:26 PM   #2337
Legö
Little Clucker
 
Join Date: Apr 2010
Posts: 25
Reputation: 1
Default AW: [REL] MySQL Plugin (R7 released)

With the MYSQL Plugin R6 at SAMP 03d RC2 the server will close the conection after connecting.

Why is it so? pls. help me!
__________________
Legö is offline   Reply With Quote
Old 18/04/2012, 03:36 PM   #2338
Tomer!.$
Big Clucker
 
Join Date: Apr 2012
Posts: 192
Reputation: 4
Default Re : [REL] MySQL Plugin (R7 released)

Am I able to use MySQL on my own server which is hosted by my own computer? Or do I need a server host?
Tomer!.$ is offline   Reply With Quote
Old 18/04/2012, 03:51 PM   #2339
Thomas.
Big Clucker
 
Join Date: Aug 2010
Location: The Netherlands
Posts: 125
Reputation: 15
Default Re: [REL] MySQL Plugin (R7 released)

Yes, you can.

Download MySQL Community Server.
Thomas. is offline   Reply With Quote
Old 18/04/2012, 05:47 PM   #2340
a guy
Little Clucker
 
Join Date: Mar 2012
Posts: 1
Reputation: 1
Default Re: [REL] MySQL Plugin (R7 released)

Hello. I usually hate asking for help, but I really can't figure this out myself and I have searched for this problem. The problem is that it loads just fine in my computer and remote server, however it doesn't load in server after gmx. Yet everything in my pc works just fine. Does anyone have had any similar problems or know solution to this. Both are windows machines. My pc runs Win 8 Consumer Preview thing and server runs 2008 R2
Thank you in advance
a guy 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
Google Project: Glass int3s0 Everything and Nothing 99 26/02/2013 05:22 PM
MySQL Plugin R5 plugin problem dud Scripting Help 12 05/12/2011 07: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 03:32 PM


All times are GMT. The time now is 07:37 PM.


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