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

First items script isn't working?

XxDeathAvenger

New Member
Joined
May 5, 2011
Messages
95
Reaction score
2
Hey guys, I put this script into my firstitems.lua. And nothing happens?

Code:
[code=lua]local firstItems_storage = 30001

local commonItems = {
{itemid=2554, inContainer = TRUE}, -- shovel
{itemid=2120, inContainer = TRUE}, -- rope
{itemid=2160, count=2, inContainer = TRUE}, -- 2 crystal coins
{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
[/CODE]

Can anyone see an error with this? Or do I have to add something somewhere else? I already made sure I had the creaturescripts correct as well.
 
Try this, see if it works :)
Code:
    local firstItems_storage = 30001

    local commonItems = {
         "backpack", "rope", "leather boots", "shovel"
    }
    local cash {
        "crystal coin", -- cash
        "2" -- count
    }
    local ammo = {
        "arrow", -- ammo type
        "100" -- ammo amount
    }
    local firstItems = {
        -- sorc
        {
            "spellbook", -- shield
            "wand of vortex", -- weapon
            "mage hat", -- head... yes plx
            "magician's robe", -- chest
            "studded legs", -- legs
            "leather boots", -- feet
            cash[1], -- cash
            "nothing", -- arrow slot
            cash[2], -- cash count
            "nothing" -- arrow slot count
        },
        -- druid
        {
            "spellbook",
            "snakebite rod",
            "mage hat",
            "magician's robe", 
            "studded legs",
            "leather boots",
            cash[1],
            "nothing",
            cash[2],
            "nothing"
        },
        -- paladin
        {
            "nothing",
            "bow",
            "legion helmet",
            "ranger's cloak",
            "ranger legs"
            "leather boots",
            cash[1],
            ammo[1],
            cash[2],
            ammo[2]
        },
        -- knight
        {
            "steel shield",
            "jagged sword",
            "soldier helmet",
            "brass armor",
            "brass legs"
            "leather boots",
            cash[1],
            "nothing",
            cash[2],
            "nothing"
        }   
    }
   
    function friItenzPlx(iten)
        return getItemIdByName(iten, false)
    end

    function onLogin(cid)
        if getPlayerGroupId(cid) < 2 and getPlayerStorageValue(cid, firstItems_storage) <= 0 then
            local myFriItens = firstItems[getPlayerVocation(cid)]
            -- this creates the backpack and put stuff in it
            for x = 1, #commonItems do
                if (isItemContainer( friItenzPlx(commonItems[x]) ) )
                    backpack = doPlayerAddItem(cid, friItenzPlx(commonItems[x]), 1)
                else
                    doAddContainerItem(backpack, friItenzPlx(commonItems[x]), 1)
                end
            end
            ------------------------------------
            -- this creates the equipment for the player, adds gold etc
            for i = 1, #myFriItens - 2 do
                if myFriItens[i] ~= "nothing" and myFriItens[i] ~= cash[1] and myFriItens[i] ~= ammo[1] then
                    doPlayerAddItem(cid, friItenzPlx(myFriItens[i]), 1)
                elseif myFriItens[i] == cash[1] or myFriItens[i] == ammo[1] then
                    doPlayerAddItem(cid, friItenzPlx(myFriItens[i]), tonumber( myFriItens[i+2]:gsub('[0-9]+') ) )
                end
            end
            setPlayerStorageValue(cid, firstItems_storage, 1)
        end
        return TRUE
    end
 
Last edited:
Hey guys, I put this script into my firstitems.lua. And nothing happens?

Code:
[code=lua]local firstItems_storage = 30001

local commonItems = {
{itemid=2554, inContainer = TRUE}, -- shovel
{itemid=2120, inContainer = TRUE}, -- rope
{itemid=2160, count=2, inContainer = TRUE}, -- 2 crystal coins
{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
[/CODE]

Can anyone see an error with this? Or do I have to add something somewhere else? I already made sure I had the creaturescripts correct as well.

U must remove
Lua:
 and
..
 
Back
Top