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

Weird lua error

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hello, the main idea of this script is use a item then depending the chance will create a item, but isn't working, the scripts is making all the items, check the img and the code below, I don't know how to fix it, seems normal the code.

mby it's the for i = 0 #items do? Don't know.

v-48cK64f.png


Code:
items = {
  [0] = {id = 11302, count = 1, chance = 30}, -- zaoan helmet
  [1] = {id = 2493, count = 1, chance = 30}, -- demon helmet
  [2] = {id = 2494, count = 1, chance = 30}, -- demon armor
  [3] = {id = 11356, count = 1, chance = 30}, -- zaoan robe
  [4] = {id = 15490, count = 1, chance = 25}, -- grasshoper
  [5] = {id = 18390, count = 1, chance = 10}, -- wand of defiance
   [6] = {id = 18412, count = 1, chance = 10}, -- glacial rod
   [7] = {id = 2160, count = 10, chance = 30}, -- money
   [8] = {id = 6132, count = 1, chance = 1}, -- pair of soft
   [9] = {id = 2366, count = 1, chance = 1}, -- stamina refiller
   [10] = {id = 5791, count = 1, chance = 60} -- stuffed dragon
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  for i = 0, #items do
     local chance = math.random(1, 100)
  if (items[i].chance < chance) then
  player:addItem(items[i].id, items[i].count)
  item:remove(1)
       player:say('Gratzzz!', TALKTYPE_MONSTER_SAY)
  end
  end
end
 
it create all the items cause of loop
Code:
items = {
  [0] = {id = 11302, count = 1, chance = 30}, -- zaoan helmet
  [1] = {id = 2493, count = 1, chance = 30}, -- demon helmet
  [2] = {id = 2494, count = 1, chance = 30}, -- demon armor
  [3] = {id = 11356, count = 1, chance = 30}, -- zaoan robe
  [4] = {id = 15490, count = 1, chance = 25}, -- grasshoper
  [5] = {id = 18390, count = 1, chance = 10}, -- wand of defiance
  [6] = {id = 18412, count = 1, chance = 10}, -- glacial rod
  [7] = {id = 2160, count = 10, chance = 30}, -- money
  [8] = {id = 6132, count = 1, chance = 1}, -- pair of soft
  [9] = {id = 2366, count = 1, chance = 1}, -- stamina refiller
  [10] = {id = 5791, count = 1, chance = 60} -- stuffed dragon
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   local chance = math.random(1, 100)
   local items_x = math.random(0, #items)
  if (items[i].chance < chance) then
   player:addItem(items[i].id, items[i].count)
   player:say('Gratzzz!', TALKTYPE_MONSTER_SAY)
  end
return true
end
 

Similar threads

Back
Top