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

Lua NPC - How to set key action id ?

pucus78

Cookie Monster
Joined
Jul 4, 2008
Messages
40
Reaction score
0
This code doesn't work for me. NPC sell key with actionid = 0
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

..

function sellkey(cid, message, keywords, parameters, node)
local key1 = doPlayerAddItem(cid,2088,1)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if  getPlayerMoney(cid) >= 1 then
      doPlayerRemoveMoney(cid, 5)
      doSetItemActionId(key1, 4601)
      npcHandler:say('Please take it.', cid)     
    else
      npcHandler:say('HEY! You don\'t have money! Stop playing tricks on me or I\'ll give you some extra work!', cid)
    end
end

...
local node5 = keywordHandler:addKeyword({'key'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Want buy a key? It\'s cost only 5gp'})
    node5:addChildKeyword({'yes'}, sellkey, {npcHandler = npcHandler, onlyFocus = true, reset = true})

npcHandler:addModule(FocusModule:new())

Thank you for any help :)

PS. In console server i have error:

luaDoSetItemActionId(). Item not found
 
Last edited:
Back
Top