Hey here is a part of my code of NPC:
The problem is, that everytime i'm getting "selfSay("Oh, I can not fight with you anymore", cid)" please help me guys!
#EDIT It's working when I change from false to true the fight_again
Lua:
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
-- Bruce lutará novamente o jogador que o derrotar? [true/false]
local fight_again = false
if msgcontains(msg, "challenge") then
if fight_again and getPlayerStorageValue(cid, 692) < os.time() then
selfSay("So you want to fight? Get ready to die!")
local pos = getThingPos(getNpcCid())
local summonName = getCreatureName(getNpcCid())
local lookdir = getCreatureLookDirection(cid)
doRemoveCreature(getNpcCid())
local summonCid = doCreateMonster(summonName, pos)
doCreatureSetLookDirection(summonCid, lookdir)
addEvent(checkForBruce, 5000, summonName)
else
selfSay("Oh, I can not fight with you anymore", cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
function checkForBruce(name)
local Bruce = isCreature(getCreatureByName("Mecha Frieza")) and getCreatureByName("Mecha Frieza") or false
if isNpc(Bruce) then
return false
end
if not Bruce then
Bruce = isCreature(getCreatureByName("Mecha Frieza_evolved")) and getCreatureByName("Mecha Frieza_evolved") or Bruce
end
if isCreature(getCreatureTarget(Bruce)) then
addEvent(checkForBruce, 5000, name)
return true
else
local pos = getThingPos(Bruce)
doRemoveCreature(Bruce)
doCreateNpc(name, pos)
end
end
The problem is, that everytime i'm getting "selfSay("Oh, I can not fight with you anymore", cid)" please help me guys!
#EDIT It's working when I change from false to true the fight_again
Last edited: