Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <mod name="Loot System" version="1.0" author="Vodkart, Mkalo and Adriano Swatt'" contact="none.com" enabled="yes">
- <config name="Loot_func"><![CDATA[
- info = {
- OnlyPremium = false,
- AutomaticDeposit = true,
- limitList = 10,
- BlockMonsters = {},
- BlockItemsList = {2123, 2515}
- }
- function setPlayerStorageTable(cid, storage, tab)
- local tabstr = "&"
- for i, x in pairs(tab) do
- tabstr = tabstr .. i .. "," .. x .. ";"
- end
- setPlayerStorageValue(cid, storage, tabstr:sub(1, #tabstr-1))
- end
- function getPlayerStorageTable(cid, storage)
- local tabstr = getPlayerStorageValue(cid, storage)
- local tab = {}
- if type(tabstr) ~= "string" then
- return {}
- end
- if tabstr:sub(1,1) ~= "&" then
- return {}
- end
- local tabstr = tabstr:sub(2, #tabstr)
- local a = string.explode(tabstr, ";")
- for i,x in pairs(a) do
- local b = string.explode(x, ",")
- tab[tonumber(b[1]) or b[1]] = tonumber(b[2]) or b[2]
- end
- return tab
- end
- function isInTable(cid, item)
- for _,i in pairs(getPlayerStorageTable(cid, 27000))do
- if tonumber(i) == tonumber(item) then
- return true
- end
- end
- return false
- end
- function addItemTable(cid, item)
- local x = {}
- getQtdd = getPlayerStorageTable(cid, 27000)
- for i = 1, #getQtdd do
- if #getQtdd < info.limitList then
- table.insert(x, getQtdd[i])
- else
- doPlayerSendCancel(cid, "You have reached the limit from AutoLoot List ["..#getQtdd.."/"..info.limitList.."].")
- return true
- end
- end
- if x ~= 0 then
- table.insert(x,tonumber(item))
- setPlayerStorageTable(cid, 27000, x)
- else
- setPlayerStorageTable(cid, 27000, {item})
- end
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You added the "..getItemNameById(item).." from your AutoLoot List sucessfully.")
- end
- function removeItemTable(cid, item)
- local x = {}
- for i = 1, #getPlayerStorageTable(cid, 27000) do
- table.insert(x,getPlayerStorageTable(cid, 27000)[i])
- end
- for i, v in ipairs(x) do
- if tonumber(v) == tonumber(item) then
- table.remove(x,i)
- end
- end
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You removed the "..getItemNameById(item).." from your AutoLoot List sucessfully.")
- return setPlayerStorageTable(cid, 27000, x)
- end
- function ShowItemsTabble(cid)
- local str, n = "-- My Loot List --\n\n",0
- for i = 1, #getPlayerStorageTable(cid, 27000) do
- n = n + 1
- str = str..""..n.." - "..getItemNameById(getPlayerStorageTable(cid, 27000)[i]).."\n"
- end
- return doShowTextDialog(cid, 2529, str)
- end
- function getContainerItems(containeruid)
- if not isContainer(containeruid) then
- return true
- end
- local items = {}
- local containers = {}
- if type(getContainerSize(containeruid)) ~= "number" then
- return false
- end
- for slot = 0, getContainerSize(containeruid)-1 do
- local item = getContainerItem(containeruid, slot)
- if item.itemid == 0 then
- break
- end
- if isContainer(item.uid) then
- table.insert(containers, item.uid)
- end
- table.insert(items, item)
- end
- if #containers > 0 then
- for i, x in ipairs(getContainerItems(containers[1])) do
- table.insert(items, x)
- end
- table.remove(containers, 1)
- end
- return items
- end
- function getItemsInContainerById(container, itemid) -- Function By Kydrai
- local items = {}
- if isContainer(container) and getContainerSize(container) > 0 then
- for slot = 0, (getContainerSize(container)-1) do
- local item = getContainerItem(container, slot)
- if isContainer(item.uid) then
- local itemsbag = getItemsInContainerById(item.uid, itemid)
- for i = 0, #itemsbag do
- table.insert(items, itemsbag[i])
- end
- else
- if itemid == item.itemid then
- table.insert(items, item.uid)
- end
- end
- end
- end
- return items
- end
- function doPlayerAddItemStacking(cid, itemid, quant) -- by Mkalo
- local item = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemid)
- local piles = 0
- if #item > 0 then
- for i, x in pairs(item) do
- if getThing(x).type < 100 then
- local it = getThing(x)
- doTransformItem(it.uid, itemid, it.type+quant)
- if it.type+quant > 100 then
- doPlayerAddItem(cid, itemid, it.type+quant-100)
- end
- else
- piles = piles+1
- end
- end
- else
- return doPlayerAddItem(cid, itemid, quant)
- end
- if piles == #item then
- doPlayerAddItem(cid, itemid, quant)
- end
- end
- function AutomaticDeposit(cid, item, n)
- local deposit = item == tonumber(2160) and (n*10000) or tonumber(item) == 2152 and (n*100) or (n*1)
- return doPlayerDepositMoney(cid, deposit)
- end
- function corpseRetireItems(cid, corpseID, corpsePos) -- Aperfeiçoada por Adriano Swatt'
- pid = getPlayerByNameWildcard(cid)
- if isPlayer(pid) then
- checkCorpse = getTileItemById(corpsePos, corpseID)
- if checkCorpse.uid > 0 and isContainer(checkCorpse.uid) then
- local items = getContainerItems(checkCorpse.uid)
- for i, x in pairs(items) do
- if isInArray(getPlayerStorageTable(pid, 27000), tonumber(x.itemid)) then
- if doRemoveItem(x.uid) then
- if isItemStackable(x.itemid) then
- doPlayerAddItemStacking(pid, x.itemid, x.type)
- if info.AutomaticDeposit == true and isInArray({"2148","2152","2160"}, tonumber(x.itemid)) then
- AutomaticDeposit(pid, x.itemid, x.type)
- if x.type == 1 then
- doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, ""..x.type.." gold coin was automatically transferred to the bank of your account by AutoLoot Script.")
- else
- doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, ""..x.type.." gold coins were automatically transferred to the bank of your account by AutoLoot Script.")
- end
- else
- doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, "You take "..x.type.." "..getItemNameById(x.itemid).." from AutoLoot script.")
- end
- else
- doPlayerAddItem(pid, x.itemid)
- doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, "You take "..getItemNameById(x.itemid).." from AutoLoot script.")
- end
- end
- end
- end
- end
- end
- end]]></config>
- <event type="login" name="LootLogin" event="script"><![CDATA[
- function onLogin(cid)
- registerCreatureEvent(cid, "MonsterAttack")
- return true
- end]]></event>
- <event type="death" name="LootEventDeath" event="script"><![CDATA[
- domodlib('Loot_func')
- function onDeath(cid, corpse, deathList) -- Aperfeiçoada por Adriano Swatt'
- if isCreature(cid) and isCreature(deathList[1]) then
- local getMostDmgTab = {}
- local getMostDmgCID = {}
- local pos = getThingPos(cid)
- local corpseID = corpse.itemid
- for z = 1, #deathList do
- killer = deathList[z]
- if not isPlayer(killer) then
- killer = getCreatureMaster(deathList[z])
- if isPlayer(killer) then
- else
- return true
- end
- end
- getOldExp = getPlayerStorageValue(killer, 25666)
- resultExp = getPlayerExperience(killer) - getOldExp
- if getMostDmgTab[1] ~= nil and resultExp >= getMostDmgTab[1] then
- table.insert(getMostDmgTab, 1, resultExp)
- table.insert(getMostDmgCID, 1, killer)
- else
- table.insert(getMostDmgTab, resultExp)
- table.insert(getMostDmgCID, killer)
- end
- if z+1 > #deathList then -- FIM DA CHECAGEM DE MAIOR DANO
- addEvent(corpseRetireItems, 1, getCreatureName(getMostDmgCID[1]), corpseID, pos)
- end
- end
- end
- return true
- end]]></event>
- <event type="combat" name="MonsterAttack" event="script"><![CDATA[
- domodlib('Loot_func')
- if isPlayer(cid) and isMonster(target) and not isInArray(info.BlockMonsters,string.lower(getCreatureName(target))) then
- setPlayerStorageValue(cid, 25666, getPlayerExperience(cid))
- registerCreatureEvent(target, "LootEventDeath")
- end
- return true]]></event>
- <talkaction words="!autoloot;/autoloot" event="buffer"><![CDATA[
- domodlib('Loot_func')
- local t = string.explode(string.lower(param), ",")
- if info.OnlyPremium == true and not isPremium(cid) then
- doPlayerSendCancel(cid, "you must be a premium account.") return true
- elseif not t[1] then
- ShowItemsTabble(cid) return true
- elseif tonumber(t[1]) or tonumber(t[2]) then
- doPlayerSendCancel(cid, "Say !autoloot add, item name or !autoloot remove, item name") return true
- elseif tostring(t[1]) == "add" then
- local item = getItemIdByName(tostring(t[2]), false)
- if not item then
- doPlayerSendCancel(cid, "This item does not exist [Say !autoloot add, item name].") return true
- elseif isInArray(info.BlockItemsList, item) then
- doPlayerSendCancel(cid, "You can not add this item in the list!") return true
- elseif isInTable(cid, item) then
- doPlayerSendCancel(cid, "This item already in your list.") return true
- end
- addItemTable(cid, item)
- elseif tostring(t[1]) == "remove" then
- local item = getItemIdByName(tostring(t[2]), false)
- if not item then
- doPlayerSendCancel(cid, "This item does not exist [Say !autoloot remove, item name or !autoloot clean].") return true
- elseif not isInTable(cid, item) then
- doPlayerSendCancel(cid, "This item isn't in your list.") return true
- end
- removeItemTable(cid, item)
- elseif tostring(t[1]) == "clean" then
- setPlayerStorageValue(cid, 27000, -1)
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "AutoLoot List cleaned sucessfully.") return true
- end
- return true]]></talkaction>
- </mod>
Add Comment
Please, Sign In to add comment