SA-MP Forums Archive
SQlite - 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: SQlite (/showthread.php?tid=648167)



SQlite - MyUndiesSmell - 16.01.2018

The SQlite saving system I'm using saves everything when onplayerdisconnect is called but doesn't save while in-game. Therefore, when a player changes his skin and is spawned or dies again. It will give him his skin back he had from when the database last saved him. Anyway around this?


Re: SQlite - MyUndiesSmell - 16.01.2018

Код:
OnPlayerDisconnect
if (GetPVarInt(playerid, "LoggedIn"))
	{
		new string[1024],
		name[MAX_PLAYER_NAME];
		GetPlayerName(playerid, name, MAX_PLAYER_NAME);
		format(string, sizeof(string), "UPDATE `users` SET `name` = '%s', `password` = '%q', `salt` = '%q', `sec_question` = '%q', `sec_answer` = '%q', `kills` = %i, `deaths` = %i, `skin` = %i, `money` = %i, `adminlevel` = %i, `viplevel` = %i WHERE `id` = %i",
		name, eUser[playerid][e_USER_PASSWORD], eUser[playerid][e_USER_SALT], eUser[playerid][e_USER_SECURITY_QUESTION], eUser[playerid][e_USER_SECURITY_ANSWER],  eUser[playerid][e_USER_KILLS], eUser[playerid][e_USER_DEATHS], GetPlayerSkin(playerid), GetPlayerMoney(playerid), eUser[playerid][e_USER_ADMIN_LEVEL], eUser[playerid][e_USER_VIP_LEVEL], eUser[playerid][e_USER_SQLID]);
		db_query(db, string);
	}



Re: SQlite - Mikro - 16.01.2018

A general good practise is to save the skin already in the database when the user changes it. You would for example make your own stock function which does both the sqlite query saving and SetPlayerSkin.