Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
htc16 committed Sep 14, 2024
1 parent a6027f4 commit 9b2c08e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
3 changes: 0 additions & 3 deletions data-otservbr-global/npc/gnombold.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ local function creatureSayCallback(npc, creature, type, message)
return
end

--[[/////////////////////
////GEOMANTIC CHARGES////
///////////////////////]]
if MsgContains(message, "charges") then
if player:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Spike_Middle_Charge_Daily) >= os.time() then
return npcHandler:say("Sorry, you have to wait " .. string.diff(player:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Spike_Middle_Charge_Daily) - os.time()) .. " before this task gets available again.", npc, creature)
Expand Down
43 changes: 21 additions & 22 deletions data-otservbr-global/npc/gnome_trooper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,38 +57,37 @@ local response = {
[3] = "A medal of honour! At last they saw my true worth!",
}

local function initializeParcelDelivery(player)
local playerGuid = player:getGuid()
if not DELIVERED_PARCELS[playerGuid] then
DELIVERED_PARCELS[playerGuid] = {}
end

return DELIVERED_PARCELS[playerGuid]
end

local function greetCallback(npc, creature)
local player = Player(creature)
local playerId = player:getId()

-- Inicializa a tabela se ela for nil
if not DELIVERED_PARCELS[player:getGuid()] then
DELIVERED_PARCELS[player:getGuid()] = {}
end
local playerGuid = player:getGuid()
local deliveredParcels = initializeParcelDelivery(player)
local parcelStatus = player:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Lower_Parcel_Main)

if table.contains({ -1, 4 }, player:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Spike_Lower_Parcel_Main)) then
return false
end
if table.contains(DELIVERED_PARCELS[player:getGuid()], npc:getId()) then
if table.contains({-1, 4}, parcelStatus) or table.contains(deliveredParcels, npc:getId()) then
return false
end

npcHandler:setMessage(MESSAGE_GREET, "Do you have something to deliver?")

return true
end

local function creatureSayCallback(npc, creature, type, message)
local player = Player(creature)
local status = player:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Spike_Lower_Parcel_Main)

-- Inicializa a tabela se ela for nil
if not DELIVERED_PARCELS[player:getGuid()] then
DELIVERED_PARCELS[player:getGuid()] = {}
end
local playerGuid = player:getGuid()
local deliveredParcels = initializeParcelDelivery(player)
local parcelStatus = player:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Lower_Parcel_Main)

if MsgContains(message, "something") and not table.contains({ -1, 4 }, status) then
if table.contains(DELIVERED_PARCELS[player:getGuid()], npc:getId()) then
if MsgContains(message, "something") and not table.contains({-1, 4}, parcelStatus) then
if table.contains(deliveredParcels, npc:getId()) then
return true
end

Expand All @@ -97,9 +96,9 @@ local function creatureSayCallback(npc, creature, type, message)
return npcHandler:removeInteraction(npc, creature)
end

npcHandler:say(response[player:getStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Spike_Lower_Parcel_Main)], npc, creature)
player:setStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Spike_Lower_Parcel_Main, status + 1)
table.insert(DELIVERED_PARCELS[player:getGuid()], npc:getId())
npcHandler:say(response[parcelStatus], npc, creature)
player:setStorageValue(Storage.Quest.U10_20.SpikeTaskQuest.Constants.Spike_Lower_Parcel_Main, parcelStatus + 1)
table.insert(deliveredParcels, npc:getId())
npcHandler:removeInteraction(npc, creature)
end
return true
Expand Down

0 comments on commit 9b2c08e

Please sign in to comment.