Postado Julho 15, 2023 1 ano Olá. Estou com um problema no NPC Halvar, o carinha da arena de Svar... A quest funciona normalmente (cada player só pode fazer 1x cada e em ordem, começando pela Greenhorn, depois Scrapper e Warlord...) Porém aparecem alguns erros que incomodam um pouco, queria saber se tem como tirar... Quando falo hi pro npc: [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> E quando eu falo bye ou fico sem digitar nada por alguns segundos o NPC fica louco e spamma "bye" 20 vezes kkkkkk... Segue o erro: [15/7/2023 18:29:28] [Error - NpcEvents::onCreatureSay] NPC Name: Halvar - Call stack overflow Eu renomeei todas falas dele com "bye" pra saber qual causava isso, porque o fdm tem 4 falas assim... e a mensagem que ele está spamando é essa que esta agora como "Bye three!" Segue o script completo que acusa o erro: 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())
Postado Julho 18, 2023 1 ano Diretor -- Import required modules and libraries domodlib('arenaFunctions') local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} -- Function to reset conversation states local function resetTalkState() focus = 0 talk_start = 0 TS = 0 end -- Function to check if a string contains another string (case-insensitive) local function msgcontains(txt, str) return string.find(string.lower(txt), string.lower(str)) end -- Function to handle player saying something to the NPC 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('I\'m busy.') elseif TS == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena')) then local myArenaLevel = 3 -- Replace this with the appropriate storage value for your system local enterArena = myArenaLevelIs(cid) if getPlayerStorageValue(cid, myArenaLevel) < 3 then 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!") resetTalkState() else selfSay("You don't have " .. enterArena.RC .. " gold! Come back when you are ready!") resetTalkState() end else selfSay("You don't have level " .. enterArena.RLV .. " yet! Come back when you are ready!") resetTalkState() end else selfSay("Cancel[6]") -- Note: Ensure the 'Cancel' table is defined in the arenaFunctions module. resetTalkState() end elseif TS == 1 and msgcontains(msg, 'no') then selfSay("Bye two!") resetTalkState() elseif msgcontains(msg, 'bye') then selfSay("Bye three!") resetTalkState() end return true end -- Function to handle NPC behavior on think function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 10 then if focus > 0 then selfSay('Bye four.') end resetTalkState() end end -- Set the appropriate callback and add the FocusModule npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSay) npcHandler:addModule(FocusModule:new())
Postado Julho 19, 2023 1 ano Autor Vou testar mais tarde, estou no serviço agora... O tibiaking estava off algumas horas atrás quando eu tava almoçando 😕 O GUI está spammando o seguinte erro: [19/7/2023 22:10:21] [Error - NpcScript Interface] [19/7/2023 22:10:21] data/npc/scripts/arena.lua:onThink [19/7/2023 22:10:21] Description: [19/7/2023 22:10:21] data/npc/scripts/arena.lua:69: attempt to perform arithmetic on global 'talk_start' (a nil value) [19/7/2023 22:10:21] stack traceback: [19/7/2023 22:10:21] data/npc/scripts/arena.lua:69: in function <data/npc/scripts/arena.lua:66>
Postado Julho 27, 2023 1 ano Diretor -- Import required modules and libraries domodlib('arenaFunctions') local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) -- Initialize conversation states as local variables local focus = 0 local talk_start = 0 local TS = 0 -- Function to check if a string contains another string (case-insensitive) local function msgcontains(txt, str) return string.find(string.lower(txt), string.lower(str)) end -- Function to handle player saying something to the NPC 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('I\'m busy.') elseif TS == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena')) then local myArenaLevel = 3 -- Replace this with the appropriate storage value for your system local enterArena = myArenaLevelIs(cid) if getPlayerStorageValue(cid, myArenaLevel) < 3 then 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!") focus = 0 -- Reset conversation state: focus talk_start = 0 -- Reset conversation state: talk_start TS = 0 -- Reset conversation state: TS else selfSay("You don't have " .. enterArena.RC .. " gold! Come back when you are ready!") focus = 0 -- Reset conversation state: focus talk_start = 0 -- Reset conversation state: talk_start TS = 0 -- Reset conversation state: TS end else selfSay("You don't have level " .. enterArena.RLV .. " yet! Come back when you are ready!") focus = 0 -- Reset conversation state: focus talk_start = 0 -- Reset conversation state: talk_start TS = 0 -- Reset conversation state: TS end else selfSay("Cancel[6]") -- Note: Ensure the 'Cancel' table is defined in the arenaFunctions module. focus = 0 -- Reset conversation state: focus talk_start = 0 -- Reset conversation state: talk_start TS = 0 -- Reset conversation state: TS end elseif TS == 1 and msgcontains(msg, 'no') then selfSay("Bye two!") focus = 0 -- Reset conversation state: focus talk_start = 0 -- Reset conversation state: talk_start TS = 0 -- Reset conversation state: TS elseif msgcontains(msg, 'bye') then selfSay("Bye three!") focus = 0 -- Reset conversation state: focus talk_start = 0 -- Reset conversation state: talk_start TS = 0 -- Reset conversation state: TS end return true end -- Function to handle NPC behavior on think function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 10 then if focus > 0 then selfSay('Bye four.') end focus = 0 -- Reset conversation state: focus talk_start = 0 -- Reset conversation state: talk_start TS = 0 -- Reset conversation state: TS end end -- Set the appropriate callback and add the FocusModule npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSay) npcHandler:addModule(FocusModule:new())
Postado Julho 29, 2023 1 ano Autor Oi desculpa a demora, estava ocupado com algumas coisas do serviço mas hoje estou de folga... Então... sumiu os erros que mencionei no post original exceto esse: [29/7/2023 9:52:42] [Error - NpcEvents::onCreatureSay] NPC Name: Halvar - Call stack overflow Acontece, como eu disse, quando falo bye pro npc ou quando fico algum tempo sem dizer nada pra ele... Se ajudar eu estou usando a base do NvSo que postaram aqui e esses scripts da arena peguei desse tutorial: Mas desde já agradeço, afinal esse erro é só um erro de diálogo e não afeta em nada a quest, ela funciona certinho
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.