damian00912
Member
- Joined
- Sep 11, 2009
- Messages
- 90
- Reaction score
- 6
Hei, i have problem, if someone has exta loot in ring, thats working fine, is information about extra drop, and in monster this item is like extra drop but every this drop make error in logs, and if this ring have a lot of players, thats sometime make crash server :/ someone know what is wrong?
Here is error from console:
And this is the script:
Please help if someone know where is problem
Here is error from console:
Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/stats.lua:2080: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/stats.lua:2080: in function 'improveChance'
data/stats.lua:2156: in function <data/stats.lua:2131>
And this is the script:
Lua:
function improveChance(c, monsterName, extraPercent, killer)
local m = MonsterType(monsterName):getLoot()
if math.random(1, 100) <= extraPercent then
local t = {}
for i = 1, #m do
t[i] = {itemId = m[i].itemId, chance = m[i].chance}
end
local min = 1
local t_s = {}
local low5 = #t-5
while #t > low5 do
min = 1
for i = 1, #t do
if math.min(t[i].chance, t[min].chance) == t[i].chance then
min = i
end
end
t_s[#t_s + 1] = {itemId = t[min].itemId, chance = t[min].chance}
table.remove(t, min)
end
local chosenId = math.random(1, #t_s)
local h = c:getItemHoldingCount()
if h > 0 then
local extra = true
for i = 1, h do
if ItemType(c:getItem(i - 1):getId()) == t_s[chosenId].itemId then
extra = false
break
end
end
if extra then
if math.random(1, 100000) <= (t_s[chosenId].chance + (t_s[chosenId].chance * extraPercent / 100)) * configManager.getNumber(configKeys.RATE_LOOT) then
c:addItem(m[chosenId].itemId, 1)
if killer then
local iid = ItemType(m[chosenId].itemId)
Player(killer):sendTextMessage(MESSAGE_EVENT_ADVANCE, "Extra loot: " .. (iid:getArticle() ~= "" and iid:getArticle() .. " " or "") .. iid:getName())
end
end
end
end
end
return true
end
Please help if someone know where is problem