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

Firstitems.lua - How can i add runes inside a backpack

opsdan

New Member
Joined
May 7, 2010
Messages
16
Solutions
1
Reaction score
0
Hi everyone.
I've been editing the creaturescripts/items.lua for hours to set up the initial items for a character, and I want to add a backpack with runes inside, but I haven't had any success so far.
The current code looks like this:

local commonItems = {
-- ITEMS ALL VOC RECEIVE
{itemid=2120, count=1}, -- rope
{itemid=2554, count=1}, -- shovel
{itemid=2789, count=100}, -- brown mushroom
{itemid=2006,7, count=7}, -- vial of manafluid
{itemid=1996, count=1}, -- greyb
{itemid=1993, count=1}, -- redb
{itemid=1995, count=1}, -- blueb
{itemid=1994, count=1}, -- purpleb
}
local firstItems = {
{ -- SORC ITEMS
{itemid=2323, count=1}, -- hotm
{itemid=2656, count=1}, -- blue robe
{itemid=2456, count=1}, -- bow
{itemid=2546, count=1}, -- burst arrow
{itemid=2488, count=1}, -- crown legs
{itemid=2195, count=1}, -- boh
{itemid=2123, count=1}, -- rots
{itemid=2173, count=1}, -- aol infinito
{itemid=2260, count=1}, -- blank rune
{itemid=2273, count=1}, -- ultimate healing rune
{itemid=2268, count=1}, -- sudden death rune
{itemid=2304, count=1}, -- great fireball rune
{itemid=2293, count=1}, -- magic wall rune
{itemid=2286, count=1}, -- poison bomb rune
{itemid=2262, count=1}, -- energy bomb rune
{itemid=2305, count=1}, -- firebomb rune
{itemid=2261, count=1}, -- destroy field rune
{itemid=2310, count=1}, -- desintegrate rune
},
{ -- DRUID ITEMS
{itemid=2323, count=1}, -- hotm
{itemid=2656, count=1}, -- blue robe
{itemid=2456, count=1}, -- bow
{itemid=2546, count=1}, -- burst arrow
{itemid=2488, count=1}, -- crown legs
{itemid=2195, count=1}, -- boh
{itemid=2123, count=1}, -- rots
{itemid=2173, count=1}, -- aol infinito
{itemid=2260, count=1}, -- blank rune
{itemid=2273, count=1}, -- ultimate healing rune
{itemid=2268, count=1}, -- sudden death rune
{itemid=2304, count=1}, -- great fireball rune
{itemid=2278, count=1}, -- paralyze rune
{itemid=2293, count=1}, -- magic wall rune
{itemid=2286, count=1}, -- poison bomb rune
{itemid=2262, count=1}, -- energy bomb rune
{itemid=2305, count=1}, -- firebomb rune
{itemid=2261, count=1}, -- destroy field rune
{itemid=2310, count=1}, -- desintegrate rune
},
{ -- PALADIN ITEMS
{itemid=2498, count=1}, -- rh
{itemid=2656, count=1}, -- blue robe
{itemid=2455, count=1}, -- crossbow
{itemid=2547, count=1}, -- pbow
{itemid=2488, count=1}, -- crown legs
{itemid=2195, count=1}, -- boh
{itemid=2123, count=1}, -- rots
{itemid=2173, count=1}, -- aol infinito
{itemid=2273, count=1}, -- ultimate healing rune
{itemid=2268, count=1}, -- sudden death rune
{itemid=2293, count=1}, -- magic wall rune
{itemid=2286, count=1}, -- poison bomb rune
{itemid=2262, count=1}, -- energy bomb rune
{itemid=2305, count=1}, -- firebomb rune
{itemid=2261, count=1}, -- destroy field rune
{itemid=2310, count=1}, -- desintegrate rune
},
{ -- KNIGHT ITEMS
{itemid=2493, count=1}, -- dh
{itemid=2472, count=1}, -- mpa
{itemid=2514, count=1}, -- mms
{itemid=2470, count=1}, -- golden legs
{itemid=2195, count=1}, -- boh
{itemid=2123, count=1}, -- gold ring
{itemid=2173, count=1}, -- aol infinito
{itemid=2431, count=1}, -- sca
{itemid=2400, count=1}, -- sov
{itemid=2421, count=1}, -- thammer
{itemid=2273, count=1}, -- ultimate healing rune
{itemid=2293, count=1}, -- magic wall rune
{itemid=2286, count=1}, -- poison bomb rune
{itemid=2262, count=1}, -- energy bomb rune
{itemid=2305, count=1}, -- firebomb rune
{itemid=2261, count=1}, -- destroy field rune
{itemid=2310, count=1}, -- desintegrate rune
}
}
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 then
if getPlayerStorageValue(cid, 90808) < 1 then
--[[local backpack = ]]doPlayerAddItem(cid, 1988, TRUE)
local giveItems = firstItems[getPlayerVocation(cid)]
if giveItems then
for _, v in ipairs(giveItems) do
--doAddContainerItem(backpack, v.itemid, v.count or 1)
doPlayerAddItem(cid, v.itemid, v.count or 1)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You received your first items depending on your vocation.")
end
setPlayerStorageValue(cid, 90808, 1)
end
end
return true
end

Thanks for the help!
 
Solution
Solved!

For me, it worked to use the firstitems.lua below. But keep in mind that it only worked with the SQLite database; I couldn't implement it with MySQL.

function onLogin(cid)
if getPlayerGroupId(cid) == 1 and getPlayerStorageValue(cid, 50002) == -1 then

if isSorcerer(cid) then
local bag = doPlayerAddItem(cid, 1988, 1)
doPlayerAddItem(cid, 2323, 1) -- hotm
doPlayerAddItem(cid, 2656, 1) -- blue robe
doPlayerAddItem(cid, 2456, 1) -- bow
doPlayerAddItem(cid, 2546, 1) -- burst arrow
doPlayerAddItem(cid, 2488, 1) -- crown legs
doPlayerAddItem(cid, 2195, 1) -- boh
doPlayerAddItem(cid, 2123, 1) -- rots...
I'd just do something easy (but working) and then try to make it more complex, like:

local first items = {a, b, c} - for all vocations
function onlogin
if player getlastloginsaved = 0 then
player additem (first items, 1)
if vocation X
then
player:additem(bp, 1):additem (rune,1) <- and so on with other items in bp
if voc Y
then
(repeat adding items)


But, when it comes to your code:

LUA:
local commonItems = {
-- ITEMS ALL VOC RECEIVE
{itemid=2120, count=1}, -- rope
local firstItems = {
{ -- SORC ITEMS
{itemid=2323, count=1}, -- hotm
},
{ -- DRUID ITEMS
{itemid=2323, count=1}, -- hotm
{ -- PALADIN ITEMS
{itemid=2498, count=1}, -- rh
},
{ -- KNIGHT ITEMS
{itemid=2493, count=1}, -- dh
}
You did not specify really that those are sorc items, those are druid items and those are knight items. You've just added a comment.

What you want is:
LUA:
local firstItems = {
    sorcerer = {
        {itemid=2323, count=1}, -- hotm
        {itemid=2656, count=1}, -- blue robe
        {itemid=2456, count=1}, -- bow
        {itemid=2546, count=1}, -- burst arrow
        {itemid=2488, count=1}, -- crown legs
        {itemid=2195, count=1}, -- boh
        {itemid=2123, count=1}, -- rots
        {itemid=2173, count=1}, -- aol infinito
        {itemid=2260, count=1}, -- blank rune
        {itemid=2273, count=1}, -- ultimate healing rune
        {itemid=2268, count=1}, -- sudden death rune
        {itemid=2304, count=1}, -- great fireball rune
        {itemid=2293, count=1}, -- magic wall rune
        {itemid=2286, count=1}, -- poison bomb rune
        {itemid=2262, count=1}, -- energy bomb rune
        {itemid=2305, count=1}, -- firebomb rune
        {itemid=2261, count=1}, -- destroy field rune
        {itemid=2310, count=1}, -- desintegrate rune
    },
    druid = {
        {itemid=2323, count=1}, -- hotm
        {itemid=2656, count=1}, -- blue robe
        {itemid=2456, count=1}, -- bow
        {itemid=2546, count=1}, -- burst arrow
        {itemid=2488, count=1}, -- crown legs
        {itemid=2195, count=1}, -- boh
        {itemid=2123, count=1}, -- rots
        {itemid=2173, count=1}, -- aol infinito
        {itemid=2260, count=1}, -- blank rune
        {itemid=2273, count=1}, -- ultimate healing rune
        {itemid=2268, count=1}, -- sudden death rune
        {itemid=2304, count=1}, -- great fireball rune
        {itemid=2278, count=1}, -- paralyze rune
        {itemid=2293, count=1}, -- magic wall rune
        {itemid=2286, count=1}, -- poison bomb rune
        {itemid=2262, count=1}, -- energy bomb rune
        {itemid=2305, count=1}, -- firebomb rune
        {itemid=2261, count=1}, -- destroy field rune
        {itemid=2310, count=1}, -- desintegrate rune
    },
    paladin = {
        {itemid=2498, count=1}, -- rh
        {itemid=2656, count=1}, -- blue robe
        {itemid=2455, count=1}, -- crossbow
        {itemid=2547, count=1}, -- pbow
        {itemid=2488, count=1}, -- crown legs
        {itemid=2195, count=1}, -- boh
        {itemid=2123, count=1}, -- rots
        {itemid=2173, count=1}, -- aol infinito
        {itemid=2273, count=1}, -- ultimate healing rune
        {itemid=2268, count=1}, -- sudden death rune
        {itemid=2293, count=1}, -- magic wall rune
        {itemid=2286, count=1}, -- poison bomb rune
        {itemid=2262, count=1}, -- energy bomb rune
        {itemid=2305, count=1}, -- firebomb rune
        {itemid=2261, count=1}, -- destroy field rune
        {itemid=2310, count=1}, -- desintegrate rune
    },
    knight = {
        {itemid=2493, count=1}, -- dh
        {itemid=2472, count=1}, -- mpa
        {itemid=2514, count=1}, -- mms
        {itemid=2470, count=1}, -- golden legs
        {itemid=2195, count=1}, -- boh
        {itemid=2123, count=1}, -- gold ring
        {itemid=2173, count=1}, -- aol infinito
        {itemid=2431, count=1}, -- sca
        {itemid=2400, count=1}, -- sov
        {itemid=2421, count=1}, -- thammer
        {itemid=2273, count=1}, -- ultimate healing rune
        {itemid=2293, count=1}, -- magic wall rune
        {itemid=2286, count=1}, -- poison bomb rune
        {itemid=2262, count=1}, -- energy bomb rune
        {itemid=2305, count=1}, -- firebomb rune
        {itemid=2261, count=1}, -- destroy field rune
        {itemid=2310, count=1}, -- desintegrate rune
    }

Then this: local giveItems = firstItems[getPlayerVocation(cid)]
will trigger succesfuly.

Not sure if anything else is wrong or not; that's what i noticed at first.
 
Solved!

For me, it worked to use the firstitems.lua below. But keep in mind that it only worked with the SQLite database; I couldn't implement it with MySQL.

function onLogin(cid)
if getPlayerGroupId(cid) == 1 and getPlayerStorageValue(cid, 50002) == -1 then

if isSorcerer(cid) then
local bag = doPlayerAddItem(cid, 1988, 1)
doPlayerAddItem(cid, 2323, 1) -- hotm
doPlayerAddItem(cid, 2656, 1) -- blue robe
doPlayerAddItem(cid, 2456, 1) -- bow
doPlayerAddItem(cid, 2546, 1) -- burst arrow
doPlayerAddItem(cid, 2488, 1) -- crown legs
doPlayerAddItem(cid, 2195, 1) -- boh
doPlayerAddItem(cid, 2123, 1) -- rots
doAddContainerItem(bag, 2120, 1) -- rope
doAddContainerItem(bag, 2554, 1) -- shovel
doAddContainerItem(bag, 2789, 1) -- brown mushroom
doAddContainerItem(bag, 2553, 1) -- pick
doAddContainerItem(bag, 1949, 1) -- declaracoes iniciais
local bag = doPlayerAddItem(cid, 2003, 1) -- greybp
doAddContainerItem(bag, 2268, 1) -- sd
doAddContainerItem(bag, 2268, 1) -- sd
doAddContainerItem(bag, 2268, 1) -- sd
doAddContainerItem(bag, 2268, 1) -- sd
doAddContainerItem(bag, 2304, 1) -- gfb
doAddContainerItem(bag, 2304, 1) -- gfb
doAddContainerItem(bag, 2304, 1) -- gfb
doAddContainerItem(bag, 2304, 1) -- gfb
local bag = doPlayerAddItem(cid, 2002, 1) -- bluebp
doAddContainerItem(bag, 2273, 1) -- uh
doAddContainerItem(bag, 2273, 1) -- uh
doAddContainerItem(bag, 2273, 1) -- uh
doAddContainerItem(bag, 2273, 1) -- uh
local bag = doPlayerAddItem(cid, 2001, 1) -- purplebp
doAddContainerItem(bag, 2006, 7) -- vial of manafluid
doAddContainerItem(bag, 2006, 7) -- vial of manafluid
doAddContainerItem(bag, 2006, 7) -- vial of manafluid
doAddContainerItem(bag, 2006, 7) -- vial of manafluid
setPlayerStorageValue(cid, 50002, 1)

elseif isDruid(cid) then
-- copy and paste the sorcerer's lines and modify them as needed.

elseif isPaladin(cid) then
-- copy and paste the sorcerer's lines and modify them as needed.

elseif isKnight(cid) then
-- copy and paste the sorcerer's lines and modify them as needed.
end
end
return TRUE
end
 
Solution
Back
Top