--[[
Copyright: © Ирбиs , Real Wolf
]]

local worder,have_ord,allowed

function is_ordered_now()
	worder = "freedom_exo"
	if have_ord == nil or not have_ord == true then
		return true
	end
	return false
end

function precond_all()
	if db.actor:money() >= 11000 and db.actor:object("exo_outfit") then
		return true
	end
	return false
end

function precond_money_1()
	if db.actor:money() >= 11000 then
		return false
	end
	return true
end

function precond_exo_1()
	if db.actor:object("exo_outfit") then
		return false
	end
	return true
end

function precond_exo_2()
	if db.actor:object("exo_outfit") then
		return true
	end
	return false
end

function start_order(gg,npc)
	dialogs.relocate_item_section(npc, "exo_outfit", "out")
	dialogs.relocate_money(npc, 11000, "out")
	amk.g_start_timer("order_for_"..tostring(worder),0,6,0)
	have_ord = true
end

function allowed_to_get()
	allowed = true
	amk.send_tip("Заказ выполнен, можешь забирать.", "Скряга", nil, 5) 
end

function precond_getting(gg,npc)
	worder = "freedom_exo"
	if (have_ord ~= nil and have_ord == true) then
		return true
	end
	return false
end

function precond_getting_1()
	if allowed == true then
		return false
	end
	return true
end

function precond_getting_2()
	if allowed == true then
		return true
	end
	return false
end

function getting(gg,npc)
	have_ord = false
	dialogs.relocate_item_section(gg, tostring(worder), "in")
	worder = "nil"
	allowed = false
end

function Save()
	amk.save_variable("ord_free_have_ord", have_ord)
	amk.save_variable("ord_free_allowed", allowed)
	amk.save_variable("ord_free_worder", worder)
end

function Load()
	have_ord = amk.load_variable("ord_free_have_ord")
	amk.del_variable("ord_free_have_ord")
	allowed = amk.load_variable("ord_free_allowed")
	amk.del_variable("ord_free_allowed")
	worder = amk.load_variable("ord_free_worder")
	amk.del_variable("ord_free_worder")
end	