Vi que muitos voltaram, principalmente meu mestre Oneshot, então voltei também. Não sei se voltei pra ficar ativo, mas de qualquer maneira, vou quebrar o gelo e postar um sistema depois de mais de um semestre inativo no fórum.
Sinceramente, a qualidade da seção de scripting caiu consideravelmente. Chega a dar vergonha ver como está andando atualmente em comparação à época de novembro/dezembro do ano passado até fevereiro desse ano, em que deu aqueles problemas. São poucas as coisas que aparecem aqui que realmente são bem feitas. Bom, de qualquer maneira, fazer o quê se a maioria dos membros não consegue ver isso, deixemos rolar e tentemos restaurar o que era, né.
Voltando ao tópico, trouxe pra vocês um sisteminha que funciona como um autoloot, porém, ele looteia apenas money e envia ele direto pra backpack ou direto para o banco do player (configurável), cobrando uma porcentagem do dinheiro looteado como troca pelo serviço. Exemplo, looteou 10 gold coins, cobra 10% (1 gold coin), dando pro player 9 gold coins no total.
Scripts:
Crie um arquivo e data/creaturescripts/scripts com o nome de autoloot.lua e coloque isso dentro:
function onKill(cid, target, lastHit)
local target_pos,target_name = getCreaturePosition(target),getCreatureName(target)
addEvent(executeAutoLoot, 0, cid, target_pos, target_name)
return true
end
<event type="kill" name="AutoLootMoney" script="autoloot.lua"/>
registerCreatureEvent(cid, "AutoLootMoney")
AUTO_LOOT_TAX = 10 -- Tax for using the service (in %) (min 0, max 100)
AUTO_LOOT_BANK = false -- Will the money go to the bank? If false, the money will go to the player
AUTO_LOOT_STORAGE = 38199 -- Storage of the status of the Auto Loot
function findItemsInContainer(ids, container)
local items_found = {}
local v_uids = {}
for i = 0, getContainerSize(container)-1 do
container_item = getContainerItem(container, i)
if isContainer(container_item.uid) then
local container_recursive = findItemsInContainer(ids, container_item.uid)
for a, b in ipairs(container_recursive) do
if not isInArray(v_uids, b.uid) then
table.insert(v_uids, container_item.uid)
table.insert(items_found, b)
end
end
end
if isInArray(ids, container_item.itemid) and not isInArray(v_uids, container_item.uid) then
table.insert(v_uids, container_item.uid)
table.insert(items_found, container_item)
end
end
return items_found
end
function executeAutoLoot(cid, pos, target_name)
AUTO_LOOT_TAX = AUTO_LOOT_TAX > 100 and 100 or AUTO_LOOT_TAX < 0 and 0 or AUTO_LOOT_TAX
local corpse = getTileItemByType(pos, ITEM_TYPE_CONTAINER).uid
local total_count = 0
for a, b in ipairs(findItemsInContainer({ITEM_GOLD_COIN, ITEM_PLATINUM_COIN, ITEM_CRYSTAL_COIN}, corpse)) do
if b.itemid == ITEM_CRYSTAL_COIN then
total_count = total_count+b.type*10000
elseif b.itemid == ITEM_PLATINUM_COIN then
total_count = total_count+b.type*100
elseif b.itemid == ITEM_GOLD_COIN then
total_count = total_count+b.type
end
doRemoveItem(b.uid, b.type)
end
if AUTO_LOOT_BANK then
doPlayerSetBalance(cid, getPlayerBalance(cid)+math.ceil(total_count*(1-AUTO_LOOT_TAX/100)))
else
doPlayerAddMoney(cid, math.ceil(total_count*(1-AUTO_LOOT_TAX/100)))
end
if total_count > 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Money collected from "..target_name..": "..total_count.." gold coins."..(AUTO_LOOT_TAX > 0 and " Tax ("..AUTO_LOOT_TAX.."%) discounted: "..math.floor(total_count*(AUTO_LOOT_TAX/100)).." gold coins." or " No tax."))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Total collected: "..math.ceil(total_count*(1-AUTO_LOOT_TAX/100)).." gold coins.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "No money collected from "..target_name..".")
end
return true
end
function onSay(cid, words, param)
if getPlayerStorageValue(cid, AUTO_LOOT_STORAGE) == -1 then
registerCreatureEvent(cid, "AutoLootMoney")
setPlayerStorageValue(cid, AUTO_LOOT_STORAGE, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Auto Loot Money activated! There's a tax of "..AUTO_LOOT_TAX.."% of the collected money.")
else
unregisterCreatureEvent(cid, "AutoLootMoney")
setPlayerStorageValue(cid, AUTO_LOOT_STORAGE, -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Auto Loot Money deactivated!")
end
return true
end
<talkaction words="/autoloot" event="script" value="autoloot_talk.lua"/>
Edite aqui:
AUTO_LOOT_TAX = 10 -- Tax for using the service (in %) (min 0, max 100) AUTO_LOOT_BANK = false -- Will the money go to the bank? If false, the money will go to the player AUTO_LOOT_STORAGE = 38199 -- Storage of the status of the Auto Loot
- Luck Oake













