• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[npc] Gives action id to items

tarjei

Necronian Engineer
Joined
May 25, 2008
Messages
504
Reaction score
126
Location
Poland
Hello.
I was trying to make a npc which would sell item with action id on TFS 0.3 but when I use this

Code:
 doSetItemActionId(doPlayerAddItem(cid, 2090, 1,1), 3940)

I Recive item but without actionid..
and bug in console
Code:
[05/11/2008  18:37:02] Lua Script Error: [Npc interface] 
[05/11/2008  18:37:02] data/npc/scripts/key.lua:onCreatureSay

[05/11/2008  18:37:02] luaDoSetItemActionId(). Item not found

and whole script :PP

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 creatureSayCallback(cid, type, msg)

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

        if msgcontains(msg, 'Czesc') then
            selfSay('Chcesz kupic przedmiot z action id?')
            talkState = 1
        elseif msgcontains(msg, 'yes') and talkState == 1 then
            if pay(cid, 1) then
                doSetItemActionId(doPlayerAddItem(cid, 2090, 1,1), 3940)

                selfSay('Prosze, o to twoj zakupiony przedmiot.')
            else
                selfSay('Nie masz tyle pieniedzy.')
            end
            talkState = 0    
        elseif msgcontains(msg, 'no') and (talkState == 1) then
            selfSay('Ok, than.')
            talkState = 0
        end
    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
[05/11/2008 18:37:02] Lua Script Error: [Npc interface]
[05/11/2008 18:37:02] data/npc/scripts/key.lua:onCreatureSay

[05/11/2008 18:37:02] luaDoSetItemActionId(). Item not found


Do you use tfs 0.3?
 
@topic
[06/11/2008 23:19:10] Lua Script Error: [Npc interface]
[06/11/2008 23:19:10] data/npc/scripts/asd.lua:onCreatureSay

[06/11/2008 23:19:10] luaDoSetItemActionId(). Item not found
using TFS0.3a3pl1
@offtop
hm, I'm wondering where is the price of this item?
if pay(cid, 1) then
NPC doesn't respond when if pay(cid) is 1. When I changed it to 0 it worked.
 
Has anyone got a fix for this or do I need to assign actionid's via an action script instead?

I do know that previous versions of TFS allowed for NPC lua's to set actionid's in the way stated above...

Code:
local item = doPlayerAddItem(cid,2090,1)
doSetItemActionId(item,3940)

But this method no longer works for NPC lua, only Action LUA's (strange, but true).

Cheers.
edit
BTW, to the post starter, the fibula key is a wooden key, so the item id is 2087 ;)
 
Last edited:
Here is my code... I found a way to bypass it with getPlayerSlotItem().

Code:
if getPlayerSlotItem(cid, 6).itemid == 0 and getPlayerSlotItem(cid, 5).itemid == 0 then
		    selfSay('Alright, take this key to unlock the chest.', cid)
			doPlayerAddItem(cid, 2090, 1)
			local key = getPlayerSlotItem(cid, 5)
			doSetItemActionId(key.uid, 5006)
			doSetItemSpecialDescription(key.uid, 'There is still spider silk on it. It looks very old.')
			setPlayerStorageValue(cid, 50005, 2)
		else
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, 'Please, free up your both hands.')
		end
 
Here is my code... I found a way to bypass it with getPlayerSlotItem().

Code:
if getPlayerSlotItem(cid, 6).itemid == 0 and getPlayerSlotItem(cid, 5).itemid == 0 then
		    selfSay('Alright, take this key to unlock the chest.', cid)
			doPlayerAddItem(cid, 2090, 1)
			local key = getPlayerSlotItem(cid, 5)
			doSetItemActionId(key.uid, 5006)
			doSetItemSpecialDescription(key.uid, 'There is still spider silk on it. It looks very old.')
			setPlayerStorageValue(cid, 50005, 2)
		else
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, 'Please, free up your both hands.')
		end

It's a bit of a hack, but at least it's going to do what I need. Thanks for this.

Cheers.
 
Back
Top