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

Small Problem with the Codes here

alltus

Active Member
Joined
Aug 5, 2020
Messages
49
Reaction score
31
Hey guys, I'm using 10.98 FTS 1.2
I'm having a little problem with a code here. I want a chest with uID 60001 to give x,y,z items and, after that, stop giving the items.
But when I use the chest, it still giving me the items, and I don't know exactly what I should do here to fix it.
The code is:
Lua:
function onUse(cid, item, frompos, item2, topos)
    if item.uid == 60001 then
        queststatus = getPlayerStorageValue(cid, 60001)
        if queststatus == -1 or queststatus == 0 then
            for i = 1, 10 do
                if getPlayerSlotItem(cid, i).itemid > 0 and i ~= 3 then
                    doPlayerSendTextMessage(cid, 22, "You must get rid of all your equipment!")
                    return false
                end
            end
            doPlayerSendTextMessage(cid, 22, "You have obtained the Paladin Gear!")
            doPlayerAddItem(cid,1988,1)
            doPlayerAddItem(cid,2389,5)
            doPlayerAddItem(cid,2456,1)
            doPlayerAddItem(cid,2525,1)
            doPlayerAddItem(cid,2544,100)
            doPlayerAddItem(cid,2660,1)
            doPlayerAddItem(cid,8923,1)
            doPlayerAddItem(cid,2643,1)
            doPlayerAddItem(cid,2461,1)
            doPlayerSetStorage(cid,60001,1)
            setPlayerStorageValue(cid, 60001, 1)
        else
            doPlayerSendTextMessage(cid, 22, "It is empty.")
        end
    else
        return false
    end
    return true
end
 
Solution
something like this maybe:

Lua:
local config = {
    [60001] = {
        items = {
            {2389, 5},
            {2456},
            {2525},
            {2544, 100},
            {2660},
            {8923},
            {2643},
            {2461}
        }
    },
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local useItem = config[item.uid]
    if not useItem then
        return true
    end
    
    if player:getStorageValue(60001) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        return true
    end
    
    for i = 1, 10 do
        if player:getSlotItem(i).itemid > 0 and i ~= 3 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must get rid of all...

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,902
Solutions
197
Reaction score
3,714
something like this maybe:

Lua:
local config = {
    [60001] = {
        items = {
            {2389, 5},
            {2456},
            {2525},
            {2544, 100},
            {2660},
            {8923},
            {2643},
            {2461}
        }
    },
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local useItem = config[item.uid]
    if not useItem then
        return true
    end
    
    if player:getStorageValue(60001) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        return true
    end
    
    for i = 1, 10 do
        if player:getSlotItem(i).itemid > 0 and i ~= 3 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must get rid of all your equipment!")
            return true
        end
    end

    local container = player:addItem(1988)
    if not container then
        return true
    end

    for i = 1, #useItem.items do
        container:addItem(useItem.items[i][1], useItem.items[i][2] or 1)
    end

    player:setStorageValue(60001, 1)
    local itemType = ItemType(container.itemid)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have obtained the Paladin Gear!")
    return true
end
 
Solution

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,902
Solutions
197
Reaction score
3,714
Top