Svira
Active Member
- Joined
- Jan 27, 2008
- Messages
- 263
- Solutions
- 11
- Reaction score
- 35
Hi! I have been struggling with such a bug for a long time, I probably confused some functions with these TFS.
Below is the script itself
Thank you in advance for your help!
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/creaturescripts/scripts/onkill_slot.lua:23: attempt to index local 'i_Ex' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/onkill_slot.lua:23: in function <data/creaturescripts/scripts/onkill_slot.lua:14>
Below is the script itself
Lua:
function getper()
local n = 1
for i=1,10 do
n = n+math.random(0,10)
if n < 8*i then
break
end
end
return n
end
local lootable_slots = {'hp','mp','ml','melee','shield','dist'}
function assign_loot_Slot(pos)
local c = Tile(pos):getTopDownItem()
if c ~= nil then
if c:isContainer() then
local h = c:getItemHoldingCount()
if h > 0 then
for i = 1, h do
local i_Ex = c:getItem(i - 1)
local itemEx = {
itemid = i_Ex:getId(),
uid = i_Ex:getUniqueId()
}
if (isArmor(itemEx.uid) or isWeapon(itemEx.uid) or isShield(itemEx.uid)) and not isItemStackable(itemEx.uid) then
if math.random(1,5) == 5 then
if math.random(1, 100) <= 15 then
nam = Item(itemEx.uid):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
nam = nam..' ['..lootable_slots[math.random(1, #lootable_slots)]..'.+'..getper()..'%]'
doSetItemSpecialDescription(itemEx.uid, nam)
if math.random(1, 100) <= 10 then
nam = nam..' ['..lootable_slots[math.random(1, #lootable_slots)]..'.+'..getper()..'%]'
doSetItemSpecialDescription(itemEx.uid, nam)
if math.random(1, 100) <= 5 then
nam = nam..' ['..lootable_slots[math.random(1, #lootable_slots)]..'.+'..getper()..'%]'
doSetItemSpecialDescription(itemEx.uid, nam)
end
end
end
end
end
end
return true
end
end
end
end
function onKill(cid, target, lastHit)
if (not isSummon(target)) then
addEvent(assign_loot_Slot, 2, getThingPos(target))
end
return true
end
Thank you in advance for your help!