local npcs = {}

function get_npc_money(npc)
	local npc_money = 0
	if npc ~= nil and not npcs[npc:id()] then
		local npc_rank, npc_money
		npc_rank = ranks.get_obj_rank_name(npc)

		if npc_rank == "novice" then
			money = math.random(1,500)
		elseif npc_rank	== "experienced" then
			money = math.random(50,1000)
		elseif npc_rank	== "veteran" then
			money = math.random(50,3000)
		elseif npc_rank	== "master" then
			money = math.random(50,5000)
		end

		if npc_rank ~= nil then
			local level_name, level_money
			level_name = level.name()

			if level_name == "zaton" then
				level_money = 1.0
			elseif level_name == "jupiter" then
				level_money = 1.0
			elseif level_name == "escape" then
				level_money = 1.0
			elseif level_name == "digger_stash" then
				level_money = 1.0
			elseif level_name == "hospital" then
				level_money = 1.0
			elseif level_name == "military" then
				level_money = 1.0
			elseif level_name == "stancia_2" then
				level_money = 1.0
			elseif level_name == "yantar" then
				level_money = 1.0
			elseif level_name == "agroprom_underground" then
				level_money = 1.0
			elseif level_name == "pripyat" then
				level_money = 1.0
			elseif level_name == "labx8" or level_name == "jupiter_underground" then
				level_money = 1.0
			end

			if level_name ~= nil then
				local npc_community, com_money
				npc_community =	npc:character_community()

				if     npc_community ==	"monolith"	then
					com_money = 1.0
				elseif npc_community ==	"military"	then
					com_money = 1.0
				elseif npc_community ==	"bandit"	then
					com_money = 1.0
				elseif npc_community ==	"killer"	then
					com_money = 1.0
				elseif npc_community ==	"ecolog"	then
					com_money = 1.0
				elseif npc_community ==	"dolg"		then
					com_money = 1.0
				elseif npc_community ==	"freedom"	then
					com_money = 1.0
				elseif npc_community ==	"zombied"	then
					com_money = 1.0
				elseif npc_community == "stalker"	then
					com_money = 1.0
				elseif npc_community ==	"unknown"	then
					com_money = 0
				elseif npc_community == ""		then
					com_money = 1.0
				else
					com_money = 1.1
				end

				if npc_community ~= nil	then
					npc_money = math.ceil(money * level_money * com_money)
				end

				if npc_money > 0 then
					xr_sound.set_sound_play(db.actor:id(), "pda_tips")
					news_manager.relocate_money(db.actor, "in", npc_money)
					db.actor:give_money(npc_money)
					npcs[npc:id()] = true
				end
			end
		end
	end
end