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

Solved Adding text into a book quest

Jalorius

Intermediate OT User
Joined
Sep 2, 2015
Messages
62
Reaction score
103
I've been trying to figure this out, but been having slight difficulty understanding why the script does not work. It works to collect the book, but there is no text inside the book. Is there a way to get this to function properly? I am using TFS 1.2 and my client version is 10.77. any ideas?

Code:
 function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemWeight = (ItemType(1955):getWeight())
    local playerCap = player:getFreeCapacity()
    if player:getStorageValue(2322) == -1 then
        if playerCap >= itemWeight then
            if item.uid == 3010 then
                doSetItemText(player:addItem(1955, 1), "Day 1: Wow! I finally get to leave the village and explore the world! I am so excited to get started on my adventures! Day 2: I ventured down into a cave, wow, some neat cave drawings! I have never seen anything like this in my life! Day 3: My lungs are feeling heavy and *cough* *cough* I can't move very well *cough*. I don't know if I will ever *cough* make it...")
                player:setStorageValue(2322, 1)
                player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a Book.")
        end
            elseif
                playerCap < itemWeight then
                player:sendTextMessage(MESSAGE_INFO_DESCR, "You do not have enough capacity.")
            end
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There is nothing here.")
        end
        return true
end
 
Solution
Lua:
local book = player:addItem(1955, 1)
book:setAttribute("text", "Day 1: Wow! I finally get to leave the village and explore the world! I am so excited to get started on my adventures! Day 2: I ventured down into a cave, wow, some neat cave drawings! I have never seen anything like this in my life! Day 3: My lungs are feeling heavy and *cough* *cough* I can't move very well *cough*. I don't know if I will ever *cough* make it...")
Try this one
Lua:
 function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemWeight = (ItemType(1955):getWeight())
    local playerCap = player:getFreeCapacity()
    if player:getStorageValue(2322) == -1 then
        if playerCap >= itemWeight then
            if item.uid == 3010 then
                local p = Player(cid)
                local book = p:addItem(1955, 1)   
                doSetItemText(book, "Day 1: Wow! I finally get to leave the village and explore the world! I am so excited to get started on my adventures! Day 2: I ventured down into a cave, wow, some neat cave drawings! I have never seen anything like this in my life! Day 3: My lungs are feeling heavy and *cough* *cough* I can't move very well *cough*. I don't know if I will ever *cough* make it...")
                player:setStorageValue(2322, 1)
                player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a Book.")
        end
            elseif
                playerCap < itemWeight then
                player:sendTextMessage(MESSAGE_INFO_DESCR, "You do not have enough capacity.")
            end
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There is nothing here.")
        end
        return true
end
 
I gave it a whirl but still a no go. Also with this code you put together, I got an error from the line

Code:
local p = Player(cid)

So I just removed and it worked again. But still without text in the book itself.
 
Lua:
local book = player:addItem(1955, 1)
book:setAttribute("text", "Day 1: Wow! I finally get to leave the village and explore the world! I am so excited to get started on my adventures! Day 2: I ventured down into a cave, wow, some neat cave drawings! I have never seen anything like this in my life! Day 3: My lungs are feeling heavy and *cough* *cough* I can't move very well *cough*. I don't know if I will ever *cough* make it...")
 
Solution
Lua:
 function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemWeight = (ItemType(1955):getWeight())
    local playerCap = player:getFreeCapacity()
    if player:getStorageValue(2322) == -1 then
        if playerCap >= itemWeight then
            if item.uid == 3010 then
                local book = player:addItem(1955, 1) 
                book:setAttribute(ITEM_ATTRIBUTE_TEXT, "Day 1: Wow! I finally get to leave the village and explore the world! I am so excited to get started on my adventures! Day 2: I ventured down into a cave, wow, some neat cave drawings! I have never seen anything like this in my life! Day 3: My lungs are feeling heavy and *cough* *cough* I can't move very well *cough*. I don't know if I will ever *cough* make it...")
                player:setStorageValue(2322, 1)
                player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a Book.")
        end
            elseif
                playerCap < itemWeight then
                player:sendTextMessage(MESSAGE_INFO_DESCR, "You do not have enough capacity.")
            end
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There is nothing here.")
        end
        return true
end

Try this

Edit: rip didnt see that evil hero solved it b4 me ^^,
 
Back
Top