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

Too many start items on druid

zapo

Member
Joined
Nov 10, 2020
Messages
129
Solutions
3
Reaction score
11
when creating a new character the druid has too many items to start(2x the same items)
but only druid. is there a place other than startitems.lua items are set for the start?
tfs1.3

Lua:
local config = {
        [1] = {
                --equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, amulet of loss
                items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}},
                --container rope, shovel, mana potion, 10 platinum coin
                container = {{2120, 1}, {2554, 1}, {2152, 10}}
        },
        [2] = {
                --equipment spellbook, snakebite rod, magician's robe, mage hat, studded legs, leather boots, amulet of loss
                items = {{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}},
                --container rope, shovel, mana potion, 10 platinum coin
                container = {{2120, 1}, {2554, 1}, {2152, 10}}
        },
        [3] = {
                --equipment dwrven shield, 5 spear, ranger's cloak, ranger legs, legion helmet, amulet of loss
                items = {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2480, 1}},
                --container rope, shovel, health potion, bow, 50 arrow, 10 platinum coin
                container = {{2120, 1}, {2554, 1}, {2456, 1}, {2544, 50}, {2152, 10}}
        },
        [4] = {
                --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs, amulet of loss
                items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}},
                --container jagged sword, daramian mace, rope, shovel, health potion, 10 platinum coin
                container = {{8602, 1}, {2439, 1}, {2120, 1}, {2554, 1}, {2152, 10}}
        }
}
local startitems = CreatureEvent("startitems")
function startitems.onLogin(player)
    if player:getLastLoginSaved() ~= 0 then
        return true
    end
 
    local targetVocation = config[player:getVocation():getId()]
    if not targetVocation then
        return true
    end

    for i = 1, #targetVocation.items do
        player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
    end

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

    for i = 1, #targetVocation.container do
        backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
    end
    return true
end
startitems:register()
 
Solution
There might be items on the druid sample, or added to the characters when they are created, before they login.

You can try and check in the database / character creation code from php.

or if you don't care too much, you could simply add a check into this code, that removes all items from the character, before giving them the starter items.

Add this to line 32 before targetVocation
Lua:
local slotItem
for i = 1, 10 do
    slotItem = player:getSlotItem(i)
    if slotItem then
        slotItem:remove()
    end
end
There might be items on the druid sample, or added to the characters when they are created, before they login.

You can try and check in the database / character creation code from php.

or if you don't care too much, you could simply add a check into this code, that removes all items from the character, before giving them the starter items.

Add this to line 32 before targetVocation
Lua:
local slotItem
for i = 1, 10 do
    slotItem = player:getSlotItem(i)
    if slotItem then
        slotItem:remove()
    end
end
 
Solution
There might be items on the druid sample, or added to the characters when they are created, before they login.

You can try and check in the database / character creation code from php.

or if you don't care too much, you could simply add a check into this code, that removes all items from the character, before giving them the starter items.

Add this to line 32 before targetVocation
Lua:
local slotItem
for i = 1, 10 do
    slotItem = player:getSlotItem(i)
    if slotItem then
        slotItem:remove()
    end
end
Can this code considers interior of backpacks? What about this scenario, when player bought Premium Store Items before login?
 
i have the same script and it has a strange problem for example certain item id designed in table are not being given to player
and if i add the items in other vocation table they appear i know that is not something relted to comma or a bracket
can somebody help me review what is broken?
Lua:
-- Without Rookgaard
local config = {
    [1] = {
        --equipment
        items = {{2456, 1}, {2656, 1}, {2491, 1}, {2647, 1}, {2195, 1}, {2546, 100}, {2171, 1}},
        --container
        container = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}, {2006, 7}, {2261, 1}, {2305, 1}, {2293, 1}, {2268, 1}, {2304, 1}, {2273, 1}}
    },
    [2] = {
        --equipment
        items = {{2456, 1}, {2656, 1}, {2491, 1}, {2647, 1}, {2195, 1}, {2546, 100}, {2171, 1}},
        --container
        container = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}, {2006, 7}, {2261, 1}, {2305, 1}, {2293, 1}, {2268, 1}, {2304, 1}, {2273, 1}}
    },
    [3] = {
        --equipment
        items = {{2455, 1}, {2476, 1}, {2475, 1}, {2647, 1}, {2195, 1}, {2543, 100}, {2171, 1}},
        --container rope, shovel, health potion, bow, 50 arrow
        container = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}, {2006, 7}, {2261, 1}, {2305, 1}, {2293, 1}, {2268, 1}, {2304, 1}, {2273, 1}}
    },
    [4] = {
        --equipment
        items = {{2536, 1}, {2407, 1}, {2487, 1}, {2497, 1}, {2477, 1}, {2195, 1}, {2562, 1}, {2171, 1}},
        --container rope, shovel, health potion, bow, 50 arrow
        container = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}, {2006, 7}, {2261, 1}, {2305, 1}, {2304, 1}, {2273, 1}}
    }
}

function onLogin(player)
    local targetVocation = config[player:getVocation():getId()]
    if not targetVocation then
        return true
    end

    if player:getLastLoginSaved() ~= 0 then
        return true
    end

    for i = 1, #targetVocation.items do
        player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
    end

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

    for i = 1, #targetVocation.container do
        backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
    end
    return true
end


edited
Lua:
-- Without Rookgaard
local config = {
    [1] = {
        --equipment
        items = {{2456, 1}, {2656, 1}, {2491, 1}, {2647, 1}, {2195, 1}, {2546, 100}, {2171, 1}},
        container = {{2000, 1}},
        container = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}},
        container = {{2006, 7}, {2261, 1}, {2305, 1}, {2293, 1}, {2268, 1}, {2304, 1}, {2273, 1}, {2313, 1}}
    },
    [2] = {
        --equipment
        items = {{2456, 1}, {2656, 1}, {2491, 1}, {2647, 1}, {2195, 1}, {2546, 100}, {2171, 1}},
        container = {{}},
        container = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}},
        container = {{2006, 7}, {2261, 1}, {2305, 1}, {2293, 1}, {2268, 1}, {2304, 1}, {2273, 1}, {2313, 1}, {2278, 1}}
    },
    [3] = {
        --equipment
        items = {{2455, 1}, {2656, 1}, {2475, 1}, {2647, 1}, {2195, 1}, {2543, 100}, {2171, 1}},
        container = {{2000, 1}},
        container = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}},
        container = {{2006, 7}, {2261, 1}, {2305, 1}, {2293, 1}, {2268, 1}, {2304, 1}, {2273, 1}, {2313, 1}}
    },
    [4] = {
        --equipment
        items = {{2536, 1}, {2407, 1}, {2656, 1}, {2497, 1}, {2647, 1}, {2195, 1}, {2562, 1}, {2171, 1}},
        container = {{2000, 1}},
        container = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}},
        container = {{2006, 7}, {2261, 1}, {2305, 1}, {2293, 1}, {2304, 1}, {2273, 1}, {2313, 1}, {2436, 1}, {2432, 1}}
    }
}


function onLogin(player)
    local targetVocation = config[player:getVocation():getId()]
    if not targetVocation then
        return true
    end

    if player:getLastLoginSaved() ~= 0 then
        return true
    end

    if (player:getSlotItem(CONST_SLOT_LEFT)) then
        return true
    end

    for i = 1, #targetVocation.items do
        player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
    end

    local backpack = player:getVocation():getId() == 0 and player:addItem(1987) or player:addItem(1988)
    if not backpack then
        return true
    end

    local bag = player:getVocation():getId() ==0 and player:addItem(3939)
    if backpack then
        return true
    end

    for i = 1, #targetVocation.container do
        backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
        bag:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
    end
    return true
end
 
Last edited:
Back
Top