johnsamir
Advanced OT User
Hello im trying to edit firstitems.lua script i want to add new containers so it will be more organized. i have edited im not getting errors in console, at some points it used to work but it does not anymore
the script is working, looks like this
and the edited one looks like this, is not giving any items inside containers just the inventory items
the script is working, looks like this
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}, {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}, {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 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}, {2313, 1}}
},
[4] = {
--equipment
items = {{2536, 1}, {2407, 1}, {2656, 1}, {2497, 1}, {2647, 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}, {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
for i = 1, #targetVocation.container do
backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
end
return true
end
and the edited one looks like this, is not giving any items inside containers just the inventory items
Code:
-- Without Rookgaard
local config = {
[1] = {
--equipment
items = {{2456, 1}, {2656, 1}, {2491, 1}, {2647, 1}, {2195, 1}, {2546, 100}, {2171, 1}},
container = {{2000, 1}},
container2 = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}},
container1 = {{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 = {{}},
container2 = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}},
container1 = {{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}},
container2 = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}},
container1 = {{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}},
container2 = {{2120, 1}, {2554, 1}, {2789, 100}, {2167, 1}, {2169, 1}},
container1 = {{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 player:addItem(1988)
if not backpack then
return true
end
local backpack = player:getVocation():getId() == 0 player:addItem(3939)
if backpack then
return true
end
local bag = player:getVocation():getId() == 0 player:addItem(3940)
if backpack then
return true
end
for i = 1, #targetVocation.container do
for i = 1, #targetVocation.container1 do
for i = 1, #targetVocation.container2 do
backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
backpack:addItem(targetVocation.container1[i][1], targetVocation.container1[i][2])
bag:addItem(targetVocation.container2[i][1], targetVocation.container2[i][2])
end
end
end
return true
end