darkmu
Well-Known Member
What is happening is that if the player goes in sequence to kill the boss he suddenly starts giving this error or if he simply does not count the time again and expels him at any time, does anyone know how I can adjust this?
TFS 1.3
TFS 1.3
Lua:
2020-10-28 12:54:17 - Lua Script Error: [Main Interface]
2020-10-28 12:54:17 - in a timer event called from:
2020-10-28 12:54:17 - (Unknown scriptfile)
2020-10-28 12:54:17 - attempt to index a number value
2020-10-28 12:54:17 - stack traceback:
2020-10-28 12:54:17 - [C]: at 0x555555786b00
2020-10-28 12:54:17 - [C]: in function 'getSpectators'
2020-10-28 12:54:17 - data/npc/scripts/Ancient.lua:22: in function <data/npc/scripts/Ancient.lua:19>
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
local function roomIsOccupied(centerPosition, rangeX, rangeY)
local spectators = Game.getSpectators(centerPosition, false, false, rangeX, rangeX, rangeY, rangeY)
if #spectators ~= 0 then
return true
end
return false
end
function clearBossRoom(playerId, bossId,
centerPosition,
rangeX, rangeY, exitPosition)
local spectators, spectator = Game.getSpectators(centerPosition, false, false,
rangeX,
rangeX, rangeY, rangeY)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isPlayer() and spectator.uid == playerId then
spectator:teleportTo(exitPosition)
exitPosition:sendMagicEffect(CONST_ME_TELEPORT)
end
if spectator:isMonster() then
spectator:remove()
end
end
end
local function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if msgcontains(msg, "fight") then
npcHandler:say("Are you sure you want to duel with the Ancient Lion Knight?", cid)
npcHandler.topic[cid] = 1
elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 1 then
if player:getItemCount(39801) == 0 then
npcHandler:say("Sorry but you don't have the item.", cid)
npcHandler.topic[cid] = 0
elseif roomIsOccupied(Position(233, 65, 7),3,3) then
npcHandler:say("Sorry, but the room is currently occupied.", cid)
npcHandler.topic[cid] = 0
else
npcHandler.topic[cid] = 2
npcHandler:say("I need you to give me a White Silk Flower, say {yes}.", cid)
end
elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
npcHandler:say("Go to the cemetery to fight the Ancient.", cid)
doPlayerRemoveItem(cid,39801,1)
player:setStorageValue(15518,1)
local monster = Game.createMonster('Ancient Lion Knight', Position(233, 65, 7))
addEvent(clearBossRoom, 5 * 60 * 1000 , player.uid, monster.uid, Position(233, 65, 7), 5, 4, Position(222, 57, 7))
npcHandler.topic[cid] = 0
end
end
npcHandler:setMessage(MESSAGE_GREET, 'If you want to fight the boss, say {fight}.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)
npcHandler:addModule(FocusModule:new())