bradette19
Member
I've the error again :s
I've the error again :s
Tested it on my server TFS 1.1, I just changed this part:Ok, ty. Good night !
if corpse and corpse:isContainer() then
for i = 1, #extra_loot do
corpse:addExtraLoot(creature, extra_loot[i])
end
end
if ((corpse > 0) and (Container(corpse):isContainer())) then
for i = 1, #extra_loot do
Container(corpse):addExtraLoot(creature, extra_loot[i])
end
end
local extra_loot = {
{hasName = "dragon", items = {
{id = 2152, count = 2, chance = 40000}, -- 40%
{id = 2160, countMax = 4, chance = 100000}
}},
{items = {
{id = 2365, chance = 10000},
{id = 2392, chance = 1000}
}},
}
function Container:addExtraLoot(c, t)
if t.hasName then
local cn = c:getName():lower()
local cm = t.hasName:lower()
if not cn:match(cm) then
return true
end
end
for i = 1, #t.items do
local count = 1
if t.items[i].count then
if t.items[i].countMax then
count = math.random(t.items[i].count, t.items[i].countMax)
else
count = t.items[i].count
end
else
if t.items[i].countMax then
count = math.random(1, t.items[i].countMax)
end
end
if math.random(0, 100000) <= t.items[i].chance then
self:addItem(t.items[i].id, count)
end
end
end
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
if not creature:isMonster() then return true end
if ((corpse > 0) and (Container(corpse):isContainer())) then
for i = 1, #extra_loot do
Container(corpse):addExtraLoot(creature, extra_loot[i])
end
end
return true
end
Are you sure you're using TFS 1.1?Hum, still have the error.
his using TFS 1.2Are you sure you're using TFS 1.1?
It worked for me on TFS 1.1 so not sure what the problem could be.
if corpse and Container(corpse) then
local extra_loot = {
--{hasName = "dragon", items = {
--{id = 2152, count = 2, chance = 40000}, -- 40%
--{id = 2160, countMax = 4, chance = 10000}
--}},
{items = {
{id = 8300, chance = 200}
}},
}
function Container:addExtraLoot(c, t)
if t.hasName then
local cn = c:getName():lower()
local cm = t.hasName:lower()
if not cn:match(cm) then
return true
end
end
for i = 1, #t.items do
local count = 1
if t.items[i].count then
if t.items[i].countMax then
count = math.random(t.items[i].count, t.items[i].countMax)
else
count = t.items[i].count
end
else
if t.items[i].countMax then
count = math.random(1, t.items[i].countMax)
end
end
if math.random(0, 100000) <= t.items[i].chance then
self:addItem(t.items[i].id, count)
end
end
end
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
if not creature:isMonster() then return true end
if ((corpse > 0) and (Container(corpse):if corpse and Container(corpse) then())) then
for i = 1, #extra_loot do
Container(corpse):addExtraLoot(creature, extra_loot[i])
end
end
return true
end
if ((corpse > 0) and (Container(corpse):if corpse and Container(corpse) then())) then
if corpse and Container(corpse) then
math.randomseed(os.time())
local extra_loot = {
{hasName = "dragon", items = {
{id = 2152, count = 1, countMax = 2,chance = 90000}, -- 40%
{id = 2160, countMax = 1, chance = 10000} -- 10%
}},
{items = {
{id = 2365, chance = 90000},
{id = 2392, chance = 1000}
}},
{hasName = "war wolf", items = {
{id = 2152, count = 2, chance = 40000}, -- 40%
{id = 2160, countMax = 4, chance = 10000}
}},
{items = {
{id = 2365, chance = 10000},
{id = 2392, chance = 1000}
}},
}
function Container:addExtraLoot(c, t)
if t.hasName then
local cn = c:getName():lower()
local cm = t.hasName:lower()
if not cn:match(cm) then
return true
end
end
for i = 1, #t.items do
local count = 1
if t.items[i].count then
if t.items[i].countMax then
count = math.random(t.items[i].count, t.items[i].countMax)
else
count = t.items[i].count
end
else
if t.items[i].countMax then
count = math.random(1, t.items[i].countMax)
end
end
if math.random(0, 100000) <= t.items[i].chance then
self:addItem(t.items[i].id, count)
end
end
end
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
if not creature:isMonster() then
return true
end
if creature:getMaster() then
return true
end
if corpse then
local itemType = corpse:getType()
if itemType:isCorpse() and itemType:isContainer() then
for i = 1, #extra_loot do
corpse:addExtraLoot(creature, extra_loot[i])
end
end
return true
end
end
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/stats.lua:2173: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/stats.lua:2173: in function 'improveChance'
data/stats.lua:2247: in function <data/stats.lua:2222>
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/extra_loot.lua:onDeath
data/creaturescripts/scripts/extra_loot.lua:47: attempt to call method 'isContainer' (a nil value)
stack traceback:
[C]: in function 'isContainer'
data/creaturescripts/scripts/extra_loot.lua:47: in function <data/creaturescripts/scripts/extra_loot.lua:45>
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/extra_loot.lua:onDeath
data/creaturescripts/scripts/extra_loot.lua:47: attempt to call method 'isContainer' (a nil value)
stack traceback:
[C]: in function 'isContainer'
data/creaturescripts/scripts/extra_loot.lua:47: in function <data/creaturescripts/scripts/extra_loot.lua:45>
local extra_loot = {
{hasName = "dragon", items = {
{id = 2152, count = 2, chance = 40000}, -- Common
{id = 2160, countMax = 4, chance = 10000} -- Rare
}},
{items = {
{id = 2365, chance = 10000}, -- Epic
{id = 2392, chance = 1000} -- Lendary
}},
}
function Container:addExtraLoot(c, t)
if t.hasName then
local cn = c:getName():lower()
local cm = t.hasName:lower()
if not cn:match(cm) then
return true
end
end
for i = 1, #t.items do
local count = 1
if t.items[i].count then
if t.items[i].countMax then
count = math.random(t.items[i].count, t.items[i].countMax)
else
count = t.items[i].count
end
else
if t.items[i].countMax then
count = math.random(1, t.items[i].countMax)
end
end
if math.random(0, 100000) <= t.items[i].chance then
self:addItem(t.items[i].id, count)
end
end
end
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
if not creature:isMonster() then return true end
if corpse and corpse:isContainer() then
for i = 1, #extra_loot do
corpse:addExtraLoot(creature, extra_loot[i])
end
end
return true
end
}
sorry to revive the topic, but is there a possibility to modify this system so that it identifies and separates items by rarity?
Lua:local extra_loot = { {hasName = "dragon", items = { {id = 2152, count = 2, chance = 40000}, -- Common {id = 2160, countMax = 4, chance = 10000} -- Rare }}, {items = { {id = 2365, chance = 10000}, -- Epic {id = 2392, chance = 1000} -- Lendary }}, } function Container:addExtraLoot(c, t) if t.hasName then local cn = c:getName():lower() local cm = t.hasName:lower() if not cn:match(cm) then return true end end for i = 1, #t.items do local count = 1 if t.items[i].count then if t.items[i].countMax then count = math.random(t.items[i].count, t.items[i].countMax) else count = t.items[i].count end else if t.items[i].countMax then count = math.random(1, t.items[i].countMax) end end if math.random(0, 100000) <= t.items[i].chance then self:addItem(t.items[i].id, count) end end end function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified) if not creature:isMonster() then return true end if corpse and corpse:isContainer() then for i = 1, #extra_loot do corpse:addExtraLoot(creature, extra_loot[i]) end end return true end }
and when the item drops according to its rarity the player receives a default message!!
if math.random(0, 100000) <= t.items[i].chance then -- Common Recipe Formula
local rndm = math.random(50501, 50506)
local rndm1 = math.random(101, 110)
local rndm2 = math.random(201, 211)
local rndm3 = math.random(301, 310)
local rndm4 = math.random(401, 410)
local rndm5 = math.random(501, 510)
local rndm6 = math.random(601, 610)
local item = self:addItem(t.items[i].id, count)
if t.items[i].storage and t.items[i].aid then
item:setAttribute(ITEM_ATTRIBUTE_ACTIONID, rndm)
if rndm == 50501 then
if t.items[i].id == 26384 then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, rndm1)
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Common Blacksmithing Recipe")
return true
elseif t.items[i].id == 26447 then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, rndm1)
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Rare Blacksmithing Recipe")
return true
elseif t.items[i].id == 26448 and t.items[i].hasName == "odibrand" then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, math.random(901, 906))
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Boss Blacksmithing Recipe")
return true
end
end
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/extra_loot.lua:onDeath
data/creaturescripts/scripts/extra_loot.lua:78: attempt to compare number with userdata
stack traceback:
[C]: in function '__lt'
data/creaturescripts/scripts/extra_loot.lua:78: in function <data/creaturescripts/scripts/extra_loot.lua:76>