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

Quote:
Originally Posted by $ЂЯĢ
Get user ID first (OnPlayerRequestClass or something) and save it in PVar. If you get 0, it means that username hasn't been registered yet.
Код:
SELECT uid FROM mybb_players WHERE username='%s' LIMIT 1
This is the best solution to find out if password is right. If you get any result it means password is right and if you don't, password is wrong.
Код:
SELECT * FROM mybb_players WHERE uid=(SELECT uid FROM mybb_users WHERE uid=%d AND password=MD5('%s')) LIMIT 1
What's wrong, second query doesnt work, not loading data :/
Reply

And what does log say?
Reply

Код:
[23:26:12] CMySQLHandler::Ping() - Connection is still alive.
[23:26:12] >> mysql_real_escape_string( Connection handle: 1 )
[23:26:12] CMySQLHandler::EscapeString(William_Stevenson); - Escaped 17 characters to William_Stevenson.
[23:26:12] >> mysql_query( Connection handle: 1 )
[23:26:12] CMySQLHandler::Query(SELECT gid FROM `mybb_players` WHERE username='William_Stevenson' LIMIT 1,resultID) - Threaded query with id 0 started. (Extra ID: 0)
[23:26:12] CMySQLHandler::Ping() - Connection is still alive.
[23:26:12] CMySQLHandler::ProcessQueryThread(SELECT gid FROM `mybb_players` WHERE username='William_Stevenson' LIMIT 1, Resultid: 0) - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)
[23:26:12] OnQueryFinish("SELECT gid FROM `mybb_players` WHERE username='William_Stevenson' LIMIT 1",0) - Called.
[23:26:12] >> mysql_store_result( Connection handle: 1 )
[23:26:12] CMySQLHandler::StoreResult() - Result was stored.
[23:26:12] >> mysql_retrieve_row( Connection handle: 1 )
[23:26:12] >> mysql_fetch_field_row( Connection handle: 1 )
[23:26:12] CMySQLHandler::FetchField("gid") - 1
[23:26:12] >> mysql_free_result( Connection handle: 1 )
[23:26:12] CMySQLHandler::FreeResult() - Result was successfully free'd.
[23:26:16] >> mysql_reconnect( Connection handle: 1 )
[23:26:16] CMySQLHandler::Ping() - Connection is still alive.
[23:26:16] >> mysql_real_escape_string( Connection handle: 1 )
[23:26:16] CMySQLHandler::EscapeString(12345678); - Escaped 8 characters to 12345678.
[23:26:16] >> mysql_query( Connection handle: 1 )
[23:26:16] CMySQLHandler::Query(SELECT * FROM `mybb_players` WHERE gid = (SELECT uid FROM `mybb_users` WHERE uid='1' AND password=MD5('12345678')) LIMIT 1,resultID) - Threaded query with id 1 started. (Extra ID: 0)
[23:26:16] CMySQLHandler::Ping() - Connection is still alive.
[23:26:16] CMySQLHandler::ProcessQueryThread(SELECT * FROM `mybb_players` WHERE gid = (SELECT uid FROM `mybb_users` WHERE uid='1' AND password=MD5('12345678')) LIMIT 1, Resultid: 1) - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)
[23:26:16] OnQueryFinish("SELECT * FROM `mybb_players` WHERE gid = (SELECT uid FROM `mybb_users` WHERE uid='1' AND password=MD5('12345678')) LIMIT 1",1) - Called.
[23:26:16] >> mysql_store_result( Connection handle: 1 )
[23:26:16] CMySQLHandler::StoreResult() - Result was stored.
[23:26:16] >> mysql_retrieve_row( Connection handle: 1 )
[23:26:16] >> mysql_free_result( Connection handle: 1 )
[23:26:16] CMySQLHandler::FreeResult() - Result was successfully free'd.
gid is global id from mybb_users
Reply

Quote:
Originally Posted by pziemczyk
gid is global id from mybb_users
And a few hours ago there was no gid field?

Stop fooling around seriously. If you can't describe connection between tables mybb_users and mybb_players in details then at least post screenshot of database structure. You are not the first one doing something like that, but it seems only you have problems with that, so stop being so modest with information as it was some top secret project or you won't get any help.
Reply

i have two tables to login (mybb_users and mybb_players)
in mybb_userss i have global accounts (forums)
in mybb_players i have all player accounts (without password, but i want have global password from mybb_users).

the most important fields in mybb_users (without the special mybb field)
- uid (auto_increment) - its unique id of global account
- username
- password

the most important fields in mybb_players (without the money and other not important)
- uid (auto_increment) - it's unique id of player account
- gid - it's global account id
- username
Reply

This plugin don't accept hosts like:

fdb2.awardspace.com
mysql4.000webhost.com

?

Sorry for the bad english!
Reply

Код:
SELECT gid,uid FROM mybb_players WHERE username='%s' LIMIT 1
Код:
SELECT * FROM mybb_players WHERE uid=%d AND gid=(SELECT uid FROM mybb_users WHERE uid=%d AND password=MD5('%s')) LIMIT 1
And start naming fields with some sense like user_id, player_id, etc.

mysql_users
user_id

mysql_players
player_id
user_id
Reply

mybb_users is not dependent from me, its mybb forums script.
Reply

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

Код:
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
Код:
		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
Код:
		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();
			}
		}
Reply

I have a very strange problem that apparently is triggered when I gmx my server, please see this link and note the marked lines
Reply

I have never had any problems with time functions in MySQL. Does it get wrong time only via SA:MP server (using this plugin) or also when running query via console/phpmyadmin/etc?
Reply

Are samp server and mysql server hosted on the same pc ?

Have you started/configured the mysql server with a different timezone ? http://dev.mysql.com/doc/refman/5.1/...e-support.html
Reply

Quote:
Originally Posted by Slice
try changing
Код:
stock salt_password( const password[ 32 ], const salt[ 16 ] )
{
	new hash[ sizeof( password ) + sizeof( salt ) ]
to
Код:
stock salt_password( const password[ ], const salt[ ] )
{
	new hash[ 33 ]
same problem
Reply

libmysqlclient.so.15 link is not working, can someone upload?
Reply

Quote:
Originally Posted by Calgon
Quote:
Originally Posted by pziemczyk
So, it's double md5?

//edit:
problem with line
Код:
strcat(hash, MD5_Hash(salt), sizeof(hash));
Код:
error 035: argument type mismatch (argument 1)
https://sampwiki.blast.hk/wiki/Strcat
But what's wrong, you give me link but i don't know what's wrong.
Reply

anybody have example on how to use this?
Reply

If I try to check the success of a query operation, I get an invalid error number.

Look, in my script I have this:

Код:
mysql_query(query);
	printf("ERROR: %d",mysql_errno());
The query finish OK:

Код:
[00:07:54] CMySQLHandler::Query(SELECT id FROM usuarios WHERE username='Astaroth') - Successfully executed.

[00:07:54] >> mysql_errno( Connection handle: 1 )
But in the server console I get:

Код:
ERROR: 11862392
Instead of "ZERO" value (for suceeded querys)

What happens?.

P.S: Sorry for my poor english.

Thanks
Reply

Quote:
Originally Posted by [SP
LilGunna © ]
anybody have example on how to use this?
There's a example in the first page of this thread:

http://files.g-stylezzz.com/mysql/re...ser_script.pwn
Reply

Hey i just downloaded this plugin and wants to use it.
But, when i run my server, I get these errors:
First i get this. When i press okay

NOTE: Sorry its danish, it says "This program could not start because it couldnt find libmySQL.dll. Problem could maybe be solved by reinstalling

I get this?


I have this in my server.cfg

Код:
echo Executing Server Config...
lanmode 0
rcon_password res
maxplayers 50
port 7777
hostname SA-MP 0.3 Server
gamemode0 MysqlScript 1
filterscripts
plugins mysql.dll
announce 0
query 1
weburl www.sa-mp.com
maxnpc 0
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
I just downloaded the server.
If i change the plugins to
Код:
plugins mysql.dll libmySQL.dll
Theres no changes.

Please help me, i couldn't find anything that solved my problem when i searched.
Reply

do you have file 'libmysql.dll' in plugins folder? Don't add it to server.cfg tho'.
Reply


Forum Jump:


Users browsing this thread: 19 Guest(s)