From 6a55c26f8e5140ad4e9e2a3ad4e26b07a86040c1 Mon Sep 17 00:00:00 2001 From: Majesty <32709570+majestyotbr@users.noreply.github.com> Date: Sun, 14 Jan 2024 00:14:56 -0300 Subject: [PATCH] Update rapier_quest.lua --- .../actions/rookgaard/rapier_quest.lua | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/data-otservbr-global/scripts/actions/rookgaard/rapier_quest.lua b/data-otservbr-global/scripts/actions/rookgaard/rapier_quest.lua index a60563ec1a5..726279dd274 100644 --- a/data-otservbr-global/scripts/actions/rookgaard/rapier_quest.lua +++ b/data-otservbr-global/scripts/actions/rookgaard/rapier_quest.lua @@ -1,15 +1,20 @@ local rapierQuest = Action() - +local reward = 3272 function rapierQuest.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if player:questKV("rapier"):get("completed") then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The box is empty.") + local itemType = ItemType(reward) + local itemWeight = itemType:getWeight() + if player:getFreeCapacity() >= itemType:getWeight() then + if not player:questKV("rapier"):get("completed") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a rapier.") + player:addItem(reward, 1) + player:questKV("rapier"):set("completed", true) + else + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The box is empty.") + end else - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a rapier.") - player:addItem(3272, 1) - player:questKV("rapier"):set("completed", true) + player:sendTextMessage(MESSAGE_LOOK, "You have found a " .. itemType:getName() .. " weighing " .. (itemWeight/ 100) .. " oz, but it's too heavy.") end return true end - rapierQuest:uid(14042) rapierQuest:register()