player getting diff stats
#1

my problem is when a player connects to my server and spawns, he spawns with the stats of another player in the server (the loc, the skin, the admin level etc.)

Code:
SavePlayer(playerid)//there is a timer which calls this func.
{
	if(!PlayerLogged[playerid])
	return 0;
	
	if(GetPlayerState(playerid) == PLAYER_STATE_WASTED)
	return 0;
	
   	Money[playerid] = GetPlayerMoney(playerid);
   	skin[playerid] = GetPlayerSkin(playerid);
   	GetPlayerPos(playerid, X[playerid],Y[playerid],Z[playerid]);
   	GetPlayerFacingAngle(playerid, Ang[playerid]);

	CheckMySQL();

   	new string[516];
  	format(string, sizeof(string), "UPDATE Users SET Money=%d, skin=%d, X=%f, Y=%f, Z=%f, Angle=%f, dlic=%d, pin=%d, cc=%d, admin=%d WHERE Name='%s'", Money[playerid], skin[playerid],X[playerid],Y[playerid],Z[playerid],Ang[playerid],dlic[playerid],pin[playerid], cc[playerid], admin[playerid], Name[playerid]);
   	mysql_query(string);
   	
   	new Float:x,Float:y,Float:z,Float:r;
   	GetVehiclePos(vid, x, y, z);
   	GetVehicleZAngle(vid, r);
   	format(string, sizeof(string), "UPDATE vehs SET Model=%d, X=%f, Y=%f, Z=%f, Rotation=%f WHERE Name='%s'", tmdl[playerid], x, y, z, r, Name[playerid]);
   	mysql_query(string);
   	return 1;
}


LoginPlayer(playerid, password[])
{
	GetPlayerName(playerid, Name, sizeof(Name));
	if(!AccountExists[playerid])//the account is checked when player is connected
		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 row[128];
	new field[13][32];
	
	mysql_fetch_row_format(row, "|");
	explode(row, field, "|");
	mysql_free_result();

	format(password, 32, "%s", field[2]);
 	Money[playerid] = strval(field[3]);
 	skin[playerid] = strval(field[4]);
 	X[playerid] = strval(field[5]);
	Y[playerid] = strval(field[6]);
	Z[playerid] = strval(field[7]);
	Ang[playerid] = strval(field[8]);
	dlic[playerid] = strval(field[9]);
	pin[playerid] = strval(field[10]);
	cc[playerid] = strval(field[11]);
	admin[playerid] = strval(field[12]);

 	GivePlayerMoney(playerid, Money[playerid]);
 	
 	
 	
	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;
}
EDIT: i have about 12 fields in it. will it mess it up?
Reply
#2

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)