JuggaloUser
New Member
- Joined
- Jan 10, 2013
- Messages
- 62
- Reaction score
- 1
Ok so I got a firstitems.lua and it works fine except that it doesnt add the items to a bp because players don't start with a bp.... here is the code, I am sure I isolated where it needs fixed but I am still new to otserv programming, and scripting, haven't done anything since 7.6....
Lua code:
local firstItems_storage = 30001
local commonItems = {
{itemid=2554, inContainer = TRUE}, -- shovel
{itemid=2120, inContainer = TRUE}, -- rope
{itemid=2152, count=20, inContainer = TRUE}, -- 2 crystal coins
{itemid=2789, count=20, inContainer = TRUE}, -- brown mushrom
{itemid=2643} -- leather boots
}
local firstItems = {
{ -- Sorcerer
{itemid=1988, container = TRUE}, -- backpack
{itemid=2175}, -- spellbook
{itemid=2190}, -- wand of vortex
{itemid=8819}, -- magician's robe
{itemid=8820}, -- mage hat
{itemid=2468} -- studded legs
},
{ -- Druid
{itemid=1988, container = TRUE}, -- backpack
{itemid=2175}, -- spellbook
{itemid=2182}, -- snakebite rod
{itemid=8819}, -- magician's robe
{itemid=8820}, -- mage hat
{itemid=2468} -- studded legs
},
{ -- Paladin
{itemid=1988, container = TRUE}, -- backpack
{itemid=2456}, -- bow
{itemid=2544, count = 100}, -- 100 arrows
{itemid=2660}, -- ranger's cloak
{itemid=2480}, -- legion helmet
{itemid=8923} -- ranger legs
},
{ -- Knight
{itemid=1988, container = TRUE}, -- backpack
{itemid=2439, inContainer = TRUE}, -- daramanian mace
{itemid=8601, inContainer = TRUE}, -- steel axe
{itemid=2509}, -- steel shield
{itemid=8602}, -- jagged sword
{itemid=2465}, -- brass armor
{itemid=2481}, -- soldier helmet
{itemid=2478} -- brass legs
}
}
for _, items in ipairs(firstItems) do
for _, item in ipairs(commonItems) do
table.insert(items, item)
end
end
function onLogin(cid)
if getPlayerGroupId(cid) < 2 and getPlayerStorageValue(cid, firstItems_storage) <= 0 then
local currvoc = getPlayerVocation(cid)
local vocation = 5 > currvoc and currvoc or currvoc - 4
local giveItems = firstItems[vocation]
if giveItems then
for _, v in ipairs(giveItems) do
if v.container == TRUE then
backpack = doPlayerAddItem(cid, v.itemid, 1)
elseif v.inContainer == TRUE then
doAddContainerItem(backpack, v.itemid, v.count or 1)
else
doPlayerAddItem(cid, v.itemid, v.count or 1)
end
end
end
setPlayerStorageValue(cid, firstItems_storage, 1)
end
return TRUE
end
I am sure the problem is here...
if v.container == TRUE then
backpack = doPlayerAddItem(cid, v.itemid, 1)
elseif v.inContainer == TRUE then
doAddContainerItem(backpack, v.itemid, v.count or 1)
else
doPlayerAddItem(cid, v.itemid, v.count or 1)
end
little help please? Or does anyone know how I can alter the samples to include them all starting with bp so this works?
- - - Updated - - -
Oh also the eq don't go in the bp or equip the character with the items....
Lua code:
local firstItems_storage = 30001
local commonItems = {
{itemid=2554, inContainer = TRUE}, -- shovel
{itemid=2120, inContainer = TRUE}, -- rope
{itemid=2152, count=20, inContainer = TRUE}, -- 2 crystal coins
{itemid=2789, count=20, inContainer = TRUE}, -- brown mushrom
{itemid=2643} -- leather boots
}
local firstItems = {
{ -- Sorcerer
{itemid=1988, container = TRUE}, -- backpack
{itemid=2175}, -- spellbook
{itemid=2190}, -- wand of vortex
{itemid=8819}, -- magician's robe
{itemid=8820}, -- mage hat
{itemid=2468} -- studded legs
},
{ -- Druid
{itemid=1988, container = TRUE}, -- backpack
{itemid=2175}, -- spellbook
{itemid=2182}, -- snakebite rod
{itemid=8819}, -- magician's robe
{itemid=8820}, -- mage hat
{itemid=2468} -- studded legs
},
{ -- Paladin
{itemid=1988, container = TRUE}, -- backpack
{itemid=2456}, -- bow
{itemid=2544, count = 100}, -- 100 arrows
{itemid=2660}, -- ranger's cloak
{itemid=2480}, -- legion helmet
{itemid=8923} -- ranger legs
},
{ -- Knight
{itemid=1988, container = TRUE}, -- backpack
{itemid=2439, inContainer = TRUE}, -- daramanian mace
{itemid=8601, inContainer = TRUE}, -- steel axe
{itemid=2509}, -- steel shield
{itemid=8602}, -- jagged sword
{itemid=2465}, -- brass armor
{itemid=2481}, -- soldier helmet
{itemid=2478} -- brass legs
}
}
for _, items in ipairs(firstItems) do
for _, item in ipairs(commonItems) do
table.insert(items, item)
end
end
function onLogin(cid)
if getPlayerGroupId(cid) < 2 and getPlayerStorageValue(cid, firstItems_storage) <= 0 then
local currvoc = getPlayerVocation(cid)
local vocation = 5 > currvoc and currvoc or currvoc - 4
local giveItems = firstItems[vocation]
if giveItems then
for _, v in ipairs(giveItems) do
if v.container == TRUE then
backpack = doPlayerAddItem(cid, v.itemid, 1)
elseif v.inContainer == TRUE then
doAddContainerItem(backpack, v.itemid, v.count or 1)
else
doPlayerAddItem(cid, v.itemid, v.count or 1)
end
end
end
setPlayerStorageValue(cid, firstItems_storage, 1)
end
return TRUE
end
I am sure the problem is here...
if v.container == TRUE then
backpack = doPlayerAddItem(cid, v.itemid, 1)
elseif v.inContainer == TRUE then
doAddContainerItem(backpack, v.itemid, v.count or 1)
else
doPlayerAddItem(cid, v.itemid, v.count or 1)
end
little help please? Or does anyone know how I can alter the samples to include them all starting with bp so this works?
- - - Updated - - -
Oh also the eq don't go in the bp or equip the character with the items....