• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

noodles tfs 0.4

siusiaczek

Banned User
Joined
Jun 22, 2019
Messages
107
Solutions
1
Reaction score
38
hi i am fixing noodles script and i have problem with npc handler focus it doesnt follow the handler focus patch instead it just sniffs banana skin and doesnt follow to next step?

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

function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end   
    
    


    
    if (msgcontains(msg, 'sniff banana skin') or msgcontains(msg, 'banana skin')) and (getPlayerStorageValue(cid, 250) == 19) then
    if (getPlayerItemCount(cid,2219) >= 1) then
        npcHandler:say("<sniff><sniff>",cid)
        npcHandlerfocus = 2
        else
        npcHandler:say("Grrr! banana?",cid)
        
    end
    elseif(npchandlerfocus == 2) then
    if (msgcontains(msg, 'do you like that?') or msgcontains(msg, 'do you like that') or msgcontains(msg, 'do you like') or msgcontains(msg, 'like')) and (npcHandlerfocus == 2) then
    npcHandler:say("Woof!",cid)
    npcHandlerfocus = 3
    end
    
    elseif(npchandlerfocus == 3) then
    if (msgcontains(msg, 'sniff dirty fur') or msgcontains(msg, 'dirty fur')) and (npcHandlerfocus == 3) then
    if (getPlayerItemCount(cid,2220) >= 1) then
        npcHandler:say("<sniff><sniff>",cid)
    npcHandlerfocus = 4
    end
        else
        npcHandler:say("Grrr! fur?",cid)
        end
        elseif(npcHandlerfocus == 4) then
        if (msgcontains(msg, 'do you like that?') or msgcontains(msg, 'do you like that') or msgcontains(msg, 'do you like') or msgcontains(msg, 'like')) and (npcHandlerfocus == 4) then
        npcHandler:say("Woof!",cid)
        npcHandlerfocus = 5
        end
        elseif(npcHandlerfocus == 5) then
        if (msgcontains(msg, 'sniff mouldy cheese') or msgcontains(msg, 'mouldy cheese')) and (npcHandlerfocus == 5) then
        if (getPlayerItemCount(cid,2235,1)) then
        npcHandler:say("<sniff><sniff>",cid)
        npcHandlerfocus = 6
        end
        else
        npcHandler:say("Grrr! cheese?",cid)
        end
        elseif(npcHandlerfocus == 6) then
        if (msgcontains(msg, 'do you like that?') or msgcontains(msg, 'do you like that') or msgcontains(msg, 'do you like') or msgcontains(msg, 'like')) and (npcHandlerfocus == 6) then
        npcHandler:say("Meeep! Grrrrr! <spits>",cid)
        setPlayerStorageValue(cid,250,22)
        npcHandlerfocus = 0
        end
    
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
maybe i did easy mistake somewhere someone can help me with? ;p
 
fixed
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
 
function greetCallback(cid)
    npcHandlerfocus = 0
    return true
end
 
function creatureSayCallback(cid, type, msg)
       if(npcHandler.focus ~= cid) then
        return false
    end   
    
    if (msgcontains(msg, 'no') or msgcontains(msg, 'bad')) and (npcHandlerfocus >= 1) then
        npcHandler:say("Grrr! Woof! Woof!",cid)
        npcHandlerfocus = 0
    end

        if (msgcontains(msg, 'sniff banana skin') or msgcontains(msg, 'banana skin')) and (getPlayerStorageValue(cid, 250) == 19) then
        if (getPlayerItemCount(cid,2219) >= 1) then
        npcHandler:say("<sniff><sniff>",cid)
        npcHandlerfocus = 1
            else
        npcHandler:say("Grrr! banana?",cid)
   end
    elseif (npcHandlerfocus == 1) then   
    if (msgcontains(msg, 'do you like that?') or msgcontains(msg, 'do you like that') or msgcontains(msg, 'do you like') or msgcontains(msg, 'like')) and (npcHandlerfocus == 1) then
        npcHandler:say("Woof!",cid)
        npcHandlerfocus = 2
    end
    elseif (npcHandlerfocus == 2) then
    if (msgcontains(msg, 'sniff dirty fur') or msgcontains(msg, 'dirty fur')) and (npcHandlerfocus == 2) then
    if (getPlayerItemCount(cid,2220) >= 1) then
        npcHandler:say("<sniff><sniff>",cid)
        npcHandlerfocus = 3
        end
    else
        npcHandler:say("Grrr! fur?",cid)
    end
    elseif (npcHandlerfocus == 3) then   
    if (msgcontains(msg, 'do you like that?') or msgcontains(msg, 'do you like that') or msgcontains(msg, 'do you like') or msgcontains(msg, 'like')) and (npcHandlerfocus == 3) then
        npcHandler:say("Woof!",cid)
        npcHandlerfocus = 4
    end
    elseif (npcHandlerfocus == 4) then
        if (msgcontains(msg, 'sniff mouldy cheese') or msgcontains(msg, 'mouldy cheese')) and (npcHandlerfocus == 4) then
        if (getPlayerItemCount(cid,2235,1)) then
        npcHandler:say("<sniff><sniff>",cid)
        npcHandlerfocus = 5
        end
    else
        npcHandler:say("Grrr! cheese?",cid)
    end
    elseif (npcHandlerfocus == 5) then   
    if (msgcontains(msg, 'do you like that?') or msgcontains(msg, 'do you like that') or msgcontains(msg, 'do you like') or msgcontains(msg, 'like')) and (npcHandlerfocus == 5) then
        npcHandler:say("Meeep! Grrrrr! <spits>",cid)
        setPlayerStorageValue(cid,250,22)
        setPlayerStorageValue(cid,100171,26)
        npcHandlerfocus = 0
    end
    end
    return true
end
 
npcHandler:setMessage(MESSAGE_GREET, "<sniff> Woof! <sniff>")
npcHandler:setMessage(MESSAGE_FAREWELL, "Woof! Woof!")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top