I got the quest working 100% (players can do each arena only once, starting with greenhorn, then scrapper, then warlord... so no way to duplicate items...)
But I keep getting these errors and would like to know if I can remove them:
When I say hi to Halvar:
And when I say bye or stay silent for a few seconds:
Also the NPC goes crazy and says "Bye!" 20 times xD
I changed each of his "farewell" messages and found out that the message being spammed is, as I named: "Bye three!", but the whole script is here for you guys to check out:
But I keep getting these errors and would like to know if I can remove them:
When I say hi to Halvar:
Lua:
[15/7/2023 18:29:17] [Error - NpcScript Interface]
[15/7/2023 18:29:17] data/npc/scripts/arena.lua:onCreatureSay
[15/7/2023 18:29:17] Description:
[15/7/2023 18:29:17] (LuaInterface::internalGetPlayerInfo) Player not found when requesting player info #3
[15/7/2023 18:29:17] [Error - NpcScript Interface]
[15/7/2023 18:29:17] data/npc/scripts/arena.lua:onCreatureSay
[15/7/2023 18:29:17] Description:
[15/7/2023 18:29:17] data/npc/scripts/arena.lua:46: attempt to compare number with boolean
[15/7/2023 18:29:17] stack traceback:
[15/7/2023 18:29:17] data/npc/scripts/arena.lua:46: in function <data/npc/scripts/arena.lua:34>
[15/7/2023 18:29:17] [C]: in function 'selfSay'
[15/7/2023 18:29:17] data/npc/scripts/arena.lua:37: in function <data/npc/scripts/arena.lua:34>
And when I say bye or stay silent for a few seconds:
Code:
[15/7/2023 18:29:28] [Error - NpcEvents::onCreatureSay] NPC Name: Halvar - Call stack overflow
Also the NPC goes crazy and says "Bye!" 20 times xD
I changed each of his "farewell" messages and found out that the message being spammed is, as I named: "Bye three!", but the whole script is here for you guys to check out:
Code:
domodlib('arenaFunctions')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 focus = 0
local talk_start = 0
local TS = 0
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Bye one.')
focus = 0
talk_start = 0
end
end
local function BYE()
focus = 0
talk_start = 0
TS = 0
end
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) then
selfSay('Hello ' .. getCreatureName(cid) .. ', do you want to fight in the arena?')
focus = cid
talk_start = os.clock()
TS = 1
elseif msgcontains(msg, 'hi') and (focus ~= cid) then
selfSay('Im Busy')
elseif TS == 1 and msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena') then
if getPlayerStorageValue(cid, myArenaLevel) < 3 then
local enterArena = myArenaLevelIs(cid)
if getPlayerLevel(cid) >= enterArena.RLV then
if getPlayerMoney(cid) >= enterArena.RC then
setPlayerStorageValue(cid, talkNPC, 1)
doPlayerRemoveMoney(cid, enterArena.RC)
selfSay("Now you can face the... ".. enterArena.LN .."level!")
BYE()
else
selfSay("You don\'t have "..enterArena.RC.." gold! Come back when you are ready!")
BYE()
end
else
selfSay("You don\'t have level "..enterArena.RLV.." yet! Come back when you are ready!")
BYE()
end
else
selfSay(Cancel[6])
BYE()
end
elseif TS == 1 and msgcontains(msg, 'no') then
selfSay("Bye two!")
BYE()
elseif msgcontains(msg, 'bye') then
selfSay("Bye three!")
BYE()
end
return true
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 10 then
if focus > 0 then
selfSay('Bye four.')
end
focus = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: