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

Lua Quest by Mapeditor

witze15

New Member
Joined
Mar 21, 2010
Messages
29
Reaction score
1
Hey,

is there a way to fill a Chest on the Mapeditor and give this Chest a AID or UID and after that by Scripting or maybe one Universal Script to give the Items Back once?

At the Moment i "fill" the Chest by a Quest script like "onUse", have a look for the CreatureStorage and if that negativ than i give him the Items by
doPlayerAddItem(cid, 2475, 1)

and set the Storage to 1 or maybe to the UID when i have a Choosing Chest. (2-5 Chest when you can Choose about one Item)

The Idea is from a Map that i have seen, the Mapper ussed Action ID's and Unique ID's and filled the Chest.
But i can't find an Script for that.. :/

Can you Help me, Please?

Greetings
Daniel
 
Actions.xml
Code:
    <action actionid="22001" script="reward.lua"/>

Script from otland
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local chest = Container(item.uid)

    if not chest then
        return true
    end

    local uniqueid = chest:getUniqueId()
    if player:getStorageValue(uniqueid) == -2 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
        return true
    end

    local reward = nil
    local start = player:getStorageValue(uniqueid) == -1 and 0 or player:getStorageValue(uniqueid)

    for i = start, chest:getSize() do
        reward = chest:getItem(i)
        if not reward then
            break
        end

        if reward:getWeight() > player:getFreeCapacity() then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found a ' .. reward:getName() .. ' weighing ' .. reward:getWeight()/100 .. ' oz it\'s too heavy.')
            player:setStorageValue(uniqueid, i)
            break
        else
            local reward_container = Container(reward:getUniqueId())
            if reward_container then
                reward_container = reward_container:clone()
                reward_container:moveTo(player)
            else
                player:addItem(reward:getId(), reward:getCount())
            end
            local reward_msg = reward:getArticle() .. ' ' .. reward:getName()
            if reward:getCount() > 1 then
                reward_msg = reward:getCount() .. ' ' .. reward:getPluralName()
            end

            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. reward_msg .. '.')

            player:setStorageValue(uniqueid, -2)
        end
    end

    return true
end

Put AID in corpse/chest (22001) and put items in a corpse/box/chest etc. Ofc you need to set a different UIDs.
 
Back
Top