SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 28/05/2010, 07:37 PM   #1041
pziemczyk
Big Clucker
 
Join Date: Sep 2008
Posts: 63
Reputation: 0
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

Okey, now i have other problem. Query is good, but still nothing happens.

Code:
public OnPlayerRequestClass(playerid, classid)
{
	new query[80];
	if (IsPlayerNPC(playerid)) return SpawnPlayer(playerid);
 	TogglePlayerSpectating(playerid, 1);

	mysql_reconnect();
	mysql_real_escape_string(LoginName(playerid), LoginName(playerid));
	format(query, sizeof(query), "SELECT gid,uid FROM `mybb_players` WHERE username='%s' LIMIT 1", LoginName(playerid));
	mysql_query(query, 0, playerid);
	
	ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "...", "Login", "Change nick");
	return 1;
}
and second query in OnDialogResponse
Code:
		case 1: // Login Input
		{
			if (response)
			{
				new query[180];
				mysql_reconnect();
				mysql_real_escape_string(inputtext, inputtext);
				format(query, sizeof(query), "SELECT * FROM mybb_players WHERE uid=%d AND gid=(SELECT uid FROM mybb_users WHERE uid=%d AND password=MD5('%s')) LIMIT 1",
				PlayerData[playerid][pUID], PlayerData[playerid][pGID], inputtext);
				mysql_query(query, 1, playerid);
			}
			else
			{
				ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Zmiana nicku postaci", "Aby zmienić nick, wprowadź nowy nick do pola i zatwierdź.\nPamiętaj, że nick nie może zawierać znaków: !#^&*(){}|<>?, oraz procentu", "Zmień nick", "Anuluj");
			}
		}
And OnQueryFinish
Code:
		case 0: // Getting Global ID
		{
			if (IsPlayerConnected(extraid))
			{
				new field[11];
				mysql_store_result();

				if (mysql_retrieve_row())
				{
					mysql_fetch_field_row(field, "uid"); PlayerData[extraid][pUID] = strval(field);
					mysql_fetch_field_row(field, "gid"); PlayerData[extraid][pGID] = strval(field);
    			}
  				mysql_free_result();
			}
			else
			{
				mysql_store_result();
				mysql_free_result();
			}
			return 1;
		}
		
		case 1: // Loading Player Data
		{
			if (IsPlayerConnected(extraid))
			{
				new string[128], field[11];
				mysql_store_result();
				
				if (mysql_retrieve_row())
				{
					mysql_fetch_field_row(field, "admin"); PlayerData[extraid][pAL] = strval(field);
					mysql_fetch_field_row(field, "blocked"); PlayerData[extraid][pBlocked] = strval(field);
					mysql_fetch_field_row(field, "muted"); PlayerData[extraid][pMute] = strval(field);
					mysql_fetch_field_row(field, "aj"); PlayerData[extraid][pAJ] = strval(field);
					mysql_fetch_field_row(field, "vi"); PlayerData[extraid][pVI] = strval(field);
					mysql_fetch_field_row(field, "health"); PlayerData[extraid][pHealth] = floatstr(field);
					mysql_fetch_field_row(field, "gender"); PlayerData[extraid][pGender] = strval(field);
					mysql_fetch_field_row(field, "money"); PlayerData[extraid][pMoney] = strval(field);
					mysql_fetch_field_row(field, "bank"); PlayerData[extraid][pBank] = strval(field);
					mysql_fetch_field_row(field, "faction"); PlayerData[extraid][pFaction] = strval(field);
					mysql_fetch_field_row(field, "rfaction"); PlayerData[extraid][pFactionRank] = strval(field);
					mysql_fetch_field_row(field, "business"); PlayerData[extraid][pBusiness] = strval(field);
					mysql_fetch_field_row(field, "rbusiness"); PlayerData[extraid][pBusinessRank] = strval(field);
					mysql_fetch_field_row(field, "x"); PlayerData[extraid][pLastPos][0] = floatstr(field);
					mysql_fetch_field_row(field, "y"); PlayerData[extraid][pLastPos][1] = floatstr(field);
					mysql_fetch_field_row(field, "z"); PlayerData[extraid][pLastPos][2] = floatstr(field);
					mysql_fetch_field_row(field, "angle"); PlayerData[extraid][pLastPos][3] = floatstr(field);
					mysql_fetch_field_row(field, "vw"); PlayerData[extraid][pVW] = strval(field);
					mysql_fetch_field_row(field, "interior"); PlayerData[extraid][pInterior] = strval(field);
					mysql_fetch_field_row(field, "skin"); PlayerData[extraid][pSkin] = strval(field);
					mysql_fetch_field_row(field, "online"); PlayerData[extraid][pOnline] = strval(field);
					PlayerData[extraid][pMessages] = 1;

					format(string, sizeof(string), "Zalogowałeś się jako %s (ID %d, UID %d, GID %d). Miłej gry!", PlayerName(extraid), extraid, PlayerData[extraid][pUID], PlayerData[extraid][pGID]);
					SendClientMessage(extraid, COLOR_DARKRED, string);
				}
				mysql_free_result();
			}
			else
			{
				mysql_store_result();
				mysql_free_result();
			}
		}
pziemczyk is offline   Reply With Quote
Old 28/05/2010, 11:14 PM   #1042
Lenny_Carlson
Little Clucker
 
Join Date: Aug 2008
Posts: 13
Reputation: 0
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

I have a very strange problem that apparently is triggered when I gmx my server, please see this link and note the marked lines
Lenny_Carlson is offline   Reply With Quote
Old 29/05/2010, 10:21 AM   #1043
Toney
Huge Clucker
 
Join Date: Oct 2009
Posts: 200
Reputation: 0
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

Quote:
Originally Posted by Lenny_Carlson
I have a very strange problem that apparently is triggered when I gmx my server, please see this link and note the marked lines
I have trouble with fetch fleid.
In log:
[16:08:50] CMySQLHandler::Query(SELECT KeyPassword FROM cars where MYSQLCARID = 2) - Successfully executed.
[16:08:50] >> mysql_store_result( Connection handle: 1 )
[16:08:50] CMySQLHandler::StoreResult() - Result was stored.
[16:08:50] >> mysql_fetch_field_row( Connection handle: 1 )
[16:08:50] CMySQLHandler::FetchField(KeyPassword) - You cannot call this function now. (Reason: Fields/Rows are empty.)
In pawn code:
Code:
new GotNewPassword[256];
format(sql, sizeof(sql), "SELECT KeyPassword FROM cars where MYSQLCARID = %d", GetPlayerVehicleID(playerid));
mysql_query(sql); mysql_store_result(); new KeyPassword2[256];
mysql_fetch_field_row(GotNewPassword, "KeyPassword"); mysql_real_escape_string(KeyPassword2, GotNewPassword);
mysql_free_result();
What is wrong?

And yes, that happened only on new version plugin. I never had it before.
Toney is offline   Reply With Quote
Old 29/05/2010, 08:36 PM   #1044
pziemczyk
Big Clucker
 
Join Date: Sep 2008
Posts: 63
Reputation: 0
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

Quote:
Originally Posted by pziemczyk
Okey, now i have other problem. Query is good, but still nothing happens.

Code:
public OnPlayerRequestClass(playerid, classid)
{
	new query[80];
	if (IsPlayerNPC(playerid)) return SpawnPlayer(playerid);
 	TogglePlayerSpectating(playerid, 1);

	mysql_reconnect();
	mysql_real_escape_string(LoginName(playerid), LoginName(playerid));
	format(query, sizeof(query), "SELECT gid,uid FROM `mybb_players` WHERE username='%s' LIMIT 1", LoginName(playerid));
	mysql_query(query, 0, playerid);
	
	ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "...", "Login", "Change nick");
	return 1;
}
and second query in OnDialogResponse
Code:
		case 1: // Login Input
		{
			if (response)
			{
				new query[180];
				mysql_reconnect();
				mysql_real_escape_string(inputtext, inputtext);
				format(query, sizeof(query), "SELECT * FROM mybb_players WHERE uid=%d AND gid=(SELECT uid FROM mybb_users WHERE uid=%d AND password=MD5('%s')) LIMIT 1",
				PlayerData[playerid][pUID], PlayerData[playerid][pGID], inputtext);
				mysql_query(query, 1, playerid);
			}
			else
			{
				ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Zmiana nicku postaci", "Aby zmienić nick, wprowadź nowy nick do pola i zatwierdź.\nPamiętaj, że nick nie może zawierać znaków: !#^&*(){}|<>?, oraz procentu", "Zmień nick", "Anuluj");
			}
		}
And OnQueryFinish
Code:
		case 0: // Getting Global ID
		{
			if (IsPlayerConnected(extraid))
			{
				new field[11];
				mysql_store_result();

				if (mysql_retrieve_row())
				{
					mysql_fetch_field_row(field, "uid"); PlayerData[extraid][pUID] = strval(field);
					mysql_fetch_field_row(field, "gid"); PlayerData[extraid][pGID] = strval(field);
   			}
 				mysql_free_result();
			}
			else
			{
				mysql_store_result();
				mysql_free_result();
			}
			return 1;
		}
		
		case 1: // Loading Player Data
		{
			if (IsPlayerConnected(extraid))
			{
				new string[128], field[11];
				mysql_store_result();
				
				if (mysql_retrieve_row())
				{
					mysql_fetch_field_row(field, "admin"); PlayerData[extraid][pAL] = strval(field);
					mysql_fetch_field_row(field, "blocked"); PlayerData[extraid][pBlocked] = strval(field);
					mysql_fetch_field_row(field, "muted"); PlayerData[extraid][pMute] = strval(field);
					mysql_fetch_field_row(field, "aj"); PlayerData[extraid][pAJ] = strval(field);
					mysql_fetch_field_row(field, "vi"); PlayerData[extraid][pVI] = strval(field);
					mysql_fetch_field_row(field, "health"); PlayerData[extraid][pHealth] = floatstr(field);
					mysql_fetch_field_row(field, "gender"); PlayerData[extraid][pGender] = strval(field);
					mysql_fetch_field_row(field, "money"); PlayerData[extraid][pMoney] = strval(field);
					mysql_fetch_field_row(field, "bank"); PlayerData[extraid][pBank] = strval(field);
					mysql_fetch_field_row(field, "faction"); PlayerData[extraid][pFaction] = strval(field);
					mysql_fetch_field_row(field, "rfaction"); PlayerData[extraid][pFactionRank] = strval(field);
					mysql_fetch_field_row(field, "business"); PlayerData[extraid][pBusiness] = strval(field);
					mysql_fetch_field_row(field, "rbusiness"); PlayerData[extraid][pBusinessRank] = strval(field);
					mysql_fetch_field_row(field, "x"); PlayerData[extraid][pLastPos][0] = floatstr(field);
					mysql_fetch_field_row(field, "y"); PlayerData[extraid][pLastPos][1] = floatstr(field);
					mysql_fetch_field_row(field, "z"); PlayerData[extraid][pLastPos][2] = floatstr(field);
					mysql_fetch_field_row(field, "angle"); PlayerData[extraid][pLastPos][3] = floatstr(field);
					mysql_fetch_field_row(field, "vw"); PlayerData[extraid][pVW] = strval(field);
					mysql_fetch_field_row(field, "interior"); PlayerData[extraid][pInterior] = strval(field);
					mysql_fetch_field_row(field, "skin"); PlayerData[extraid][pSkin] = strval(field);
					mysql_fetch_field_row(field, "online"); PlayerData[extraid][pOnline] = strval(field);
					PlayerData[extraid][pMessages] = 1;

					format(string, sizeof(string), "Zalogowałeś się jako %s (ID %d, UID %d, GID %d). Miłej gry!", PlayerName(extraid), extraid, PlayerData[extraid][pUID], PlayerData[extraid][pGID]);
					SendClientMessage(extraid, COLOR_DARKRED, string);
				}
				mysql_free_result();
			}
			else
			{
				mysql_store_result();
				mysql_free_result();
			}
		}
$€ЯĢ, do you have any idea?
Already if i enter the password i have no reaction. MySQL query is good.
pziemczyk is offline   Reply With Quote
Old 29/05/2010, 08:50 PM   #1045
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,862
Reputation: 230
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

It's hard to even say anything since everything is so messed up. You don't even know how to use simple function such as mysql_real_escape_string.
Code:
mysql_real_escape_string(LoginName(playerid), LoginName(playerid));
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 29/05/2010, 09:14 PM   #1046
Toney
Huge Clucker
 
Join Date: Oct 2009
Posts: 200
Reputation: 0
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

Quote:
Originally Posted by $€ЯĢ
It's hard to even say anything since everything is so messed up. You don't even know how to use simple function such as mysql_real_escape_string.
Code:
mysql_real_escape_string(LoginName(playerid), LoginName(playerid));
Hey, what about my trouble? Plugin bug or?
Toney is offline   Reply With Quote
Old 29/05/2010, 09:26 PM   #1047
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,862
Reputation: 230
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

You need to call mysql_retrieverow/mysql_fetch_row_format before.
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 29/05/2010, 09:40 PM   #1048
Toney
Huge Clucker
 
Join Date: Oct 2009
Posts: 200
Reputation: 0
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

Well.. On R3 that's was fine. In R4 i have that problems with return result's
Can you example please.
Toney is offline   Reply With Quote
Old 29/05/2010, 09:51 PM   #1049
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,862
Reputation: 230
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

Your code makes no sense.

Code:
SELECT KeyPassword FROM cars WHERE MYSQLCARID = %d", GetPlayerVehicleID(playerid)
I'm sure that server's internal ID is not your database's vehicle ID.

Code:
new KeyPassword2[256];
mysql_fetch_field_row(GotNewPassword, "KeyPassword"); mysql_real_escape_string(KeyPassword2, GotNewPassword);
You extract password to GotNewPassword and then overwrite it with empty KeyPassword2?

Also I'm sure you don't have 256 characters long password (only if you use whirpool).
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 29/05/2010, 10:11 PM   #1050
Toney
Huge Clucker
 
Join Date: Oct 2009
Posts: 200
Reputation: 0
Default Re: [REL] MySQL Plugin R4 (21/04/2010)

$€ЯĢ don't worry about car ID'S its checked by SQL query to phpmyadmin. There in phpmyadmin i had stored result. But plugin wont return it. Yep i dont have 256 chr, i have only 64 but its not major problem,
Ah yes, mysql_fetch_field_row(KeyPassword2, "KeyPassword"); mysql_real_escape_string(KeyPassword2, GotNewPassword);
That's right. But problem still there...
Toney 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 05:13 PM.


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