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

Solved firstitems.lua bug dosent register promotion!

Grozzmo

Member
Joined
Nov 29, 2007
Messages
125
Reaction score
8
So I want every player to start with promotion, but the script that gives startitems dosent work when I set them to login as promotion, they get 0 eq.

But if I set no promotion, they get EQ, i dont know why, anyone got a clue? here's my .lua scirpt, I also set firstitems in login.lua and also in creaturescripts.xml
Code:
local commonItems = {
  -- ITEMS ALL VOCS RECEIVE
  {itemid=2120, count=1}, -- rope
  {itemid=5710, count=1}, -- shovel
  {itemid=2789, count=100}, -- brown mushrooms
}

local firstItems = {
  { -- SORC ITEMS
  {itemid=2323, count=1}, -- hat of the mad
  {itemid=8871, count=1}, -- focus cape
  {itemid=2647, count=1}, -- plate legs
  {itemid=2643, count=1}, -- leather boots
  {itemid=2525, count=1}, -- dwarven shield
  {itemid=2191, count=1}, -- wand of dragonbreath


  {itemid=2268, count=1}, -- sd
  {itemid=2273, count=1}, -- uh
  {itemid=7620, count=1}, -- mp
   {itemid=7618, count=1}, -- hp
  {itemid=2293, count=1}, -- mw
   {itemid=2261, count=1}, -- dr
  {itemid=2274, count=1}, -- avalanche rune
   {itemid=2305, count=1}, -- firebomb rune
  },
  { -- DRUID ITEMS
  {itemid=2323, count=1}, -- hat of the mad
  {itemid=8871, count=1}, -- focus cape
  {itemid=2647, count=1}, -- plate legs
  {itemid=2643, count=1}, -- leather boots
  {itemid=2525, count=1}, -- dwarven shield
  {itemid=2186, count=1}, -- moonlight rod

  {itemid=2268, count=1}, -- sd
  {itemid=2273, count=1}, -- uh
  {itemid=7620, count=1}, -- mp
   {itemid=7618, count=1}, -- hp
  {itemid=2293, count=1}, -- mw
   {itemid=2261, count=1}, -- dr
  {itemid=2269, count=1}, -- wg
  {itemid=2274, count=1}, -- avalanche rune
   {itemid=2305, count=1}, -- firebomb rune
  },
  { -- PALADIN ITEMS
  {itemid=2457, count=1}, -- steel helemet
  {itemid=8891, count=1}, -- belted cape
  {itemid=2647, count=1}, -- plate legs
  {itemid=2643, count=1}, -- leather boots
  {itemid=2525, count=1}, -- dwarven shield
  {itemid=7368, count=1}, -- assassin stars

  {itemid=2268, count=1}, -- sd
  {itemid=2273, count=1}, -- uh
  {itemid=7620, count=1}, -- mp
   {itemid=7618, count=1}, -- hp
  {itemid=2293, count=1}, -- mw
   {itemid=2261, count=1}, -- dr
   {itemid=2305, count=1}, -- firebomb rune
   {itemid=2274, count=1}, -- avalanche rune
  },
  { -- KNIGHT ITEMS
  {itemid=2457, count=1}, -- steel helemet
  {itemid=2463, count=1}, -- plate armor
  {itemid=2647, count=1}, -- plate legs
  {itemid=2643, count=1}, -- leather boots
  {itemid=2525, count=1}, -- dwarven shield
  {itemid=10313, count=1}, -- Incredible Mumpiz Slayer

   {itemid=2273, count=1}, -- uh
  {itemid=7620, count=1}, -- mp
   {itemid=7618, count=1}, -- hp
  {itemid=2293, count=1}, -- mw
   {itemid=2261, count=1}, -- dr
   {itemid=2305, count=1}, -- firebomb rune
   {itemid=2274, count=1}, -- avalanche 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
  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
 
Last edited by a moderator:
I appreciate your help! I get these errors when I add your script, and I modified the ids to fit me. Ive added firstitems in creaturescripts.xml and also in login.lua I got no clue what's going on :S

Error in the console:
[14/08/2014 22:05:03] [Error - CreatureEvent::configureEvent] No valid type for creature event.firstitems
[14/08/2014 22:05:03] [Warning - BaseEvents::loadFromXml] Cannot configure an event

And here's the script:
Code:
local vocitems = {
  [1] = { -- sorcerer
  container = {
  {id = 2268, count = 1},
  {id =2273 , count = 1},
  {id = 7620, count = 1}
  {id = 7618, count = 1},
  {id = 2293, count = 1},
  {id = 2261, count = 1}
  {id = 2274, count = 1},
  {id = 2305, count = 1},
  
  },
  eq = {
  {id = 2323, count = 1},
  {id = 8871, count = 1},
  {id = 2647, count = 1},
  {id = 2643, count = 1},
  {id = 2525, count = 1},
  {id = 2191, count = 1}
  }
  },
  [2] = { -- druid
  container = {
  {id = 2268, count = 1},
  {id =2273 , count = 1},
  {id = 7620, count = 1}
  {id = 7618, count = 1},
  {id = 2293, count = 1},
  {id = 2261, count = 1}
  {id = 2274, count = 1},
  {id = 2305, count = 1},
  {id = 2269, count = 1},
  },
  eq = {
  {id = 2323, count = 1},
  {id = 8871, count = 1},
  {id = 2647, count = 1},
  {id = 2643, count = 1},
  {id = 2525, count = 1},
  {id = 2186, count = 1}
  }
  },
  [3] = { -- paladin
  container = {
  {id = 2268, count = 1},
  {id =2273 , count = 1},
  {id = 7620, count = 1}
  {id = 7618, count = 1},
  {id = 2293, count = 1},
  {id = 2261, count = 1}
  {id = 2274, count = 1},
  {id = 2305, count = 1},
  },
  eq = {
  {id = 2457, count = 1},
  {id = 8891, count = 5},
  {id = 2647, count = 1},
  {id = 2643, count = 1},
  {id = 2525, count = 1},
  {id = 7367, count = 1}
  }
  },
  [4] = { -- knight
  container = {
  {id =2273 , count = 1},
  {id = 7620, count = 1}
  {id = 7618, count = 1},
  {id = 2293, count = 1},
  {id = 2261, count = 1}
  {id = 2274, count = 1},
  {id = 2305, count = 1},
  },
  eq = {
  {id = 2457, count = 1},
  {id = 2463, count = 1},
  {id = 2643, count = 1},
  {id = 2525, count = 1},
  {id = 2392, count = 1},
  }
  }
}

function onLogin(cid)

  if(getPlayerLastLoginSaved(cid) == 0) then
  local x = vocitems[getPlayerVocation(cid)]
  if x then
  for e = 1, #x.eq do
  doPlayerAddItem(cid, x.eq[e].id, x.eq[e].count)
  end
  local bag = doPlayerAddItem(cid, 2000, 1)
  for c = 1, #x.container do
  doAddContainerItem(bag, x.container[c].id, x.container[c].count)
  end
  end
  end
  return true
end
 
Last edited by a moderator:
I think i solved the creatureevent, but now I got this in the console :/ checked line 3 any there's nothing wrong

[Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/firstitems.lua:7: '}' expected (to close '{' at line 3) near '{'
[14/08/2014 22:15:36] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/firstitems.lua)
[14/08/2014 22:15:36] data/creaturescripts/scripts/firstitems.lua:7: '}' expected (to close '{' at line 3) near '{'

the script:
Code:
local vocitems = {
  [1] = { -- sorcerer
  container = {
  {id = 2268, count = 1},
  {id = 2273, count = 1},
  {id = 7620, count = 1}
  {id = 7618, count = 1},
  {id = 2293, count = 1},
  {id = 2261, count = 1}
  {id = 2274, count = 1},
  {id = 2305, count = 1}
  },
  eq = {
  {id = 2323, count = 1},
  {id = 8871, count = 1},
  {id = 2647, count = 1},
  {id = 2643, count = 1},
  {id = 2525, count = 1},
  {id = 2191, count = 1}
  }
  },
  [2] = { -- druid
  container = {
  {id = 2268, count = 1},
  {id =2273 , count = 1},
  {id = 7620, count = 1}
  {id = 7618, count = 1},
  {id = 2293, count = 1},
  {id = 2261, count = 1}
  {id = 2274, count = 1},
  {id = 2305, count = 1},
  {id = 2269, count = 1}
  },
  eq = {
  {id = 2323, count = 1},
  {id = 8871, count = 1},
  {id = 2647, count = 1},
  {id = 2643, count = 1},
  {id = 2525, count = 1},
  {id = 2186, count = 1}
  }
  },
  [3] = { -- paladin
  container = {
  {id = 2268, count = 1},
  {id =2273 , count = 1},
  {id = 7620, count = 1}
  {id = 7618, count = 1},
  {id = 2293, count = 1},
  {id = 2261, count = 1}
  {id = 2274, count = 1},
  {id = 2305, count = 1}
  },
  eq = {
  {id = 2457, count = 1},
  {id = 8891, count = 5},
  {id = 2647, count = 1},
  {id = 2643, count = 1},
  {id = 2525, count = 1},
  {id = 7367, count = 1}
  }
  },
  [4] = { -- knight
  container = {
  {id =2273 , count = 1},
  {id = 7620, count = 1}
  {id = 7618, count = 1},
  {id = 2293, count = 1},
  {id = 2261, count = 1}
  {id = 2274, count = 1},
  {id = 2305, count = 1}
  },
  eq = {
  {id = 2457, count = 1},
  {id = 2463, count = 1},
  {id = 2643, count = 1},
  {id = 2525, count = 1},
  {id = 2392, count = 1}
  }
  }
}

function onLogin(cid)

  if(getPlayerLastLoginSaved(cid) == 0) then
  local x = vocitems[getPlayerVocation(cid)]
  if x then
  for e = 1, #x.eq do
  doPlayerAddItem(cid, x.eq[e].id, x.eq[e].count)
  end
  local bag = doPlayerAddItem(cid, 2000, 1)
  for c = 1, #x.container do
  doAddContainerItem(bag, x.container[c].id, x.container[c].count)
  end
  end
  end
  return true
end
 
Last edited by a moderator:
There are missing comma's at the end of the lines in the table.
container = {
{id = 2268, count = 1},
{id = 2273, count = 1},
{id = 7620, count = 1},
{id = 7618, count = 1},
{id = 2293, count = 1},
{id = 2261, count = 1},
{id = 2274, count = 1},
{id = 2305, count = 1}
},

Same goes for the container items of the other vocations.
 
Yeah I found out the problem =) and I also wrote wrong IDS for promotion its supposed to be: Sorc = 5 Druid = 6 pally = 7 knight= 8

=D THANKS ALOT Limos, Love ya! Is there any chance I could get your skype or so, to keep in touch? =)
 
Back
Top