SA-MP Forums Archive
mysql login problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: mysql login problem (/showthread.php?tid=204804)



mysql login problem - aircombat - 30.12.2010

it just crashes when i /login [any password] but if i entered right one it says "Welcome user....." and then crash and if wrong on‌e = crash without anything , here is the code :

Код:
dcmd_login(playerid, params[])
{
	new password;
	if(GetPVarInt(playerid,"LoggedIn")) return SendClientMessage(playerid,COLOR_TEST,"You're Already Logged In");
	if(sscanf(params,"s",password)) return SendClientMessage(playerid,COLOR_TEST,"Usage: /login [Password]");
    new pName[MAX_PLAYER_NAME],Query[128];
	GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    new Escpname[24];
    GetPlayerName(playerid, pName, 24);
    mysql_real_escape_string(pName, Escpname);
	format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s'", Escpname, password);
	mysql_query(Query);
	mysql_store_result();
	if(mysql_num_rows() < 1) return SendClientMessage(playerid,COLOR_TEST,"Incorrect Password!");
	else
	{
	        new playerdata[150], string[128];
 			format(string,128,"Welcome Back %s , You're Now Logged In",pName);
			SendClientMessage(playerid,COLOR_TEST,string);
			SetPVarInt(playerid,"LoggedIn",1);
			mysql_fetch_field("money", playerdata);
			ResetPlayerMoney(playerid); 
			GivePlayerMoney(playerid,strval(playerdata));
			mysql_fetch_field("score",playerdata); 
			SetPlayerScore(playerid, strval(playerdata));
			mysql_fetch_field("kills",playerdata);
			SetPVarInt(playerid,"Kills",strval(playerdata));
			mysql_fetch_field("deaths",playerdata);
			SetPVarInt(playerid,"Deaths",strval(playerdata));
			mysql_fetch_field("warns",playerdata);
			SetPVarInt(playerid,"Warns",strval(playerdata));
	}
	return 1;
}



Re: mysql login problem - aircombat - 30.12.2010

Bump , anyone :S?