
specail
Membro
-
Registro em
-
Última visita
Histórico de Curtidas
-
specail deu reputação a L3K0T em Bug no NPC Halvar (Arena Svargrond)-- 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())
-
specail deu reputação a L3K0T em Bug no NPC Halvar (Arena Svargrond)-- 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())