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

Solved Hi. I need help with a mission npc that recieve items but the script dont work.

Udun

Well-Known Member
Joined
Jan 5, 2012
Messages
193
Solutions
1
Reaction score
67
Hello all, I have this problem with this npc, must be simple to solve... I need that the npc accept all the items at the same time and give the player a storage id, but the npc doesn't work...
Anybody knows how fix it?
Thanks alot!

Code:
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

-- XVX FORGER START --

function royal(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
        if getPlayerItemCount(cid,11219) and (cid,10033) and (cid,2219) and (cid,8843) >= 1 then
        if doPlayerRemoveItem(cid,11219,15), (cid,10033,30), (cid,2219,30), (cid,8843,14) then
            npcHandler:say('Well done my friend!', cid)
            doPlayerAddItem(cid,2691,5)
            setPlayerStorageValue(cid,60146,1)
        end
        else
            npcHandler:say('You dont have all the items.', cid)
    end
end  

-- XVX FORGER END --

keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you have {all} the items?"})

local node1 = keywordHandler:addKeyword({'all'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Are you sure?'})
    node1:addChildKeyword({'yes'}, royal, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'No you dont!.', reset = true})

npcHandler:addModule(FocusModule:new())
 
is the tfs 0.3.6, I used other script as base, is exactly the same and works, but only with 1 item, i try to make it for more than 1 item, but i couldn't :(
 
distro? console errors?
dont do this
Lua:
        if getPlayerItemCount(cid,11219) and (cid,10033) and (cid,2219) and (cid,8843) >= 1 then
        if doPlayerRemoveItem(cid,11219,15), (cid,10033,30), (cid,2219,30), (cid,8843,14) then
do this
Lua:
if getPlayerItemCount(cid,11219) >= 15 and  getPlayerItemCount(cid,10033) >= 30 and getPlayerItemCount(cid,2219) >= 30 and getPlayerItemCount(cid,8843) >= 14 then
doPlayerRemoveItem(cid,11219,15)
doPlayerRemoveItem(cid,10033,30)
doPlayerRemoveItem(cid,2219,30)
doPlayerRemoveItem(cid,8843,14)
 
Last edited:
I made this fix as you say:

Code:
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

-- XVX FORGER START --

function royal(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
             if getPlayerItemCount(cid,11219) >= 15 and  getPlayerItemCount(cid,10033) >= 30 and getPlayerItemCount(cid,2219) >= 30 and getPlayerItemCount(cid,8843) >= 14 then
                doPlayerRemoveItem(cid,11219,15)
                doPlayerRemoveItem(cid,10033,30)
                doPlayerRemoveItem(cid,2219,30)
                doPlayerRemoveItem(cid,8843,14) then
            npcHandler:say('Well done my friend!', cid)
            doPlayerAddItem(cid,2691,5)
            setPlayerStorageValue(cid,60146,1)
        end
        else
            npcHandler:say('You dont have all the items!.', cid)
    end
end 

-- XVX FORGER END --

keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you have {all} the items?"})

local node1 = keywordHandler:addKeyword({'all'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Are you sure?'})
    node1:addChildKeyword({'yes'}, royal, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'No you dont...', reset = true})

npcHandler:addModule(FocusModule:new())

I see this error in console and the npc dont load :(
data/npc/scripts/willy.lua:20: unexpected symbol near 'then'
 
Last edited:
you did not copy what I provided you as is
on line 20 you must have
doPlayerRemoveItem(cid,8843,14) then
 
you did not copy what I provided you as is
on line 20 you must have
doPlayerRemoveItem(cid,8843,14) then

Thanks men! The error disappear, but now is a new one xD

data/npc/scripts/willy.lua:12: 'end' explected <to close 'function' at line 12> near 'else'
 
Back
Top