• 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 Items by level and vocations Error

CharlesHudson

Just alive, or just breathing...
Joined
Oct 25, 2011
Messages
98
Reaction score
14
Code:
function onAdvance(cid, skill, oldlevel, newlevel)
local c = {
  [{1,5}] = {
  [20] = {items = {{itemid = 2188, count = 1}}, storage = 99901},
  [35] = {items = {{itemid = 2187, count = 1}}, storage = 99902},
  [50] = {items = {{itemid = 8922, count = 1}}, storage = 99903}
  },
  [{2,6}] = {
  [20] = {items = {{itemid = 2185, count = 1}}, storage = 99901},
  [35] = {items = {{itemid = 2183, count = 1}}, storage = 99902},
  [50] = {items = {{itemid = 8910, count = 1}}, storage = 99903}
  },
  [{3,7}] = {
  [20] = {items = {{itemid = 3965, count = 15}}, storage = 99901},
  [35] = {items = {{itemid = 7378, count = 15}}, storage = 99902},
  [50] = {items = {{itemid = 7367, count = 15}}, storage = 99903}
  },
  [{4,8}] = {
  [20] = {items = {{itemid = 2383, count = 1},{itemid = 2429, count = 1},{itemid = 2423, count = 1}}, storage = 99901},
  [35] = {items = {{itemid = 7408, count = 1},{itemid = 3962, count = 1},{itemid = 2434, count = 1}}, storage = 99902},
  [50] = {items = {{itemid = 2407, count = 1},{itemid = 15451, count = 1},{itemid = 2424, count = 1}}, storage = 99903}
  }
}
  if skill ~= 8 then
  return true
  end

  for voc, x in pairs(c) do
  if isInArray(voc, getPlayerVocation(cid)) then
  for level, z in pairs(x) do
  if newlevel >= level and getPlayerStorageValue(cid, z.storage) ~= 1 then
  if isKnight(cid) then
x = getPlayerSkill(cid, SKILL_SWORD) >= getPlayerSkill(cid, SKILL_AXE) >=getPlayerSkill(cid, SKILL_CLUB) >= and table.remove(z.items, 2) and table.remove(z.items, 1) or table.remove(z.items, 3)
end
  local text = ""
  for v = 1, #z.items do
  count, info = z.items[v].count, getItemDescriptions(z.items[v].itemid)
  local ret = ", "
  if v == 1 then
  ret = ""
  elseif v == #z.items then
  ret = " and "
  end
  text = text .. ret
  text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
  doPlayerAddItem(cid, z.items[v].itemid, z.items[v].count)
  end
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you reached level "..level.." and received "..text..".")
  doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
  setPlayerStorageValue(cid, z.storage, 1)
  end
  end  
  end
  end
  end
  return true
  end


And doesn't works it say theres a unespected symbol near of 'and'
and i don't really understand that, becouse i already check this
Plx help

I use TFS 1.0
 
Code:
function onAdvance(cid, skill, oldlevel, newlevel)

   local c = {
     [{1,5}] = {
       [20] = {items = {{itemid = 2188, count = 1}}, storage = 99901},
       [35] = {items = {{itemid = 2187, count = 1}}, storage = 99901},
       [50] = {items = {{itemid = 8922, count = 1}}, storage = 99903}
     },
     [{2,6}] = {
       [15] = {items = {{itemid = 2185, count = 1}}, storage = 99901},
       [30] = {items = {{itemid = 2183, count = 1}}, storage = 99902},
       [45] = {items = {{itemid = 8910, count = 1}}, storage = 99903}
     },
     [{3,7}] = {
       [15] = {items = {{itemid = 3965, count = 15}}, storage = 99901},
       [20] = {items = {{itemid = 7378, count = 15}}, storage = 99902},
       [45] = {items = {{itemid = 7367, count = 15}}, storage = 99903}
     },
       [{4,8}] = {
       [15] = {items = {{itemid = 2383, count = 1}, {itemid = 2439, count = 1}, {itemid = 2423, count = 1}}, storage = 99901},
       [30] = {items = {{itemid = 7408, count = 1}, {itemid = 3962, count = 1}, {itemid = 2434, count = 1}}, storage = 99902},
       [45] = {items = {{itemid = 2407, count = 1}, {itemid = 15451, count = 1}, {itemid = 2424, count = 1}}, storage = 99903}
     }
   }

     if skill ~= SKILL_LEVEL then
     return true
     end

     for voc, x in pairs(c) do
         if isInArray(voc, getPlayerVocation(cid)) then
             for level, z in pairs(x) do
                 if newlevel >= level and getPlayerStorageValue(cid, z.storage) ~= 1 then
                     if isKnight(cid) then
                         local s, a, c = getPlayerSkill(cid, SKILL_SWORD), getPlayerSkill(cid, SKILL_AXE), getPlayerSkill(cid, SKILL_CLUB)
                         if s >= a and s >= c then
                             table.remove(z.items, 3)
                             table.remove(z.items, 2)
                         elseif a >= s and a >= c then
                             table.remove(z.items, 3)
                             table.remove(z.items, 1)
                         else
                             table.remove(z.items, 2)
                             table.remove(z.items, 1)
                         end
                     end
                     local text = ""
                     for v = 1, #z.items do
                         count, info = z.items[v].count, getItemDescriptions(z.items[v].itemid)
                         local ret = ", "
                         if v == 1 then
                             ret = ""
                         elseif v == #z.items then
                             ret = " and "
                         end
                         text = text .. ret
                         text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
                         doPlayerAddItem(cid, z.items[v].itemid, z.items[v].count)
                     end
                     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you reached level "..level.." and received "..text..".")
                     doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
                     setPlayerStorageValue(cid, z.storage, 1)
                 end
             end
         end
     end
     return true
end
 
Code:
function onAdvance(cid, skill, oldlevel, newlevel)

   local c = {
     [{1,5}] = {
       [20] = {items = {{itemid = 2185, count = 1}}, storage = 99901},
       [35] = {items = {{itemid = 2183, count = 1}}, storage = 99901},
       [50] = {items = {{itemid = 8910, count = 1}}, storage = 99903}
     },
     [{2,6}] = {
       [15] = {items = {{itemid = 3965, count = 1}}, storage = 99901},
       [30] = {items = {{itemid = 7378, count = 1}}, storage = 99902},
       [45] = {items = {{itemid = 7367, count = 1}}, storage = 99903}
     },
     [{3,7}] = {
       [15] = {items = {{itemid = 3965, count = 15}}, storage = 99901},
       [20] = {items = {{itemid = 7378, count = 15}}, storage = 99902},
       [45] = {items = {{itemid = 7367, count = 15}}, storage = 99903}
     },
       [{4,8}] = {
       [15] = {items = {{itemid = 2383, count = 1}, {itemid = 2439, count = 1}, {itemid = 2423, count = 1}}, storage = 99901},
       [30] = {items = {{itemid = 7408, count = 1}, {itemid = 3962, count = 1}, {itemid = 2434, count = 1}}, storage = 99902},
       [45] = {items = {{itemid = 2407, count = 1}, {itemid = 15451, count = 1}, {itemid = 2424, count = 1}}, storage = 99903}
     }
   }

     if skill ~= SKILL_LEVEL then
     return true
     end

     for voc, x in pairs(c) do
         if isInArray(voc, getPlayerVocation(cid)) then
             for level, z in pairs(x) do
                 if newlevel >= level and getPlayerStorageValue(cid, z.storage) ~= 1 then
                     if isKnight(cid) then
                         local s, a, c = getPlayerSkill(cid, SKILL_SWORD), getPlayerSkill(cid, SKILL_AXE), getPlayerSkill(cid, SKILL_CLUB)
                         if s >= a and s >= c then
                             table.remove(z.items, 3)
                             table.remove(z.items, 2)
                         elseif a >= s and a >= c then
                             table.remove(z.items, 3)
                             table.remove(z.items, 1)
                         else
                             table.remove(z.items, 2)
                             table.remove(z.items, 1)
                         end
                     end
                     local text = ""
                     for v = 1, #z.items do
                         count, info = z.items[v].count, getItemDescriptions(z.items[v].itemid)
                         local ret = ", "
                         if v == 1 then
                             ret = ""
                         elseif v == #z.items then
                             ret = " and "
                         end
                         text = text .. ret
                         text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
                         doPlayerAddItem(cid, z.items[v].itemid, z.items[v].count)
                     end
                     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you reached level "..level.." and received "..text..".")
                     doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
                     setPlayerStorageValue(cid, z.storage, 1)
                 end
             end
         end
     end
     return true
end
This works? THANKS anyway
 
Back
Top