• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 1.X+ tfs 1.5 nekiro 7.72 add set id action to key... or items

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
535
Solutions
7
Reaction score
62
Location
Brazil
hello, i started editing my quests, and i would like to know how i do for npc or anything to set an action id on the item, for example a key..


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 key(cid, message, keywords, parameters, node)
   if(not npcHandler:isFocused(cid)) then
        return false
    end
    
    local player_gold     = getPlayerItemCount(cid,2148)
    local player_plat     = getPlayerItemCount(cid,2152)*100
    local player_crys     = getPlayerItemCount(cid,2160)*10000
    local player_money     = player_gold + player_plat + player_crys
    
         if player_money >= 800 then
        if doPlayerRemoveMoney(cid,800) then
            npcHandler:say('Here, take the key!', cid)
            local playerID = getPlayerGUID(cid)
                 local item = doPlayerAddItem(cid, 2087, 1)
             doItemSetActionId(item, 3940)
        end
        else
            npcHandler:say('You don\'t have enough money for the key!', cid)
    end
end   



node4 = keywordHandler:addKeyword({'key'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To get the fibula key you need to give me 800 gold coins, do you have them with you?'})
node4:addChildKeyword({'yes'}, key, {})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})


npcHandler:addModule(FocusModule:new())
 
Solution
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


local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
    if msgcontains(msg, "key") then
        npcHandler:say("Do you want to buy the dungeon key for 800 gold?"...
OP
OP
bpm91

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
535
Solutions
7
Reaction score
62
Location
Brazil
I don't know where I'm going wrong

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 key(cid, message, keywords, parameters, node)
   if(not npcHandler:isFocused(cid)) then
        return false
    end
    
    local player_gold     = getPlayerItemCount(cid,2148)
    local player_plat     = getPlayerItemCount(cid,2152)*100
    local player_crys     = getPlayerItemCount(cid,2160)*10000
    local player_money     = player_gold + player_plat + player_crys
    
        if player_money >= 800 then
           if doPlayerRemoveMoney(cid,800) then
            npcHandler:say('Here, take the key!', cid)
            local playerID = getPlayerGUID(cid)
            local key = player:addItem(2087, 1)
            if key then
            setActionId(3940)
            end
        end
        else
            npcHandler:say('You don\'t have enough money for the key!', cid)
    end
    
end   



node4 = keywordHandler:addKeyword({'key'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To get the fibula key you need to give me 800 gold coins, do you have them with you?'})
node4:addChildKeyword({'yes'}, key, {})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})

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


1650374542152.png
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,509
Solutions
260
Reaction score
4,467
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


local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
    if msgcontains(msg, "key") then
        npcHandler:say("Do you want to buy the dungeon key for 800 gold?", cid)
        npcHandler.topic[cid] = 1
    elseif msgcontains(msg, "yes") then
        if npcHandler.topic[cid] == 1 then
            if player:removeMoney(800) then
                npcHandler:say("Here it is.", cid)
                local key = player:addItem(2087, 1)
                if key then
                    key:setActionId(3940)
                end
            else
                npcHandler:say("You don't have enough money.", cid)
            end
            npcHandler.topic[cid] = 0
        end
    end
    return true
end

keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = "I am the magistrate of this isle."})
keywordHandler:addKeyword({'magistrate'}, StdModule.say, {npcHandler = npcHandler, text = "Thats me."})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = "I am Dermot, the magistrate of this isle."})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, text = "Time is not important on Fibula."})
keywordHandler:addKeyword({'fibula'}, StdModule.say, {npcHandler = npcHandler, text = "You are at Fibula. This isle is not very dangerous. Just the wolves bother outside the village."})
keywordHandler:addKeyword({'dungeon'}, StdModule.say, {npcHandler = npcHandler, text = "Oh, my god. In the dungeon of Fibula are a lot of monsters. That's why we have sealed it with a solid door."})
keywordHandler:addKeyword({'monsters'}, StdModule.say, {npcHandler = npcHandler, text = "Oh, my god. In the dungeon of Fibula are a lot of monsters. That's why we have sealed it with a solid door."})

npcHandler:setMessage(MESSAGE_GREET, "Hello, traveller |PLAYERNAME|. How can I help you?")
npcHandler:setMessage(MESSAGE_FAREWELL, "See you again.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "See you again.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
OP
OP
bpm91

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
535
Solutions
7
Reaction score
62
Location
Brazil
this also happens for chest keys to open doors

Lua:
function onUse(cid, item, frompos, item2, topos)
queststatus = getPlayerStorageValue(cid,8125)
if queststatus == -1 then
    chave = doPlayerAddItem(cid,2091,1)
    setActionId(chave,3980)
    doPlayerSendTextMessage(cid,22,"You found a golden key!")
    setPlayerStorageValue(cid,8125,1)
else
    doPlayerSendTextMessage(cid,22,"It's empty.")
end
return 1
end

1650376042577.png
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,509
Solutions
260
Reaction score
4,467
I don't know, but maybe change setActionId(chave,3980) to chave:setActionId(3940)

you are trying to use a really old datapack with a new tfs, that is why
Post automatically merged:

I don't know, but maybe change setActionId(chave,3980) to chave:setActionId(3940)

you are trying to use a really old datapack with a new tfs, that is why
 
OP
OP
bpm91

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
535
Solutions
7
Reaction score
62
Location
Brazil
I have a doubt, the door when unlocked with the key I can only close using the key, I say like this example:
when you use the key on the door, it is free to open and close, but the key should only be used to unlock, you know? How do I make sure that when I use the key, it is unlocked?
Lua:
function onUse(cid, item, frompos, item2, topos)

if item.uid == 25285 then
    if item.itemid == 1212 or item.itemid == 1225 or item.itemid == 1227 or item.itemid == 1229 then
        if getPlayerStorageValue(cid, 25285) == 1 then
        pos = getPlayerPosition(cid)

            if pos.x == topos.x then
                if pos.y < topos.y then
                pos.y = topos.y + 0
                else
                pos.y = topos.y - 0
                end
            elseif pos.y == topos.y then
                if pos.x < topos.x then
                pos.x = topos.x + 0
                else
                pos.x = topos.x - 0
                end
        else
        doPlayerSendTextMessage(cid,22,'Please stand in front of the door.')
        return 1
        end
        doTransformItem(item.uid, item.itemid+1)
        doTeleportThing(cid,pos)
        else
        doPlayerSendTextMessage(cid,22,'It\'s Locked!')
        end
    else
        doPlayerSendTextMessage(cid,22,'Sorry, not possible.')
        end   
return 1
else
return 0
end
end

I wanted that when I unlock the door it can open and close normally, but when I use the key regardless of the position it locks again
 
Last edited:
Top