SA-MP Forums Archive
Score Saving? (MySQL sscanf) - 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)
+--- Thread: Score Saving? (MySQL sscanf) (/showthread.php?tid=523947)



Score Saving? (MySQL sscanf) - [MM]18240[FMB] - 04.07.2014

Код:
stock LoadPlayerInfo(iPlayer)
{
	new
		Query[700];

	if(mysql_fetch_row(Query))
	{
		sscanf(Query, "e<p<|>s[24]s[35]ddddfffd>", PVar[iPlayer]); // Remember to update this if you add more info...
		mysql_free_result();
	}
	return 1;
}

stock SavePInfo(playerid)
{
	if(GetPVarInt(playerid, "LoggedIN") == 1)
	{
		new
			Query[600];

		format(Query, sizeof(Query), "UPDATE `playerinfo` SET `kills` = %d, `deaths` = %d, `money` = %d, `Level` = %d, `Last Pos X` = %f, `Last Pos Y` = %f, `Last Pos Z` = %f, `Interior` = %d WHERE `user` = '%s'", // Also remember to update this...

		PVar[playerid][pKills],
		PVar[playerid][pDeaths],
		GetPlayerMoney(playerid),
		PVar[playerid][pLevel],
		PVar[playerid][pLastX],
		PVar[playerid][pLastY],
		PVar[playerid][pLastZ],
		GetPlayerInterior(playerid),
		pName(playerid));

		mysql_query(Query);
		mysql_free_result();
		return 1;
	}
	else return 0;
}
How can I make this so it saves and loads score too?


Re: Score Saving? (MySQL sscanf) - danish007 - 04.07.2014

Make Sure You've a Column of PlayerScore in Your SQL File. otherwise it will not be saved

PHP код:
format(Querysizeof(Query), "UPDATE `playerinfo` SET `PlayerScore` = %d WHERE `user` = '%s'",You Enum Of Player Datawhich Saves Player Score



Re: Score Saving? (MySQL sscanf) - [MM]18240[FMB] - 04.07.2014

I want the SAMP script to save and load the score. I already have the column in my MySQL Table.


Re: Score Saving? (MySQL sscanf) - danish007 - 04.07.2014

PHP код:
format(Querysizeof(Query), "UPDATE `playerinfo` SET `PlayerScore` = %d WHERE `user` = '%s'",You Enum Of Player Datawhich Saves Player Score
use this it works for me!


Re: Score Saving? (MySQL sscanf) - [MM]18240[FMB] - 04.07.2014

But I already have a query, how do I make this save and load the score using the one I have posted.


Re: Score Saving? (MySQL sscanf) - BleverCastard - 04.07.2014

By adding it into the query.
Then set the score when they connect(GivePlayerScore(playerid, PlayerInfo[playerid][Score]);


Re: Score Saving? (MySQL sscanf) - [MM]18240[FMB] - 05.07.2014

Thanks for trying, ended up fixing it myself through trial and error.