[Plugin] [REL] MySQL Plugin (Now on github!)
#61

debian version?
Reply
#62

Quote:
Originally Posted by [MG
mysan ]
I have a problem . Plugin doesn't work on VPS server WINDOWS SERVER 2003. Plugin by adrenaline work but no have needed functions
Make sure you have the Microsoft Visual C++ 2008 Runtime installed (not sure if it needs SP1 or normal ones). If you can not or do not want to install those, have a look at http://mabako.org/mysql-vs2003.rar which was built on an older version of Visual Studio and which's runtime files should be installed already on your vps)

Quote:
Originally Posted by Reamis
debian version?
The linux version of this plugin was compiled on Debian Etch.
Reply
#63

mysq_load() & mysql_field_count() are awesome and usefull.
Reply
#64

Quote:
Originally Posted by mabako
Quote:
Originally Posted by [MG
mysan ]
I have a problem . Plugin doesn't work on VPS server WINDOWS SERVER 2003. Plugin by adrenaline work but no have needed functions
Make sure you have the Microsoft Visual C++ 2008 Runtime installed (not sure if it needs SP1 or normal ones). If you can not or do not want to install those, have a look at http://mabako.org/mysql-vs2003.rar which was built on an older version of Visual Studio and which's runtime files should be installed already on your vps)

Quote:
Originally Posted by Reamis
debian version?
The linux version of this plugin was compiled on Debian Etch.

Wow this realy work im download this program on official microsoft site and all work. I am very grateful to you ! too xSreamer work Yahoo
Reply
#65

How often i need to do queries that server crash ?
Reply
#66

Awsome plugin.

For those who wonders whether to convert to/use or test this, LS:RP just switched to this plugin, despite the fact that I had to re-write 1090 calls to our previous mySQL script, and that the loading systems etc. were different here, meaning lots of code had to be re-written, I'm glad I did. This code is much cleaner, easier to use and understand, you don't have to deal with raw data unless you want to and it's continuously coming new features, which it doesn't on the other/previous plugin, to say the least.

I've also noticed an overall performance increase/less CPU usage, and things works as supposed to here, no need to do lame walk-arounds to free memory and stuff like that, generally easy to understand, even Damian wanted to try out on SQL when we switched :P

And the inbuilt debug makes it so much easier to run betas/tests.
Reply
#67

This plugin is not alternative of other plugin. This is the best... Congratulations G-sTyLeZzZ
Reply
#68

[Removed]
Reply
#69

Could someone who's successfully using mysql_fetch_field_row please post a snippet? I'd greatly appreciate it.

why wouldn't this work:

pawn Код:
new pass[128];
mysql_fetch_field_row(pass, "password");
print(pass);
Reply
#70

[Removed]
Reply
#71

CyberGuerilla:

http://pastebin.com/f34ee9e27
Reply
#72

deleted post

[code=pawn]deleted[/code]
Reply
#73

Quote:
Originally Posted by Sneaky.
Thank you very much Sneaky
Reply
#74

Quote:
Originally Posted by krisk
And the inbuilt debug makes it so much easier to run betas/tests.
Could you get the debug to show your "mysql_fetch_row" correctly? Most of mine ended up saying something like this.
pawn Код:
[08:19:39] mysql_fetch_row(МъЈ
ПъЈ
ЧъЈ
ЯъЈ
// and so on
Reply
#75

[Removed]
Reply
#76

Quote:
Originally Posted by ǝɹoɯ‾ʎ
Quote:
Originally Posted by krisk
And the inbuilt debug makes it so much easier to run betas/tests.
Could you get the debug to show your "mysql_fetch_row" correctly? Most of mine ended up saying something like this.
pawn Код:
[08:19:39] mysql_fetch_row(МъЈ
ПъЈ
ЧъЈ
ЯъЈ
// and so on
Well, I'm currently working on a new final version which works faster and decreases your CPU usage at the same time. It's currently running on LS-RP and appearantly works fine.

I still need to run some tests till it's completely ready. Also some people reported that the debug function sometimes crashes the server and gives you some weird characters like you posted, but this bug is now finally fixed. Almost all functions are completely re-written and should avoid server-crash's. I should also mention that there aren't any (cell) limits for mysql_fetch_row/_format in the coming version. I've included a new callback and a new function, which were suggested by krisk and Gehaktbal.

I hope I'm able to release the new plugin as soon as possible.
Reply
#77

Quote:

I've also noticed an overall performance increase/less CPU usage, and things works as supposed to here, no need to do lame walk-arounds to free memory and stuff like that, generally easy to understand, even Damian wanted to try out on SQL when we switched

Yep that's right, so easy even I get it.
Reply
#78

All GF Edits: For switch your GM's old Mysql plugin to this plugin, watch.

I working about this, for 4 days. I solved this problem.

Step 1: Find samp_mysql_ in your script. Change this to mysql_
Step 2: Change a_sampmysql to a_mysql
Step 3: Add G_Stylezz plugin to your plugins folder.
Step 4: Edit your server.cfg (add: plugins mysql)
Step 5: Find OnPlayerLogin in your script.
Step 6: Find MySQLCheckConnection change to MYSQLBaglantiKontrol

Change function to:

Код:
public OnPlayerLogin(playerid,password[])
{
	MYSQLBaglantiKontrol();
	new tmp2[256];
  new string2[64];
	new Isim[MAX_PLAYER_NAME];
  GetPlayerName(playerid, Isim, sizeof(Isim));
  new query[MAX_STRING];
  new query2[MAX_STRING];
  
	format(query,sizeof(query),"SELECT * FROM `oyuncular` WHERE Name = '%s' AND Password = '%s'",Isim,password);
	mysql_query(query);
	mysql_store_result();
	if(mysql_num_rows() == 1)
	{
   mysql_free_result();
   MYSQLOyuncuGiris(playerid, PlayerInfo[playerid][pSQLID]);
	}
	else
	{
    mysql_free_result();
		SendClientMessage(playerid, COLOR_WHITE, "SUNUCU: Sifrenizi yanlis girdiniz.");
		gPlayerLogTries[playerid] += 1;
		if(gPlayerLogTries[playerid] == 4) { Ban(playerid); }
		return 1;
	}
		PlayerInfo[playerid][pAdjustable] = 0;
		NormalParaSil(playerid);
		ConsumingMoney[playerid] = 1;
		NormalParaVer(playerid,PlayerInfo[playerid][pCash]);
		CurrentMoney[playerid] = PlayerInfo[playerid][pCash];
		if(PlayerInfo[playerid][pReg] == 0)
		{
  	new tckimlik = 10000000000 + random(24000000000);
	  format(query2, sizeof(query2), "SELECT * FROM oyuncular WHERE LOWER(TC) = LOWER('%s')", tckimlik);
	  mysql_query(query2);
  	mysql_store_result();
	  if(mysql_num_rows() == 0)
	  {
  	PlayerInfo[playerid][pTC] = tckimlik;
  	PlayerInfo[playerid][pReg] = 1;
  	}
  	mysql_free_result();
		}
		if(PlayerInfo[playerid][pHesapKilit] == 1)
		{
			Ban(playerid);
		}
   	if (PlayerInfo[playerid][pHikayeKabul] == 0)
  	{
	  	SendClientMessage(playerid, COLOR_LIGHTRED, "..:BILGI: Hikayeniz henuz kontrol edilmemis.");
	  	SendClientMessage(playerid, COLOR_LIGHTRED, "..:BILGI: Hikayeniz kontrol edilince size E-Posta ile bildirilecektir.");
	  	Kick(playerid);
  	}
		if(PlayerInfo[playerid][pKO] == 1)
		{
 		  format(string2, sizeof(string2), "..:BILGI: Hayatinizi kaybettiniz. Yeni bir hesap aliniz.");
			SendClientMessage(playerid, COLOR_WHITE, string2);
		  Kick(playerid);
		}
		if(PlayerInfo[playerid][pVaaz] > 0)
		{
      SendClientMessage(playerid, COLOR_WHITE,"..:BILGI: Vaaziniz sonra erdi.");
		  VaazBitir(playerid);
		  PlayerInfo[playerid][pVaaz] = 0;
		}
		if (PlayerInfo[playerid][pDonateRank] > 0)
		{
			SendClientMessage(playerid, COLOR_WHITE,"..:BILGI: Siz ust seviye bir kullanicisiniz.");
		}
 		new isim[MAX_PLAYER_NAME], soyisim[MAX_PLAYER_NAME];
 	  RPName(PlayerName(playerid),isim,soyisim)
		format(string2, sizeof(string2), "..:BILGI: Sayin %s, hosgeldiniz.",soyisim);
		SendClientMessage(playerid, COLOR_WHITE,string2);
		printf("%s giris yapti.",Isim);
 		new nxtlevel = PlayerInfo[playerid][pLevel]+1;
		new expamount = nxtlevel*levelexp;
		PlayerInfo[playerid][pSeviyeTavan] = expamount;
		SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pModel], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
		gPlayerLogged[playerid] = 1;
		SpawnPlayer(playerid);
		format(tmp2, sizeof(tmp2), "~w~Hosgeldiniz ~n~~y~  %s", Isim);
		DateProp(playerid);
		GameTextForPlayer(playerid, tmp2, 5000, 1);
		SendClientMessage(playerid, COLOR_YELLOW, motd);
 		for(new i = 0; i < MAX_PLAYERS; i++)
		{
	  	if(IsPlayerConnected(i))
	  	{
	    	if(PlayerInfo[i][pMaskeKullanim] == 1)
	    	{
	      	ShowPlayerNameTagForPlayer(playerid, i, 0);
	    	}
	  	}
		}
		PlayerInfo[playerid][pMuted] = 0;
		OnPlayerUpdate(playerid);
	return 1;
}
NOT: Adapt this new function to your script

Add:

http://cyberguerilla.pastebin.com/f7f0a01da

NOT: Adapt this new function to your script too!

Sorry for my English
Reply
#79

Sorry for double posting, but It's not enough

We must change OnPlayerUpdate function for fix memory allocation problem.

Change old function to:

http://cyberguerilla.pastebin.com/f62f2f968

NOT: Adapt this new function to your script too!
Reply
#80

Quote:
Originally Posted by G-sTyLeZzZ
Код:
Update as of 06/28/09:
- It's important that you recompile your script with the newest include file before using the plugin
- Fixed various reported bugs such as mysql_debug
- Improved almost all functions to decrease CPU usage
- Added a alternative second parameter to 'mysql_query()' in combination with a new callback named 'OnQueryFinish()' to check whether a query is finished or not (suggested,tested and used by krisk)
- Added 'mysql_insert_id()' (suggested by Gehaktbal)
The alternative second parameter, making the queries return it's whatever result in OnQueryFinish() makes this a threaded mysql plugin. Then, if your DB is lagging, a big query, lots of shit being returned etc. you don't have to freeze the main thread so everybody lags, you simply just execute the query in a separate thread and call pawn with the result when it's done, this decreased any lag issue on LS:RP a lot, considering we have lots of shit running on SQL and relying on SQL, when I moved over lots to use another thread than the main thread instead, the lag was gone.

Here's an example of usage:

OBS: This explanation, and really the whole threaded feature, is for advanced users and users who understands pawn well, this is not a dummy guide, more a technical note with code snippets to show what I mean.

I have a global variable named "G_THREAD_LOGON_ID" to store the ID of the player awaiting result from OnQueryFinish, this is set here: (And ofcourse reset on player disconnect/connect.)

I also have a constant (define) named "D_THREAD_USERLOGON", that's just to make the code easier to understand, instead of just having the number "1" there or whatever you choose to identify which query you're using in the thread.

(Note: This script have been running on LS:RP for awhile and I've never yet seen the "Thread is busy by %i", it's just a precaution.)

(The snippet below is obviously a part of the /login command.)
pawn Код:
if(G_THREAD_LOGON_ID == -1)
{
    G_THREAD_LOGON_ID = playerid;
    mysql_query(query, D_THREAD_USERLOGON);
    return 1;
}
else
{
  new szRes[64];
  format(szRes, sizeof(szRes), "Thread is busy by %i", G_THREAD_LOGON_ID);
  return SendClientMessage(playerid, COLOR_YELLOW, szRes);
}
This is the OnQueryFinish() callback, that's the thing receiving the data/result from the plugin thread when it's been processed by SQL.
pawn Код:
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
     printf("Query with result id %d has finished! (Connection ID %d | Query: %s)",resultid,connectionHandle,query);
    switch(resultid)
    {
        case D_THREAD_USERLOGON:
        {
          USERSYS_Receive_Thread(query);
        }
        default:
        {
        }
    }
    return 1;
}
After this I can within the function USERSYS_Receive_Thread(query) process the logon as usual, as I'd have done with any script, just that the "playerid" is in the G_THREAD_LOGON_ID variable, easy as that!

And to understand the logic, in USERSYS_Receive_Thread(query), imagine that's just after you've done the mysql_query() call, so just go ahead and mysql_store_result() and validate it further for your own needs, based on your system.

OBS: This explanation, and really the whole threaded feature, is for advanced users and users who understands pawn well, this is not a dummy guide, more a technical note with code snippets to show what I mean.
Reply


Forum Jump:


Users browsing this thread: 11 Guest(s)