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

Lua firstitems.lua doesn't work

gniu123

New Member
Joined
Aug 1, 2008
Messages
16
Reaction score
0
Location
Brasil
Hi, i got this error:

[Error - CreatureScript Interface]
buffer:eek:nLogin
Description:
[string "loadBuffer"]:5: bad argument #1 to 'maxn' (table expected, got nil)
stack traceback:
[C]: in function 'maxn'
[string "loadBuffer"]:5: in function <[string "loadBuffer"]:3

Anyone can help-me im use Feragon Online DEV 1.1
And DB of TFS 3.6
 
Use this..

Code:
local commonItems = {
  -- ITEMS ALL VOCS RECEIVE
  {itemid=2480, count=1}, -- legion helmet
  {itemid=2464, count=1}, -- chain armor
  {itemid=2468, count=1}, -- studded legs
  {itemid=2643, count=1}, -- leather boots
  {itemid=2120, count=1}, -- rope
  {itemid=5710, count=1}, -- shovel
  {itemid=2160, count=1} -- money
}

local firstItems = {
  { -- SORC ITEMS
    {itemid=2190, count=1}, -- wand of vortex
    {itemid=2175, count=1} -- spellbook
  },
  { -- DRUID ITEMS
    {itemid=2182, count=1}, -- snakebite rod
    {itemid=2175, count=1} -- spellbook
  },
  { -- PALADIN ITEMS
    {itemid=2389, count=5}, -- spears
    {itemid=2456, count=1}, -- bow
    {itemid=2544, count=100} -- 100 arrows
  },
  { -- KNIGHT ITEMS
    {itemid=2412, count=1}, -- katana
    {itemid=2398, count=1}, -- mace
    {itemid=2388, count=1}, -- hatchet
    {itemid=2530, count=1} -- copper shield
  }
}

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
    local hasReceivedFirstItems = getPlayerStorageValue(cid, 67708)

    if hasReceivedFirstItems ~= 1 then
      --[[local backpack = ]]doPlayerAddItem(cid, 1988, 1)

      local giveItems = firstItems[getPlayerVocation(cid)]

      if giveItems ~= nil 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 have recieved your first items!")
      end
      setPlayerStorageValue(cid, 67708, 1)
    end
  end
  return TRUE
end
 
Hello again, im use this firstitens.lua, i can change the line

for i = 1, table.maxn(firstItems[getPlayerVocation(cid)]) do
For
for i = 1, table.inser(firstItems[getPlayerVocation(cid)]) do

in
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
<config name="firstitems_config"><![CDATA[
firstItems = {}
firstItems[0] = {2525,3965,2124,2457,2647,2643}
firstItems[1] = {2525,8820,2468,2643,8819,2190,2120}
firstItems[2] = {2525,8820,2468,2643,8819,2182,2120}
firstItems[3] = {2525,2460,8923,2643,2660,2389,2120}
firstItems[4] = {2525,2460,2468,2643,2464,2412,2398,2388,2120}

]]></config>
<event type="login" name="FirstItems" event="script"><![CDATA[
domodlib('firstitems_config')

function onLogin(cid)
if getPlayerStorageValue(cid, 30002) == -1 then
for i = 1, table.maxn(firstItems[getPlayerVocation(cid)]) do
doPlayerAddItem(cid, firstItems[getPlayerVocation(cid)], 1)
end
local bag = doPlayerAddItem(cid, 1988, 1)
doAddContainerItem(bag, 2152, 2)
doAddContainerItem(bag, 7618, 1)
setPlayerStorageValue(cid, 30002, 1)
end
return TRUE
end
]]></event>
</mod>
 
Back
Top