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

Quest System

Crunch

Premium User
Premium User
Joined
Jun 21, 2011
Messages
353
Reaction score
19
Location
England
Hi again,

I am using the quests.lua for annihilator chests that comes with 1.3. However when I use it again for another quest reward, ie PoI, I cant seem to make it work. Originally I just made a duplicate and edited the script and added a storage on lib/storages, and added the actionid's in the same way, but I'm guessing it wont work because the itemid is assigned to the original one? Do I need to include all quests in the original quests.lua, and if so would anybody be able to give me some pointers on how to add more, as what I have tried doesnt work. I can see the basics of how the premade annihilator one works, but I obivously dont see enough to add another one!!

Thanks
Post automatically merged:


found this and it seems to work
 
Last edited:
OP
Crunch

Crunch

Premium User
Premium User
Joined
Jun 21, 2011
Messages
353
Reaction score
19
Location
England
Further on to this, while testing I noticed that the player would not get the item if there inventory was full but they had spare capacity. I've changed the script slighty to the below, it seems to do everything just fine, but there is an error on the console

luaPlayerAddItemEx(). Item already has a parent

How can I get rid of this? Thanks


Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(item.actionid) > 0 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
    end

    local reward = item:getItem(0):clone()
    local playerCap = player:getFreeCapacity()
    local itemType = reward:getType()

    local count = reward:getCount()
    local article = count > 1 and count or "a"
    local name = count > 1 and reward:getPluralName() or itemType:getName()



    if player:addItemEx(reward) ~= RETURNVALUE_NOERROR then
        player:sendCancelMessage(player:getFreeCapacity() < reward:getWeight() and RETURNVALUE_NOTENOUGHCAPACITY or RETURNVALUE_NOTENOUGHROOM)
    else
        player:addItemEx(reward)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. article .. ' ' .. name .. '.')
        player:setStorageValue(item.actionid, 1)
        player:addAchievement("Three Pillars")
        player:setStorageValue(8500, 3)
    end
    return true
end
 

M0ustafa

1337
Senator
Joined
Mar 4, 2017
Messages
2,558
Solutions
314
Reaction score
1,126
Location
Egypt
Can you try this one? Only change YOURITEMID nothing more.
Lua:
local chests = {
    [9008] = {itemid = YOURITEMID1, count = 1},
    [9009] = {itemid = YOURITEMID2, count = 1},
    [9010] = {itemid = YOURITEMID3, count = 1},
    [9011] = {itemid = YOURITEMID4, count = 1}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if chests[item.uid] then
        
        if player:getStorageValue(item.actionid) > 0 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        end
        
        local chest = chests[item.uid]
        local itemType = ItemType(chest.itemid)
        if itemType then
            local article = itemType:getArticle()
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. (#article > 0 and article .. ' ' or '') .. itemType:getName() .. '.')
        end
        player:addItem(chest.itemid, chest.count)
        player:setStorageValue(item.actionid, 1)
        player:addAchievement("Three Pillars")
        player:setStorageValue(8500, 3)
    end
    return true
end
 
OP
Crunch

Crunch

Premium User
Premium User
Joined
Jun 21, 2011
Messages
353
Reaction score
19
Location
England
Can you try this one? Only change YOURITEMID nothing more.
Lua:
local chests = {
    [9008] = {itemid = YOURITEMID1, count = 1},
    [9009] = {itemid = YOURITEMID2, count = 1},
    [9010] = {itemid = YOURITEMID3, count = 1},
    [9011] = {itemid = YOURITEMID4, count = 1}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if chests[item.uid] then
       
        if player:getStorageValue(item.actionid) > 0 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        end
       
        local chest = chests[item.uid]
        local itemType = ItemType(chest.itemid)
        if itemType then
            local article = itemType:getArticle()
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. (#article > 0 and article .. ' ' or '') .. itemType:getName() .. '.')
        end
        player:addItem(chest.itemid, chest.count)
        player:setStorageValue(item.actionid, 1)
        player:addAchievement("Three Pillars")
        player:setStorageValue(8500, 3)
    end
    return true
end

Thanks, the item goes on the floor now instead of just no where, which is all good
 
Top