• 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.3 quest with key number reward problem

Berciq

Veteran OT User
Joined
Aug 7, 2018
Messages
236
Reaction score
320
Location
Poland
Hey, I have a problem, i'm not scripter or programmer, tried many ways copying on what people published but i cannot: create quest -> open chest and get key with action ID 4600

I have tfs 1.3, probably with something missing in libraries. Everything else is working for me but i cannot force script to add action id for reward you got from chest. Hence key number is 0 and I wish it to be 4600
I tried different solutions but i have no idea where to look for examples of quests for tfs 1.3 because hardly none posted script works for me. Scripts from 1.2 should work on 1.3?, because for me they doesn't.

Script:

function onUse(cid, item, frompos, item2, topos)
if item.uid == 50005 then --key test--
if getPlayerStorageValue(cid,50005) == -1 then
doPlayerSendTextMessage(cid,22,"You have found a silver key in the drawer. They say it can open not only one or two doors on this isle...")
doPlayerAddItem(cid,2088)
doitem:setActionId(4600)
setPlayerStorageValue(cid,50005)
else
doPlayerSendTextMessage(cid,22,"This one is empty.")
end
end
return TRUE
end
 
Solution
read this before posting code again: How to display CODE properly in your post

you need to save the item in a variable
doitem is nil because you don't save addItem into a variable
Lua:
local doitem = doPlayerAddItem(cid, 2088)
i've fixed your code up (and updated it to 1.3 code style)
you shouldn't even need to check for item.uid == 50005, just register the chest to uid="50005" in actions.xml so you don't have to bother checking for it in the script for no reason
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.uid == 50005 then --key test--
        if player:getStorageValue(50005) == -1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a silver key in the drawer...
read this before posting code again: How to display CODE properly in your post

you need to save the item in a variable
doitem is nil because you don't save addItem into a variable
Lua:
local doitem = doPlayerAddItem(cid, 2088)
i've fixed your code up (and updated it to 1.3 code style)
you shouldn't even need to check for item.uid == 50005, just register the chest to uid="50005" in actions.xml so you don't have to bother checking for it in the script for no reason
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.uid == 50005 then --key test--
        if player:getStorageValue(50005) == -1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a silver key in the drawer. They say it can open not only one or two doors on this isle...")
            local key = player:addItem(2088)
            key:setActionId(4600)
            player:setStorageValue(50005, 1)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "This one is empty.")
        end
    end
    return true
end
 
Solution
Back
Top