local plural = function(int, str)
return int..' '..(int <= 1 and str:sub(1, #str - 1) or str)
end
local timeFormat = function(timestamp)
local ret = {}
if timestamp then
local time = timestamp
local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
if (hours > 0) then
ret[1] = plural(hours, 'hours')
if (time % 3600) ~= 0 then
ret[2] = plural(minutes, 'minutes')
end
elseif (minutes > 0) then
ret[1] = plural(minutes, 'minutes')
if (time % 60) ~= 0 then
ret[2] = plural(seconds, 'seconds')...
local plural = function(int, str)
return int..' '..(int <= 1 and str:sub(1, #str - 1) or str)
end
local timeFormat = function(timestamp)
local ret = {}
if timestamp then
local time = timestamp
local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
if (hours > 0) then
ret[1] = plural(hours, 'hours')
if (time % 3600) ~= 0 then
ret[2] = plural(minutes, 'minutes')
end
elseif (minutes > 0) then
ret[1] = plural(minutes, 'minutes')
if (time % 60) ~= 0 then
ret[2] = plural(seconds, 'seconds')
end
else
ret[1] = plural(seconds, 'seconds')
end
end
return table.concat(ret, ' and ')
end
local config = {}
config.increaseTime = 5 * 60 * 60
config.increaseStorage = 12500
local increaseLoot = Action()
function increaseLoot.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getStorageValue(config.increaseStorage) > os.time() then
return player:getPosition():sendMagicEffect(CONST_ME_POFF),
player:sendCancelMessage("You still have "..timeFormat(player:getStorageValue(config.increaseStorage) - os.time()).." of increased loot.")
end
item:remove(1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
player:setStorageValue(config.increaseStorage, os.time() + config.increaseTime)
return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your loot rate has been increased for "..timeFormat(config.increaseTime)..".")
end
increaseLoot:id(5865)
increaseLoot:register()
storage
and extrapercent
on scripts/evencallbacks/default_onDropLoot.lua
local ec = EventCallback
ec.onDropLoot = function(self, corpse)
if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
return
end
local player = Player(corpse:getCorpseOwner())
local mType = self:getType()
if not player or player:getStamina() > 840 then
local monsterLoot = mType:getLoot()
local increaseLoot = false
local extraLootPercent = 15
if player and player:getStorageValue(12500) > os.time() then
increaseLoot = true
end
for i = 1, #monsterLoot do
if increaseLoot then
local default = monsterLoot[i]
if default.chance < 100000 then
default.chance = default.chance + ((extraLootPercent * (default.chance / 1000) / 100) * 1000)
end
end
local item = corpse:createLootItem(monsterLoot[i])
if not item then
print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
end
end
if player then
local text = ("%s of %s: %s"):format((increaseLoot and "Increased loot" or "Loot"), mType:getNameDescription(), corpse:getContentDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
player:sendTextMessage(MESSAGE_LOOT, text)
end
end
else
local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
player:sendTextMessage(MESSAGE_LOOT, text)
end
end
end
ec:register()
awww it works thanks @Roddet god bless you boss! works!!Lua:local plural = function(int, str) return (int > 1 and int..' '..str..'s' or int..' '..str) end local timeFormat = function(timestamp) local ret = {} if timestamp then local time = timestamp local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60) if (time >= 3600) then ret[1] = plural(hours, 'hour') if (time % 3600) > 0 then ret[2] = plural(minutes, 'minute') end elseif (time >= 60) then ret[1] = plural(minutes, 'minute') if (time % 60) > 0 then ret[2] = plural(seconds, 'second') end else ret[1] = plural(seconds, 'second') end end return table.concat(ret, ' and ') end local config = {} config.increaseTime = 5 * 60 * 60 config.increaseStorage = 12500 local increaseLoot = Action() function increaseLoot.onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(config.increaseStorage) > os.time() then return player:getPosition():sendMagicEffect(CONST_ME_POFF), player:sendCancelMessage("You still have "..timeFormat(player:getStorageValue(config.increaseStorage) - os.time()).." of increased loot.") end item:remove(1) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your loot rate has been increased for "..timeFormat(config.increaseTime)..".") return player:setStorageValue(config.increaseStorage, os.time() + config.increaseTime) end increaseLoot:id(5865) increaseLoot:register()
sadly you have to set manuallystorage
andextrapercent
onscripts/evencallbacks/default_onDropLoot.lua
here is the example (you can use this one tho)
Lua:local ec = EventCallback ec.onDropLoot = function(self, corpse) if configManager.getNumber(configKeys.RATE_LOOT) == 0 then return end local player = Player(corpse:getCorpseOwner()) local mType = self:getType() if not player or player:getStamina() > 840 then local monsterLoot = mType:getLoot() local increaseLoot = false local extraLootPercent = 15 if player then if player:getStorageValue(12500) > os.time() then increaseLoot = true end end for i = 1, #monsterLoot do if increaseLoot then local default = monsterLoot[i] if default.chance < 100000 then default.chance = default.chance + ((extraLootPercent * (default.chance / 1000) / 100) * 1000) end end local item = corpse:createLootItem(monsterLoot[i]) if not item then print('[Warning] DropLoot:', 'Could not add loot item to corpse.') end end if player then local text = ("%s of %s: %s"):format((increaseLoot and "Increased loot" or "Loot"), mType:getNameDescription(), corpse:getContentDescription()) local party = player:getParty() if party then party:broadcastPartyLoot(text) else player:sendTextMessage(MESSAGE_LOOT, text) end end else local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription()) local party = player:getParty() if party then party:broadcastPartyLoot(text) else player:sendTextMessage(MESSAGE_LOOT, text) end end end ec:register()
Sorry @Roddet I meant by increasing the loot increase the chance instead from the items can u please adjust itLua:local plural = function(int, str) return int..' '..(int <= 1 and str:sub(1, #str - 1) or str) end local timeFormat = function(timestamp) local ret = {} if timestamp then local time = timestamp local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60) if (hours > 0) then ret[1] = plural(hours, 'hours') if (time % 3600) ~= 0 then ret[2] = plural(minutes, 'minutes') end elseif (minutes > 0) then ret[1] = plural(minutes, 'minutes') if (time % 60) ~= 0 then ret[2] = plural(seconds, 'seconds') end else ret[1] = plural(seconds, 'seconds') end end return table.concat(ret, ' and ') end local config = {} config.increaseTime = 5 * 60 * 60 config.increaseStorage = 12500 local increaseLoot = Action() function increaseLoot.onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(config.increaseStorage) > os.time() then return player:getPosition():sendMagicEffect(CONST_ME_POFF), player:sendCancelMessage("You still have "..timeFormat(player:getStorageValue(config.increaseStorage) - os.time()).." of increased loot.") end item:remove(1) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) player:setStorageValue(config.increaseStorage, os.time() + config.increaseTime) return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your loot rate has been increased for "..timeFormat(config.increaseTime)..".") end increaseLoot:id(5865) increaseLoot:register()
sadly you have to set manuallystorage
andextrapercent
onscripts/evencallbacks/default_onDropLoot.lua
here is the example (you can use this one tho)
Lua:local ec = EventCallback ec.onDropLoot = function(self, corpse) if configManager.getNumber(configKeys.RATE_LOOT) == 0 then return end local player = Player(corpse:getCorpseOwner()) local mType = self:getType() if not player or player:getStamina() > 840 then local monsterLoot = mType:getLoot() local increaseLoot = false local extraLootPercent = 15 if player and player:getStorageValue(12500) > os.time() then increaseLoot = true end for i = 1, #monsterLoot do if increaseLoot then local default = monsterLoot[i] if default.chance < 100000 then default.chance = default.chance + ((extraLootPercent * (default.chance / 1000) / 100) * 1000) end end local item = corpse:createLootItem(monsterLoot[i]) if not item then print('[Warning] DropLoot:', 'Could not add loot item to corpse.') end end if player then local text = ("%s of %s: %s"):format((increaseLoot and "Increased loot" or "Loot"), mType:getNameDescription(), corpse:getContentDescription()) local party = player:getParty() if party then party:broadcastPartyLoot(text) else player:sendTextMessage(MESSAGE_LOOT, text) end end else local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription()) local party = player:getParty() if party then party:broadcastPartyLoot(text) else player:sendTextMessage(MESSAGE_LOOT, text) end end end ec:register()
Its only increasing the loot chance not the items directlySorry @Roddet I meant by increasing the loot increase the chance instead from the items can u please adjust it
My bad then but where to edit the chance? is it this?Its only increasing the loot chance not the items directly
local extraLootPercent = 15
Yep, thats the oneMy bad then but where to edit the chance? is it this?Code:local extraLootPercent = 15
Thank you bossYep, thats the one