• 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 1.2 ] Key and Door

DiegoRulez

Member
Joined
Apr 16, 2012
Messages
93
Reaction score
11
Location
Feira de Santana - Brasil
I need to add the key number.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == 1001 then
        queststatus = getPlayerStorageValue(cid, 1001)
        if queststatus == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a morning star.")
            doAddContainerItem(cid, 2088, 1)
            setPlayerStorageValue(cid, 1001, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
        end
    end

    return true
end
I'm using this script, but I can use another one.

All the keys use the ID 2088 .. But the number of them in game is different ..
Examples:
Key 4501 - Tibia Wiki
Key 4502 - Tibia Wiki

Same thing for the script I need by on the port, it needs to "read" that number
At the moment it is like this:
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getStorageValue(Storage.AnnihilatorDone) ~= 1 then
if item.itemid == 5114 then
player:teleportTo(toPosition, true)
item:transform(item.itemid + 1)
end
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The door seems to be sealed against unwanted intruders.")
end
return true
end

Sorry the bad english.
 
Solution
On door you have to make action script with this key with this id.
If item:getActionId() == someactionid and target:getId() == doorId then
do this
else
do this
end
How do I do that? I do not know how to program, I'm starting now
How do they get the key(s)?
If its through a script, if the key is generated when they click on a box or whatever that is where you assign the key an action id and then when the player goes to use the key on the door that is when you compare the action id. You will also need to assign a script in actions.xml for each actionid.
 
local key = player:addItem(id, 1)
if key then
key:setActionId(actionId)
end

Written via phone so no code tags and tabbing, but thats the idea how you set action id to item.
 
The first part, the quest, I got with this code:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == 1002 then
        queststatus = getPlayerStorageValue(cid, 1002)
        if queststatus == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a key.")
            doSetItemActionId(doPlayerAddItem(cid, 2088, 1), 4501)          
            setPlayerStorageValue(cid, 1002, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
        end
    end

    return true
end

I still could not make the door recognize the key number.
 
On door you have to make action script with this key with this id.
If item:getActionId() == someactionid and target:getId() == doorId then
do this
else
do this
end
 
Solution
Back
Top