MYSQL Password doesn't match
#1

Код:
public WhenAccountCheck(playerid, password[])
{
	new rows, fields;
	cache_get_data(rows, fields, handle);

 	if(rows)
	{
		gRegistred[playerid] = 1;
  	}
  	else
  	{
		gRegistred[playerid] = 0;
	}

  	if(pInfo[playerid][pLogged] == 0)
	{
		if(gRegistred[playerid] == 1)
		{
			if(rows)
			{
				new string[256];

				format(string,sizeof(string),"{BECBFC}Welcome, {95A3FF}%s{BECBFC}!\nPlease enter your password below to login to your account.",PlayerName(playerid));
				ShowPlayerDialog(playerid, DIALOG_LOGIN ,DIALOG_STYLE_PASSWORD,"DayZ Account Login",string,"Login","Exit");
   			}
		}
		else
     		{
			ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "DayZ Register", "DayZ Account Registration\nEnter your password below:", "Register", "Cancel");
   		}
	}

	SetPlayerCameraPos(playerid, 1500.7156,-1778.1880,80.3080);
	SetPlayerCameraLookAt(playerid, 1500.7156,-1778.1880,80.3080);
	SetPlayerPos_Allow(playerid, 1437.6957,-2266.6355,13.5469);
	return 1;
}
public OnPlayerAccountLogin(playerid, enteredPassword[])
{
    if(IsPlayerNPC(playerid)) return 1;
    {
        if(IsPlayerConnected(playerid))
        {
            new query[350];
            format(query, sizeof(query), "SELECT * FROM `users` WHERE `Username`= '%s' AND `Password` = SHA1('%s')", PlayerName(playerid), enteredPassword);
            mysql_tquery(handle, query, "WhenPlayerLogin", "i", playerid);
        }
    }
    return 1;
}
public WhenPlayerLogin(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		pInfo[playerid][pHunger] = 2500;
		pInfo[playerid][pThrist] = 1000;
		pInfo[playerid][pBlood] = 12000;
		pInfo[playerid][Humanity] = 2500;

		new rows, fields;
		new tmp[128];

		cache_get_data(rows, fields, handle);

		if(rows != 0)
		{
			cache_get_field_content(0, "Password", tmp),  format(pInfo[playerid][Password], 128, tmp);
			cache_get_field_content(0, "Headshots", tmp), pInfo[playerid][Headshots] = strval(tmp);
			cache_get_field_content(0, "Murders", tmp), pInfo[playerid][Murders] = strval(tmp);
			cache_get_field_content(0, "BanditsKilled", tmp), pInfo[playerid][BanditsKilled] = strval(tmp);
			cache_get_field_content(0, "ZombiesKilled", tmp), pInfo[playerid][ZombiesKilled] = strval(tmp);
			cache_get_field_content(0, "Backpack", tmp), pInfo[playerid][Backpack] = strval(tmp);
			cache_get_field_content(0, "BackpackSlots", tmp), pInfo[playerid][BackpackSlots] = strval(tmp);
	        	cache_get_field_content(0, "BackpackSlotsUsed", tmp), pInfo[playerid][BackpackSlotsUsed] = strval(tmp);
	        	cache_get_field_content(0, "pAdminLevel", tmp), pInfo[playerid][pAdminLevel] = strval(tmp);
	        	cache_get_field_content(0, "pPremium", tmp), pInfo[playerid][pPremium] = strval(tmp);
	        	cache_get_field_content(0, "pX", tmp), pInfo[playerid][pX] = strval(tmp);
	        	cache_get_field_content(0, "pY", tmp), pInfo[playerid][pY] = strval(tmp);
	        	cache_get_field_content(0, "pZ", tmp), pInfo[playerid][pZ] = strval(tmp);
	        	cache_get_field_content(0, "pWeap1", tmp), pInfo[playerid][pWeap1] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo1", tmp), pInfo[playerid][pAmmo1] = strval(tmp);
	        	cache_get_field_content(0, "pWeap2", tmp), pInfo[playerid][pWeap2] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo2", tmp), pInfo[playerid][pAmmo2] = strval(tmp);
	        	cache_get_field_content(0, "pWeap3", tmp), pInfo[playerid][pWeap3] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo3", tmp), pInfo[playerid][pAmmo3] = strval(tmp);
	        	cache_get_field_content(0, "pWeap4", tmp), pInfo[playerid][pWeap4] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo4", tmp), pInfo[playerid][pAmmo4] = strval(tmp);
	        	cache_get_field_content(0, "pWeap5", tmp), pInfo[playerid][pWeap5] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo5", tmp), pInfo[playerid][pAmmo5] = strval(tmp);
	        	cache_get_field_content(0, "pWeap6", tmp), pInfo[playerid][pWeap6] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo6", tmp), pInfo[playerid][pAmmo6] = strval(tmp);
	        	cache_get_field_content(0, "pWeap7", tmp), pInfo[playerid][pWeap7] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo7", tmp), pInfo[playerid][pAmmo7] = strval(tmp);
	        	cache_get_field_content(0, "pWeap8", tmp), pInfo[playerid][pWeap8] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo8", tmp), pInfo[playerid][pAmmo8] = strval(tmp);
	        	cache_get_field_content(0, "pWeap9", tmp), pInfo[playerid][pWeap9] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo9", tmp), pInfo[playerid][pAmmo9] = strval(tmp);
			cache_get_field_content(0, "pHour", tmp), pInfo[playerid][pHour] = strval(tmp);
	        	cache_get_field_content(0, "pMin", tmp), pInfo[playerid][pMin] = strval(tmp);
	       		cache_get_field_content(0, "pSec", tmp), pInfo[playerid][pSec] = strval(tmp);
			cache_get_field_content(0, "pBlood", tmp), pInfo[playerid][pBlood] = strval(tmp);
			cache_get_field_content(0, "pThrist", tmp), pInfo[playerid][pThrist] = strval(tmp);
			cache_get_field_content(0, "pHunger", tmp), pInfo[playerid][pHunger] = strval(tmp);
			cache_get_field_content(0, "Humanity", tmp), pInfo[playerid][Humanity] = strval(tmp);
			cache_get_field_content(0, "pFirstSpawn", tmp), pInfo[playerid][pFirstSpawn] = strval(tmp);
			cache_get_field_content(0, "pAliveTime", tmp), pInfo[playerid][pAliveTime] = strval(tmp);
			cache_get_field_content(0, "pIsMapOpened", tmp), pInfo[playerid][pIsMapOpened] = strval(tmp);
			cache_get_field_content(0, "pSkin", tmp), pInfo[playerid][pSkin] = strval(tmp);
			cache_get_field_content(0, "Helper", tmp), pInfo[playerid][Helper] = strval(tmp);
			cache_get_field_content(0, "IsPlayerBleeding", tmp), pInfo[playerid][IsPlayerBleeding] = strval(tmp);
			cache_get_field_content(0, "IsPlayerLegBroken", tmp), pInfo[playerid][IsPlayerLegBroken] = strval(tmp);
			cache_get_field_content(0, "pAmbientEnable", tmp), pInfo[playerid][pAmbientEnable] = strval(tmp);
			cache_get_field_content(0, "DefaultGender", tmp), pInfo[playerid][DefaultGender] = strval(tmp);
			cache_get_field_content(0, "ID", tmp), pInfo[playerid][pUserID] = strval(tmp);

		}
		else
		{
			ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "The passwords don't match!\nType your account's password below:", "Login", "Exit");
			return 1;
		}

		if(pInfo[playerid][pAmbientEnable] == 0)
		{
			pInfo[playerid][pAmbientEnable] = 1;
			SendClientMessage(playerid, -1, ""chat" The ambient has been enabled, you can change this by default in the GAME OPTIONS menu!");
		}

		printf("%s has logged in.", PlayerName(playerid));

		if(pInfo[playerid][pFirstSpawn] == 0)
		{
			pInfo[playerid][pFirstSpawn] = 1;
		}
		pInfo[playerid][pLogged] = 1;
		ClearChatPlayer(playerid);
		LoadInventory(playerid);
		SetPlayerScore(playerid,pInfo[playerid][pHour]);
		DayZSA_ShowMenuForPlayer(playerid);
	}
	return 1;
}
public OnPlayerRegister(playerid, password[])
{
	if(IsPlayerConnected(playerid))
	{
	 	new Query[450],IP[16];
		GetPlayerIp(playerid, IP, sizeof(IP));
		strcat(Query,"INSERT INTO `users` (Username,Password,IP) VALUES ('%s', sha1('%s'),'%s')");
		format(Query,sizeof(Query),Query,PlayerName(playerid),password,IP);
		mysql_tquery(handle, Query, "", "");
		printf("%s",Query);
		pInfo[playerid][pFirstSpawn] = 1;
		pInfo[playerid][pHunger] = 2500;
		pInfo[playerid][pThrist] = 1000;
		pInfo[playerid][pBlood] = 12000;
		pInfo[playerid][Humanity] = 2500;
		pInfo[playerid][Backpack] = 0;
		pInfo[playerid][BackpackSlots] = 8;
		pInfo[playerid][BackpackSlotsUsed] = 0;

		ShowPlayerDialog(playerid, DIALOG_LOGIN ,DIALOG_STYLE_PASSWORD, "Login", "Please enter your password below to login to your account.", "Login", "Exit");
	}
	return 1;
}
Is there anything wrong with this code? I registered and when on the login dialog, the password doesn't match
Reply
#2

because you not inserting player into db because of this code :

Код HTML:
strcat(Query,"INSERT INTO `users` (Username,Password,IP) VALUES ('%s', sha1('%s'),'%s')");
format(Query,sizeof(Query),Query,PlayerName(playerid),password,IP);
replace it with :

Код HTML:
format(Query, sizeof(Query), "INSERT INTO users (Username, Password, IP) VALUES ('%s', 'sha1(%s)', '%s')",
PlayerName(playerid), password, IP);
and where you check password is real? because your checking(if you gave full) will log in player if he only exits in database
Reply
#3

Tried, not working, i've edited the post
Reply
#4

Quote:
Originally Posted by MrFantasy
Посмотреть сообщение
Tried, not working, i've edited the post
show your sql+ mysql logs
Reply
#5

Quote:
Originally Posted by JustNothing
Посмотреть сообщение
show your sql+ mysql logs
What you mean?
Reply
#6

Quote:
Originally Posted by MrFantasy
Посмотреть сообщение
What you mean?
answered in pm
Reply
#7

Anyone help! doesn't fixed yet
Reply
#8

1. Change your hasher for password in MD5

2. Try this code with MD5

Код:
public WhenAccountCheck(playerid, password[])
{
	new rows, fields, string[256];
	cache_get_data(rows, fields, handle);

 	if(rows) gRegistred[playerid] = 1;
  	else gRegistred[playerid] = 0;
	
  	if(pInfo[playerid][pLogged] == 0)
	{
		if(gRegistred[playerid] == 1)
		{
			if(rows)
			{
				format(string,sizeof(string),"{BECBFC}Welcome, {95A3FF}%s{BECBFC}!\nPlease enter your password below to login to your account.",PlayerName(playerid));
				ShowPlayerDialog(playerid, DIALOG_LOGIN ,DIALOG_STYLE_PASSWORD,"DayZ Account Login",string,"Login","Exit");
   			}
		}
		else ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "DayZ Register", "DayZ Account Registration\nEnter your password below:", "Register", "Cancel");
   }

	SetPlayerCameraPos(playerid, 1500.7156,-1778.1880,80.3080);
	SetPlayerCameraLookAt(playerid, 1500.7156,-1778.1880,80.3080);
	SetPlayerPos_Allow(playerid, 1437.6957,-2266.6355,13.5469);
	return 1;
}
public OnPlayerAccountLogin(playerid, enteredPassword[])
{
    if(IsPlayerNPC(playerid)) return 1;
    {
        if(IsPlayerConnected(playerid))
        {
            new query[350];
            format(query, sizeof(query), "SELECT * FROM `users` WHERE `Username`= '%s' AND `Password` = '%s'", PlayerName(playerid), MD5_Hash(enteredPassword));
            mysql_tquery(handle, query, "WhenPlayerLogin", "i", playerid);
        }
    }
    return 1;
}
public WhenPlayerLogin(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		pInfo[playerid][pHunger] = 2500;
		pInfo[playerid][pThrist] = 1000;
		pInfo[playerid][pBlood] = 12000;
		pInfo[playerid][Humanity] = 2500;

		new rows, fields, tmp[128];

		cache_get_data(rows, fields, handle);

		if(rows != 0)
		{
			cache_get_field_content(0, "Password", tmp),  format(pInfo[playerid][Password], 128, tmp);
			cache_get_field_content(0, "Headshots", tmp), pInfo[playerid][Headshots] = strval(tmp);
			cache_get_field_content(0, "Murders", tmp), pInfo[playerid][Murders] = strval(tmp);
			cache_get_field_content(0, "BanditsKilled", tmp), pInfo[playerid][BanditsKilled] = strval(tmp);
			cache_get_field_content(0, "ZombiesKilled", tmp), pInfo[playerid][ZombiesKilled] = strval(tmp);
			cache_get_field_content(0, "Backpack", tmp), pInfo[playerid][Backpack] = strval(tmp);
			cache_get_field_content(0, "BackpackSlots", tmp), pInfo[playerid][BackpackSlots] = strval(tmp);
	        	cache_get_field_content(0, "BackpackSlotsUsed", tmp), pInfo[playerid][BackpackSlotsUsed] = strval(tmp);
	        	cache_get_field_content(0, "pAdminLevel", tmp), pInfo[playerid][pAdminLevel] = strval(tmp);
	        	cache_get_field_content(0, "pPremium", tmp), pInfo[playerid][pPremium] = strval(tmp);
	        	cache_get_field_content(0, "pX", tmp), pInfo[playerid][pX] = strval(tmp);
	        	cache_get_field_content(0, "pY", tmp), pInfo[playerid][pY] = strval(tmp);
	        	cache_get_field_content(0, "pZ", tmp), pInfo[playerid][pZ] = strval(tmp);
	        	cache_get_field_content(0, "pWeap1", tmp), pInfo[playerid][pWeap1] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo1", tmp), pInfo[playerid][pAmmo1] = strval(tmp);
	        	cache_get_field_content(0, "pWeap2", tmp), pInfo[playerid][pWeap2] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo2", tmp), pInfo[playerid][pAmmo2] = strval(tmp);
	        	cache_get_field_content(0, "pWeap3", tmp), pInfo[playerid][pWeap3] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo3", tmp), pInfo[playerid][pAmmo3] = strval(tmp);
	        	cache_get_field_content(0, "pWeap4", tmp), pInfo[playerid][pWeap4] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo4", tmp), pInfo[playerid][pAmmo4] = strval(tmp);
	        	cache_get_field_content(0, "pWeap5", tmp), pInfo[playerid][pWeap5] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo5", tmp), pInfo[playerid][pAmmo5] = strval(tmp);
	        	cache_get_field_content(0, "pWeap6", tmp), pInfo[playerid][pWeap6] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo6", tmp), pInfo[playerid][pAmmo6] = strval(tmp);
	        	cache_get_field_content(0, "pWeap7", tmp), pInfo[playerid][pWeap7] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo7", tmp), pInfo[playerid][pAmmo7] = strval(tmp);
	        	cache_get_field_content(0, "pWeap8", tmp), pInfo[playerid][pWeap8] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo8", tmp), pInfo[playerid][pAmmo8] = strval(tmp);
	        	cache_get_field_content(0, "pWeap9", tmp), pInfo[playerid][pWeap9] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo9", tmp), pInfo[playerid][pAmmo9] = strval(tmp);
			cache_get_field_content(0, "pHour", tmp), pInfo[playerid][pHour] = strval(tmp);
	        	cache_get_field_content(0, "pMin", tmp), pInfo[playerid][pMin] = strval(tmp);
	       		cache_get_field_content(0, "pSec", tmp), pInfo[playerid][pSec] = strval(tmp);
			cache_get_field_content(0, "pBlood", tmp), pInfo[playerid][pBlood] = strval(tmp);
			cache_get_field_content(0, "pThrist", tmp), pInfo[playerid][pThrist] = strval(tmp);
			cache_get_field_content(0, "pHunger", tmp), pInfo[playerid][pHunger] = strval(tmp);
			cache_get_field_content(0, "Humanity", tmp), pInfo[playerid][Humanity] = strval(tmp);
			cache_get_field_content(0, "pFirstSpawn", tmp), pInfo[playerid][pFirstSpawn] = strval(tmp);
			cache_get_field_content(0, "pAliveTime", tmp), pInfo[playerid][pAliveTime] = strval(tmp);
			cache_get_field_content(0, "pIsMapOpened", tmp), pInfo[playerid][pIsMapOpened] = strval(tmp);
			cache_get_field_content(0, "pSkin", tmp), pInfo[playerid][pSkin] = strval(tmp);
			cache_get_field_content(0, "Helper", tmp), pInfo[playerid][Helper] = strval(tmp);
			cache_get_field_content(0, "IsPlayerBleeding", tmp), pInfo[playerid][IsPlayerBleeding] = strval(tmp);
			cache_get_field_content(0, "IsPlayerLegBroken", tmp), pInfo[playerid][IsPlayerLegBroken] = strval(tmp);
			cache_get_field_content(0, "pAmbientEnable", tmp), pInfo[playerid][pAmbientEnable] = strval(tmp);
			cache_get_field_content(0, "DefaultGender", tmp), pInfo[playerid][DefaultGender] = strval(tmp);
			cache_get_field_content(0, "ID", tmp), pInfo[playerid][pUserID] = strval(tmp);

		}
		else
		{
			ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "The passwords don't match!\nType your account's password below:", "Login", "Exit");
			return 1;
		}

		if(pInfo[playerid][pAmbientEnable] == 0)
		{
			pInfo[playerid][pAmbientEnable] = 1;
			SendClientMessage(playerid, -1, ""chat" The ambient has been enabled, you can change this by default in the GAME OPTIONS menu!");
		}

		printf("%s has logged in.", PlayerName(playerid));

		if(pInfo[playerid][pFirstSpawn] == 0)
		{
			pInfo[playerid][pFirstSpawn] = 1;
		}
		pInfo[playerid][pLogged] = 1;
		ClearChatPlayer(playerid);
		LoadInventory(playerid);
		SetPlayerScore(playerid,pInfo[playerid][pHour]);
		DayZSA_ShowMenuForPlayer(playerid);
	}
	return 1;
}
public OnPlayerRegister(playerid, password[])
{
	if(IsPlayerConnected(playerid))
	{
	 	new Query[450],IP[16];
		GetPlayerIp(playerid, IP, sizeof(IP));
		mysql_format(handle, Query, 450, "INSERT INTO `users` (`Username`, Password`, `IP`) VALUES ('%s', '%s', '%s')", PlayerName(playerid), MD5_Hash(password), IP);
		mysql_tquery(handle, Query, "", "");
		printf("%s", Query);
		pInfo[playerid][pFirstSpawn] = 1;
		pInfo[playerid][pHunger] = 2500;
		pInfo[playerid][pThrist] = 1000;
		pInfo[playerid][pBlood] = 12000;
		pInfo[playerid][Humanity] = 2500;
		pInfo[playerid][Backpack] = 0;
		pInfo[playerid][BackpackSlots] = 8;
		pInfo[playerid][BackpackSlotsUsed] = 0;

		ShowPlayerDialog(playerid, DIALOG_LOGIN ,DIALOG_STYLE_PASSWORD, "Login", "Please enter your password below to login to your account.", "Login", "Exit");
	}
	return 1;
}
Reply
#9

Quote:
Originally Posted by skuller12
Посмотреть сообщение
1. Change your hasher for password in MD5

2. Try this code with MD5

Код:
public WhenAccountCheck(playerid, password[])
{
	new rows, fields, string[256];
	cache_get_data(rows, fields, handle);

 	if(rows) gRegistred[playerid] = 1;
  	else gRegistred[playerid] = 0;
	
  	if(pInfo[playerid][pLogged] == 0)
	{
		if(gRegistred[playerid] == 1)
		{
			if(rows)
			{
				format(string,sizeof(string),"{BECBFC}Welcome, {95A3FF}%s{BECBFC}!\nPlease enter your password below to login to your account.",PlayerName(playerid));
				ShowPlayerDialog(playerid, DIALOG_LOGIN ,DIALOG_STYLE_PASSWORD,"DayZ Account Login",string,"Login","Exit");
   			}
		}
		else ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "DayZ Register", "DayZ Account Registration\nEnter your password below:", "Register", "Cancel");
   }

	SetPlayerCameraPos(playerid, 1500.7156,-1778.1880,80.3080);
	SetPlayerCameraLookAt(playerid, 1500.7156,-1778.1880,80.3080);
	SetPlayerPos_Allow(playerid, 1437.6957,-2266.6355,13.5469);
	return 1;
}
public OnPlayerAccountLogin(playerid, enteredPassword[])
{
    if(IsPlayerNPC(playerid)) return 1;
    {
        if(IsPlayerConnected(playerid))
        {
            new query[350];
            format(query, sizeof(query), "SELECT * FROM `users` WHERE `Username`= '%s' AND `Password` = '%s'", PlayerName(playerid), MD5_Hash(enteredPassword));
            mysql_tquery(handle, query, "WhenPlayerLogin", "i", playerid);
        }
    }
    return 1;
}
public WhenPlayerLogin(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		pInfo[playerid][pHunger] = 2500;
		pInfo[playerid][pThrist] = 1000;
		pInfo[playerid][pBlood] = 12000;
		pInfo[playerid][Humanity] = 2500;

		new rows, fields, tmp[128];

		cache_get_data(rows, fields, handle);

		if(rows != 0)
		{
			cache_get_field_content(0, "Password", tmp),  format(pInfo[playerid][Password], 128, tmp);
			cache_get_field_content(0, "Headshots", tmp), pInfo[playerid][Headshots] = strval(tmp);
			cache_get_field_content(0, "Murders", tmp), pInfo[playerid][Murders] = strval(tmp);
			cache_get_field_content(0, "BanditsKilled", tmp), pInfo[playerid][BanditsKilled] = strval(tmp);
			cache_get_field_content(0, "ZombiesKilled", tmp), pInfo[playerid][ZombiesKilled] = strval(tmp);
			cache_get_field_content(0, "Backpack", tmp), pInfo[playerid][Backpack] = strval(tmp);
			cache_get_field_content(0, "BackpackSlots", tmp), pInfo[playerid][BackpackSlots] = strval(tmp);
	        	cache_get_field_content(0, "BackpackSlotsUsed", tmp), pInfo[playerid][BackpackSlotsUsed] = strval(tmp);
	        	cache_get_field_content(0, "pAdminLevel", tmp), pInfo[playerid][pAdminLevel] = strval(tmp);
	        	cache_get_field_content(0, "pPremium", tmp), pInfo[playerid][pPremium] = strval(tmp);
	        	cache_get_field_content(0, "pX", tmp), pInfo[playerid][pX] = strval(tmp);
	        	cache_get_field_content(0, "pY", tmp), pInfo[playerid][pY] = strval(tmp);
	        	cache_get_field_content(0, "pZ", tmp), pInfo[playerid][pZ] = strval(tmp);
	        	cache_get_field_content(0, "pWeap1", tmp), pInfo[playerid][pWeap1] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo1", tmp), pInfo[playerid][pAmmo1] = strval(tmp);
	        	cache_get_field_content(0, "pWeap2", tmp), pInfo[playerid][pWeap2] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo2", tmp), pInfo[playerid][pAmmo2] = strval(tmp);
	        	cache_get_field_content(0, "pWeap3", tmp), pInfo[playerid][pWeap3] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo3", tmp), pInfo[playerid][pAmmo3] = strval(tmp);
	        	cache_get_field_content(0, "pWeap4", tmp), pInfo[playerid][pWeap4] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo4", tmp), pInfo[playerid][pAmmo4] = strval(tmp);
	        	cache_get_field_content(0, "pWeap5", tmp), pInfo[playerid][pWeap5] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo5", tmp), pInfo[playerid][pAmmo5] = strval(tmp);
	        	cache_get_field_content(0, "pWeap6", tmp), pInfo[playerid][pWeap6] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo6", tmp), pInfo[playerid][pAmmo6] = strval(tmp);
	        	cache_get_field_content(0, "pWeap7", tmp), pInfo[playerid][pWeap7] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo7", tmp), pInfo[playerid][pAmmo7] = strval(tmp);
	        	cache_get_field_content(0, "pWeap8", tmp), pInfo[playerid][pWeap8] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo8", tmp), pInfo[playerid][pAmmo8] = strval(tmp);
	        	cache_get_field_content(0, "pWeap9", tmp), pInfo[playerid][pWeap9] = strval(tmp);
	        	cache_get_field_content(0, "pAmmo9", tmp), pInfo[playerid][pAmmo9] = strval(tmp);
			cache_get_field_content(0, "pHour", tmp), pInfo[playerid][pHour] = strval(tmp);
	        	cache_get_field_content(0, "pMin", tmp), pInfo[playerid][pMin] = strval(tmp);
	       		cache_get_field_content(0, "pSec", tmp), pInfo[playerid][pSec] = strval(tmp);
			cache_get_field_content(0, "pBlood", tmp), pInfo[playerid][pBlood] = strval(tmp);
			cache_get_field_content(0, "pThrist", tmp), pInfo[playerid][pThrist] = strval(tmp);
			cache_get_field_content(0, "pHunger", tmp), pInfo[playerid][pHunger] = strval(tmp);
			cache_get_field_content(0, "Humanity", tmp), pInfo[playerid][Humanity] = strval(tmp);
			cache_get_field_content(0, "pFirstSpawn", tmp), pInfo[playerid][pFirstSpawn] = strval(tmp);
			cache_get_field_content(0, "pAliveTime", tmp), pInfo[playerid][pAliveTime] = strval(tmp);
			cache_get_field_content(0, "pIsMapOpened", tmp), pInfo[playerid][pIsMapOpened] = strval(tmp);
			cache_get_field_content(0, "pSkin", tmp), pInfo[playerid][pSkin] = strval(tmp);
			cache_get_field_content(0, "Helper", tmp), pInfo[playerid][Helper] = strval(tmp);
			cache_get_field_content(0, "IsPlayerBleeding", tmp), pInfo[playerid][IsPlayerBleeding] = strval(tmp);
			cache_get_field_content(0, "IsPlayerLegBroken", tmp), pInfo[playerid][IsPlayerLegBroken] = strval(tmp);
			cache_get_field_content(0, "pAmbientEnable", tmp), pInfo[playerid][pAmbientEnable] = strval(tmp);
			cache_get_field_content(0, "DefaultGender", tmp), pInfo[playerid][DefaultGender] = strval(tmp);
			cache_get_field_content(0, "ID", tmp), pInfo[playerid][pUserID] = strval(tmp);

		}
		else
		{
			ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "The passwords don't match!\nType your account's password below:", "Login", "Exit");
			return 1;
		}

		if(pInfo[playerid][pAmbientEnable] == 0)
		{
			pInfo[playerid][pAmbientEnable] = 1;
			SendClientMessage(playerid, -1, ""chat" The ambient has been enabled, you can change this by default in the GAME OPTIONS menu!");
		}

		printf("%s has logged in.", PlayerName(playerid));

		if(pInfo[playerid][pFirstSpawn] == 0)
		{
			pInfo[playerid][pFirstSpawn] = 1;
		}
		pInfo[playerid][pLogged] = 1;
		ClearChatPlayer(playerid);
		LoadInventory(playerid);
		SetPlayerScore(playerid,pInfo[playerid][pHour]);
		DayZSA_ShowMenuForPlayer(playerid);
	}
	return 1;
}
public OnPlayerRegister(playerid, password[])
{
	if(IsPlayerConnected(playerid))
	{
	 	new Query[450],IP[16];
		GetPlayerIp(playerid, IP, sizeof(IP));
		mysql_format(handle, Query, 450, "INSERT INTO `users` (`Username`, Password`, `IP`) VALUES ('%s', '%s', '%s')", PlayerName(playerid), MD5_Hash(password), IP);
		mysql_tquery(handle, Query, "", "");
		printf("%s", Query);
		pInfo[playerid][pFirstSpawn] = 1;
		pInfo[playerid][pHunger] = 2500;
		pInfo[playerid][pThrist] = 1000;
		pInfo[playerid][pBlood] = 12000;
		pInfo[playerid][Humanity] = 2500;
		pInfo[playerid][Backpack] = 0;
		pInfo[playerid][BackpackSlots] = 8;
		pInfo[playerid][BackpackSlotsUsed] = 0;

		ShowPlayerDialog(playerid, DIALOG_LOGIN ,DIALOG_STYLE_PASSWORD, "Login", "Please enter your password below to login to your account.", "Login", "Exit");
	}
	return 1;
}
Код:
MD5_Hash(string[])
{
      for(new x=0; x < strlen(string); x++)
	  {
		  string[x] += (3^x) * (x % 15);
		  if(string[x] > (0xff))
		  {
			  string[x] -= 256;
		  }
	  }
	  return 1;
}
Still wrong password with your code
Reply
#10

Try this link for download include md5

https://github.com/GRGServer/SAMP/bl...cludes/MD5.inc

After download in your script in top #include <md5>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)