-- connection functs idk
local meta = FindMetaTable( "Player" );

tmysql.initialize( "127.0.0.1", "root", "", "test", 3306, 6, 5 )

function callbackfunc( result, status, error )

end

tmysql.query( "CREATE TABLE IF NOT EXISTS STALKERChars ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, SteamID TEXT, RPName TEXT, Model TEXT, Rubles INTEGER, Age INTEGER, Title TEXT, STATAim INTEGER, STATStrength INTEGER, STATSpeed INTEGER, STATEndurance INTEGER, SecondTitle TEXT, containers TEXT, Items TEXT, PlayerFlags TEXT );" )
tmysql.query( "CREATE TABLE IF NOT EXISTS STALKERUsers ( userid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, SteamID TEXT, UserName TEXT, HasToolTrust TEXT, CanDupe TEXT, FactionFlags TEXT );" )

-- IS THIS EVEN RIGHT
function meta:HandlePlayerInformation()

	local query = "SELECT * FROM `STALKERUsers` WHERE `SteamID` = '" .. self:SteamID() .. "'"
	
	local tab = tmysql.query( query )

	local id = tab[1][1]
	
	--do load stuff here

end

function meta:SaveCharacterInformation()

	local fields = { }
	fields["RPName"] = self:GetNWString( "RPName" )
	fields["Model"] = self:GetNWString( "PlayerModel" )
	fields["SteamID"] = self:SteamID()
	fields["Rubles"] = self:GetPlayerRubles()
	fields["Title"] = self:GetNWString( "title" )
	fields["SecondTitle"] = self:GetNWString( "secondtitle" )
	fields["Age"] = self:GetField( "CCAge" )
	fields["STATAim"] = self:GetField( "CCAim" )
	fields["STATStrength"] = self:GetField( "CCStrength" )
	fields["STATSpeed"] = self:GetField( "CCSpeed" )
	fields["STATEndurance"] = self:GetField( "CCEndurance" )
	
	for n = 1, TS.MaxInventories do
	
		local cont = self:GetTable().Inventories[n].Name or ""
		fields["containers"] = fields["containers"] .. cont .. ";"
	end	
	
	fields["items"] = ""
	
	for i, v in pairs( self:GetTable().InventoryGrid ) do
	
		for x, c in pairs( v ) do
		
			for y, u in pairs( c ) do
				
				if( self:GetTable().InventoryGrid[i][x][y].ItemData ) then
				
					--local amt = self:GetTable().InventoryGrid[i][x][y].ItemData.Amount or 1
					local item = self:GetTable().InventoryGrid[i][x][y].ItemData.ID
					if not item then fields["items"] = ""
					else
					--fields["items"] = fields["items"] .. item .. ";" .. amt .. ";";
						--[[if( self:IsCombine() ) then
							if( not string.find( item, "ts2_" )  ) then
								fields["items"] = fields["items"] .. item .. ";";
							end
						else]]--
							fields["items"] = fields["items"] .. item .. ";";
						--end
					end

				end
			
			end
		
		end
	
	end
	
	local sinfo = ""
	local coma = false
	
	-- do save stuff 
	
	
end	
	
	

	