Meta Data Saving

Greetings fellow lua coders!

Im making a new inventory for my long out of date darkRp/Modified Darkrp server and yes this darkrp doesn’t have any Scriptfodder shit in it so yay!

Now down to the issue, my old inventory was coded by a guy named “Chewgum” back when glon was the way to do it and now that glon is gone i cant figure a way to save it

any idea?

Sincerely

  • DiscoKnight

MySQL, text files, JSON, PData, etc - you have quite a few options available

Didnt think about JSON, im trying it now…

ill keep you updated :slight_smile:

Sincerely

-DiscoKnight

Don’t use it with SQL, if that’s something you had in mind.

Didnt plan on it :slight_smile:



hook.Add("PlayerInitialSpawn","i_Load", function( ply )
	ply.i_Inventory = {};

	if(file.Exists("sInventory/" .. ply:UniqueID() .. ".txt", "DATA")) then
		local Data = util.JSONToTable(file.Read( "sInventory/" .. ply:UniqueID() .. ".txt", "DATA" ));

		ply.i_Inventory = Data;

		timer.Simple(3, function() -- For those players who have a slow spawn it sends to them with a delay :)
			plt:ChatPrint("[sInventory] - Sending inventory to player: "..ply:Nick());

			for k, v in pairs( ply.i_Inventory ) do
				umsg.Start("i_saveditems", ply);
					umsg.String(k);
					umsg.Long(v);
				umsg.End();
			end;

			ply:ChatPrint("[sInventory] - Inventory has finished sending saved data!");
		end, ply );
	else
		ply:SaveInventory();
	end;
end);


-snip-