• 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!

TFS 0.X Erro NpcScript Interface

gabriel28

Member
Joined
Mar 16, 2012
Messages
199
Solutions
6
Reaction score
24
When I try to put this script in the server, I got alot of erros. I changed everything on the npcsystem folder, but the error persists.

Here are the script:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

local storage1 = 60093
local storage2 = 60095
local global_storage = 63105

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
      
 
    if msgcontains(msg, 'mission') or msgcontains(msg, 'help') then
        if getPlayerStorageValue(cid, storage1) <= 0 then
            if getPlayerStorageValue(cid, storage2) <= 0 then
                selfSay("Well, left some herbs, you will need to bring me more 100, ok?",cid)
                talkState[talkUser] = 1
            elseif getPlayerStorageValue(cid, storage2) == 1 then
                selfSay("Did you have the 100 blood herbs?", cid)
                talkState[talkUser] = 1
            elseif getPlayerStorageValue(cid, storage2) == 2 then
                selfSay("Ta pronto pra virar hokage agora?", cid)
                talkState[talkUser] = 1
            else
                selfSay("You already bring me the herbs. Thank you again.", cid)
                talkState[talkUser] = 0
            end
        else
            selfSay("I have nothing to you.", cid)
            talkState[talkUser] = 0
        end
        npcHandler:addFocus(cid)
    end
 
    if msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, storage2) <= 0 then
            selfSay("Ok then. Come back when you have them.", cid)
            setPlayerStorageValue(cid, storage2, 1)
        elseif getPlayerStorageValue(cid, storage2) == 1 then
            selfSay("Oh, thanks mate. You've helpful.", cid)
            doPlayerRemoveItem(cid, 2160, 10)
            setPlayerStorageValue(cid, storage2, 2)
            setPlayerStorageValue(cid, storage1, 2)
        else
            selfSay("Is missing some herbs.", cid)
        elseif getPlayerStorageValue(cid, storage2) == 2 and getGlobalStorageValue(global_storage) <= 0 then
            doBroadcastMessage('Temos um novo kage. O player '..getCreatureName(cid)..' acabou de virar o kage de konoha, todos o saudem.')
            doPlayerAddItem(cid, 2124, 1)
            setGlobalStorageValue(global_storage, 1)
        else
            selfSay("Parabéns por terminar as tasks, essa é sua recompensa final.", cid)
            doPlayerAddItem(cid, 2173, 1)
        end
    elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
        selfSay("Ok then.", cid)
        talkState[talkUser] = 0  
    end
    return true
    end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

And here are the error:

[Error - NpcScript Interface]
<Unknown script file>
Description:
attempt to call a nil value

TFS 0.4 rev 3884 v8.60
Thanks in advance.
 
Last edited:
When I try to put this script in the server, I got alot of erros. I changed everything on the npcsystem folder, but the error persists.

Here are the script:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

local storage1 = 60093
local storage2 = 60095
local global_storage = 63105

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     
 
    if msgcontains(msg, 'mission') or msgcontains(msg, 'help') then
        if getPlayerStorageValue(cid, storage1) <= 0 then
            if getPlayerStorageValue(cid, storage2) <= 0 then
                selfSay("Well, left some herbs, you will need to bring me more 100, ok?",cid)
                talkState[talkUser] = 1
            elseif getPlayerStorageValue(cid, storage2) == 1 then
                selfSay("Did you have the 100 blood herbs?", cid)
                talkState[talkUser] = 1
            elseif getPlayerStorageValue(cid, storage2) == 2 then
                selfSay("Ta pronto pra virar hokage agora?", cid)
                talkState[talkUser] = 1
            else
                selfSay("You already bring me the herbs. Thank you again.", cid)
                talkState[talkUser] = 0
            end
        else
            selfSay("I have nothing to you.", cid)
            talkState[talkUser] = 0
        end
        npcHandler:addFocus(cid)
    end
 
    if msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, storage2) <= 0 then
            selfSay("Ok then. Come back when you have them.", cid)
            setPlayerStorageValue(cid, storage2, 1)
        elseif getPlayerStorageValue(cid, storage2) == 1 then
            selfSay("Oh, thanks mate. You've helpful.", cid)
            doPlayerRemoveItem(cid, 2160, 10)
            setPlayerStorageValue(cid, storage2, 2)
            setPlayerStorageValue(cid, storage1, 2)
        else
            selfSay("Is missing some herbs.", cid)
        elseif getPlayerStorageValue(cid, storage2) == 2 and getGlobalStorageValue(global_storage) <= 0 then
            doBroadcastMessage('Temos um novo kage. O player '..getCreatureName(cid)..' acabou de virar o kage de konoha, todos o saudem.')
            doPlayerAddItem(cid, 2124, 1)
            setGlobalStorageValue(global_storage, 1)
        else
            selfSay("Parabéns por terminar as tasks, essa é sua recompensa final.", cid)
            doPlayerAddItem(cid, 2173, 1)
        end
    elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
        selfSay("Ok then.", cid)
        talkState[talkUser] = 0 
    end
    return true
    end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

And here are the error:

[Error - NpcScript Interface]
<Unknown script file>
Description:
attempt to call a nil value

TFS 0.4 rev 3884 v8.60
Thanks in advance.
change
Lua:
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end
to
Lua:
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
 
@Xikini
Nothing happened, the same error happens.

Look that:
When I try this:
Code:
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 global_storage = 31004
local b = getGlobalStorageValue(31004) if b == -1 then b = 1 end
local vocs = {320}

function greetCallback(cid)
        if (isInArray(vocs, getPlayerVocation(cid))) then
            npcHandler:say("xxxxxxxxx", cid)
            npcHandler:addFocus(cid)
        else
            npcHandler:say("xxxxxxxxxxx", cid)
            npcHandler:resetNpc(cid)
        return false
        end
    return false
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
---------------------------------------------------------
if(msgcontains(msg, 'misison')) then
selfSay('xxxxxxxxxxxxxxx', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if b < 2 then
if (getGlobalStorageValue(global_storage) < 0) then
doBroadcastMessage('xxxxxxxxx '..getCreatureName(cid)..' xxxxxxxxxx.')
doPlayerAddItem(cid,2160,4)
setGlobalStorageValue(global_storage,b+1)
else
doPlayerAddItem(cid,2160,1)
selfSay('xxxxxxxxxxxxxxx', cid)
end
end
end
return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I got no error
But when I try this:

Code:
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 storage = 454674
local global_storage = 31003
local b = getGlobalStorageValue(31003) if b == -1 then b = 1 end
local vocs = {320}

function greetCallback(cid)
        if (isInArray(vocs, getPlayerVocation(cid))) then
            npcHandler:say("XXXXXXXXXXXXXXX", cid)
            npcHandler:addFocus(cid)
        else
            npcHandler:say("XXXXXXXX", cid)
            npcHandler:resetNpc(cid)
        return false
        end
    return false
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
   
    if(msgcontains(msg, 'misison')) then
        if (getPlayerStorageValue(cid, storage) = -1) then
            selfSay('XXXXXXXXXXXXX', cid)
            talkState[talkUser] = 1
        elseif (getPlayerStorageValue(cid, storage) = 1) then
            selfSay('XXXXXXXXXXX', cid)
            talkState[talkUser] = 1
        elseif (getPlayerStorageValue(cid, storage) = 2) then
            selfSay('XXXXXXXXX', cid)
            talkState[talkUser] = 1
        else
            selfSay('XXXXXXXXXXXX', cid)
        end
    end   
    if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if (getPlayerStorageValue(cid, storage) = -1) then
            selfSay('XXXXXXX', cid)
            setPlayerStorageValue(cid,storage,1)
        elseif (getPlayerStorageValue(cid, storage) = 1) then
            if (doPlayerRemoveItem(cid, 2160, 1) == TRUE) then
                selfSay('XXXXXXXXX', cid)
                setPlayerStorageValue(cid,storage,2)
            end
        elseif (getPlayerStorageValue(cid, storage) = 2) then   
            if b < 2 then
                if (getGlobalStorageValue(global_storage) < 0) then
                    doBroadcastMessage('TXXXXXXXXXX'..getCreatureName(cid)..' XXXXXXXXX')
                    doPlayerAddItem(cid,2136,3)
                    setGlobalStorageValue(global_storage,b+1)
                    setPlayerStorageValue(cid,storage,3)
                else
                    doPlayerAddItem(cid,2136,1)
                    selfSay('XXXXXXXXXX', cid)
                end
            end   
        end
    end
return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I have lots of errors I told before.
Do you know what's happen here ?
 
None of the scripts you've sent are the same.
It's kind of hard to help you when every script you post is different.

It's probably this line.
Because you have an if statement outside of a function.
Lua:
local b = getGlobalStorageValue(31003) if b == -1 then b = 1 end
 
@Xikini
Sorry about that, but they are the same script with my tries to solve my problem.
But, talking about you said now, I don't know if is it "if b == -1 then b = 1 end" the problem, because, if you see my second reply, I put two scripts, one that works and another that not. And the script that work, have it out of a function, and have no erros in the console, and the script work and if I put it inside a function works too. And I tried to put it inside a function in the script that don't work, but the error keeps.

So, look the two scripts (in the second reply), the script that don't work have some changes in comparison with the one that works.
You can tell me what I'm doing wrong? Do you think that's because it's a server updraded from 8.54 to 8.60?
 
@Xikini
Sorry about that, but they are the same script with my tries to solve my problem.
But, talking about you said now, I don't know if is it "if b == -1 then b = 1 end" the problem, because, if you see my second reply, I put two scripts, one that works and another that not. And the script that work, have it out of a function, and have no erros in the console, and the script work and if I put it inside a function works too. And I tried to put it inside a function in the script that don't work, but the error keeps.

So, look the two scripts (in the second reply), the script that don't work have some changes in comparison with the one that works.
You can tell me what I'm doing wrong? Do you think that's because it's a server updraded from 8.54 to 8.60?
nevermind, it's the same issue as before.
-- I mistyped it in my first reply.

Replace your stuff with this.
Lua:
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

-- base npc
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 greetCallback(cid)
    return true
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

    -- script goes here
  
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
@Xikini
I used your 'base npc' and tried it:

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

local storage1 = 60093
local storage2 = 60095
local b = getGlobalStorageValue(31005)
local global_storage = 31005
local vocs = {320}

function greetCallback(cid)
    if (isInArray(vocs, getPlayerVocation(cid))) then
            npcHandler:say("XXXXXXXXXXXXXXX", cid)
            npcHandler:addFocus(cid)
        else
            npcHandler:say("XXXXXXXX", cid)
            npcHandler:resetNpc(cid)
        return false
    end
    return true
end

function creatureSayCallback(cid, type, msg)
if b == -1 then b = 1 end
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if(msgcontains(msg, 'misison')) then
        if (getPlayerStorageValue(cid, storage) = -1) then
            selfSay('XXXXXXXXXXXXX', cid)
            talkState[talkUser] = 1
        elseif (getPlayerStorageValue(cid, storage) = 1) then
            selfSay('XXXXXXXXXXX', cid)
            talkState[talkUser] = 1
        elseif (getPlayerStorageValue(cid, storage) = 2) then
            selfSay('XXXXXXXXX', cid)
            talkState[talkUser] = 1
        else
            selfSay('XXXXXXXXXXXX', cid)
        end
    end
    if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if (getPlayerStorageValue(cid, storage) = -1) then
            selfSay('XXXXXXX', cid)
            setPlayerStorageValue(cid,storage,1)
        elseif (getPlayerStorageValue(cid, storage) = 1) then
            if (doPlayerRemoveItem(cid, 2160, 1) == TRUE) then
                selfSay('XXXXXXXXX', cid)
                setPlayerStorageValue(cid,storage,2)
            end
        elseif (getPlayerStorageValue(cid, storage) = 2) then
            if b < 2 then
                if (getGlobalStorageValue(global_storage) < 0) then
                    doBroadcastMessage('TXXXXXXXXXX'..getCreatureName(cid)..' XXXXXXXXX')
                    doPlayerAddItem(cid,2136,3)
                    setGlobalStorageValue(global_storage,b+1)
                    setPlayerStorageValue(cid,storage,3)
                else
                    doPlayerAddItem(cid,2136,1)
                    selfSay('XXXXXXXXXX', cid)
                end
            end
        end
    end

    return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

But the error keeps.
I use script like that in a global server, but in this server (NTO) don't work, and I use the same TFS in both.
 
Last edited:
can you post your NPC .xml file, and check if location is correct?

Try commenting out every part of function and test it again. (its odd its not giving you a line of the error.)
 
@Lyky
This is the xml file:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Kazekage" script="data/npc/scripts/npcquest/kazekage.lua" walkinterval="2000" speed="0" floorchange="0">
<health now="100" max="100"/>
<look type="145" head="38" body="79" legs="107" feet="114"/>

</npc>

And the path is right, because I'm just replacing the original script with this one that gives this error.
If you look at my second reply, where have 2 scripts, you will see one that work fine and the other that don't.

If my npc lib folder will help, here are

File> MEGA
Scam> VirusTotal
 
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
local storage = 454674
local global_storage = 31003
local b = getGlobalStorageValue(31003) if b == -1 then b = 1 end
local vocs = {320}
function greetCallback(cid)
        if (isInArray(vocs, getPlayerVocation(cid))) then
            npcHandler:say("XXXXXXXXXXXXXXX", cid)
            npcHandler:addFocus(cid)
        else
            npcHandler:say("XXXXXXXX", cid)
            npcHandler:resetNpc(cid)
        return false
        end
    return false
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
  
    if(msgcontains(msg, 'misison')) && (getPlayerStorageValue(cid, storage) = -1) then
            selfSay('XXXXXXXXXXXXX', cid)
            talkState[talkUser] = 1
        elseif (getPlayerStorageValue(cid, storage) = 1) then
            selfSay('XXXXXXXXXXX', cid)
            talkState[talkUser] = 1
        elseif (getPlayerStorageValue(cid, storage) = 2) then
            selfSay('XXXXXXXXX', cid)
            talkState[talkUser] = 1
        else
            selfSay('XXXXXXXXXXXX', cid)
        end
 
    if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) && (getPlayerStorageValue(cid, storage) = -1) then
            selfSay('XXXXXXX', cid)
            setPlayerStorageValue(cid,storage,1)
        elseif (getPlayerStorageValue(cid, storage) = 1) && (doPlayerRemoveItem(cid, 2160, 1) == TRUE) then
                selfSay('XXXXXXXXX', cid)
                setPlayerStorageValue(cid,storage,2)
        elseif (getPlayerStorageValue(cid, storage) = 2) && b < 2 && (getGlobalStorageValue(global_storage) < 0) then
                    doBroadcastMessage('TXXXXXXXXXX'..getCreatureName(cid)..' XXXXXXXXX')
                    doPlayerAddItem(cid,2136,3)
                    setGlobalStorageValue(global_storage,b+1)


                    setPlayerStorageValue(cid,storage,3)
                else
                    doPlayerAddItem(cid,2136,1)
                    selfSay('XXXXXXXXXX', cid)
                end
            end 
        end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

check following, you may also try changing && to and, make sure to check syntax. The error you listed at the first was about 'type'
what are your current errors.

You should try commenting out each beginning of the if script and see which part causes errors if your engine doesn't output the error line.
 
@Lyky
The error persists, the same error:

[Error - NpcScript Interface]
<Unknown script file>
Description:
attempt to call a nil value

Doesn't matter what I do in this script.
Do you think that I can change some file in data/lib folder that can solve this error?
 
Last edited:
Sorry double post, but I can't edit the last property.


Script like that works:

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
local storage = 775231
local global_storage = 31000
local b = getGlobalStorageValue(31000)
local vocs = {320}

function greetCallback(cid)
        if (isInArray(vocs, getPlayerVocation(cid))) then
            npcHandler:say("xxxxxxxxxxx", cid)
            npcHandler:addFocus(cid)
        else
            npcHandler:say("xxxxxxxxx", cid)
            npcHandler:resetNpc(cid)
        return false
        end
    return false
end
function creatureSayCallback(cid, type, msg)
if b == -1 then b = 1 end
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
---------------------------------------------------------
if(msgcontains(msg, 'mission')) then
if (getPlayerStorageValue(cid, storage)) < 0 then
selfSay('XX1', cid)
talkState[talkUser] = 1
end
end
if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if b < 2 then
if (getGlobalStorageValue(global_storage) < 0) then
doBroadcastMessage('xxxxxxxxxxxx '..getCreatureName(cid)..' xxxxxxxxxxxxxxxx')
doPlayerAddItem(cid,2160,4)
setGlobalStorageValue(global_storage,b+1)
else
doPlayerAddItem(cid,2160,1)
selfSay('xxxxxxxxxxxxxxxxxx', cid)
end
end
end
return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


But when I put one 'elseif', don't work more:

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
local storage = 775231
local global_storage = 31000
local b = getGlobalStorageValue(31000)
local vocs = {320}

function greetCallback(cid)
        if (isInArray(vocs, getPlayerVocation(cid))) then
            npcHandler:say("xxxxxxxxxxxxx", cid)
            npcHandler:addFocus(cid)
        else
            npcHandler:say("xxxxxxxxxxxxxxx", cid)
            npcHandler:resetNpc(cid)
        return false
        end
    return false
end
function creatureSayCallback(cid, type, msg)
if b == -1 then b = 1 end
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
---------------------------------------------------------
if(msgcontains(msg, 'mission')) then
if (getPlayerStorageValue(cid, storage)) < 0 then
selfSay('XX1', cid)
talkState[talkUser] = 1
elseif (getPlayerStorageValue(cid, storage)) = 1 then --this is the difference between both
selfSay('XX2', cid)
talkState[talkUser] = 1
end
end
if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if b < 2 then
if (getGlobalStorageValue(global_storage) < 0) then
doBroadcastMessage('xxxxx'..getCreatureName(cid)..' xxxxxxxxxxx')
doPlayerAddItem(cid,2160,4)
setGlobalStorageValue(global_storage,b+1)
else
doPlayerAddItem(cid,2160,1)
selfSay('xxxxxxxxxxxxxxxxxxxxxx', cid)
end
end
end
return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top