SA-MP Forums Archive
is there a mistake in this? - 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: is there a mistake in this? (/showthread.php?tid=219820)



is there a mistake in this? - THE_KNOWN - 02.02.2011

Код:
LoginPlayer(playerid, password[])
{
	GetPlayerName(playerid, Name, sizeof(Name));
	if(!AccountExists[playerid])
		return SendClientMessage(playerid, COLOR_RED, "You're not registered!");

	if(PlayerLogged[playerid])
	    	return SendClientMessage(playerid, COLOR_RED, "You're already logged in!");

 	if(strlen(password) < 3 || strlen(password) >= 32)
	    	return SendClientMessage(playerid, COLOR_RED, "Your password is too short or too long!");

	CheckMySQL();

   	new string[128];
	format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s' AND Password = '%s'", Name, password);
	mysql_query(string);
	mysql_store_result();

	if(!mysql_num_rows())
		return SendClientMessage(playerid, COLOR_RED, "Incorrect password.");
		
	new query[512];
	GetPlayerName(playerid, Name, sizeof(Name));
	format(query, sizeof(query), "SELECT * FROM stats WHERE Name='%s'", Name);
	mysql_query(query);
	mysql_store_result();

	new row[128];
	new field[13][32];
	
	mysql_fetch_row_format(row, "|");
	explode(row, field, "|");
	mysql_free_result();

 	Money[playerid] = strval(field[1]);
 	skin[playerid] = strval(field[2]);
 	X[playerid] = strval(field[3]);
	Y[playerid] = strval(field[4]);
	Z[playerid] = strval(field[5]);
	Ang[playerid] = strval(field[6]);
	dlic[playerid] = strval(field[7]);
	pin[playerid] = strval(field[8]);
	cc[playerid] = strval(field[9]);
	admin[playerid] = strval(field[10]);

 	GivePlayerMoney(playerid, Money[playerid]);
 	
	format(query, sizeof(query), "SELECT * FROM orgs WHERE NAME='%s'",Name);
	mysql_query(query);
	mysql_store_result();
	mysql_fetch_row_format(row, "|");
	explode(row, field, "|");
	mysql_free_result();
	
	IsLaw[playerid] = strval(field[8]);
 	
	format(string, sizeof(string), "{A9C4E4}Thank you, you have logged in and your stats have been restored.", Name);
   	SendClientMessage(playerid, 0x6666FFFF, string);
   	PlayerLogged[playerid] = 1;
   	LoadVeh(playerid);
   	return 1;
}
is there any mistake in this? no compilation errors or warnings but still i feel something might be wrong.


Re: is there a mistake in this? - Steven Paul - 02.02.2011

why do you feel that something might be wrong?


Re: is there a mistake in this? - THE_KNOWN - 02.02.2011

hmm.. coz it loads the stats of another player on the server (not from the sql db simply ig). but it loads some other guys stats if he is the only one playing


Re: is there a mistake in this? - THE_KNOWN - 02.02.2011

am i supposed to free result after assigning variables their valus from fields or just free and then assign?