Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Config ---
- local config = {
- noMoneyLoss = false, -- Set this to true if you dont want players to lose money by being killed by a player
- noItemLoss = false, -- Set this to true if you dont want players to lose any items.
- noVocLoss = true, -- If this is set to true, and the player has no vocation dont lose any items
- realAOL = true, -- Set this to true if you want AOL to be ignored if player has skull (Make it work like Real Tibia)
- bankLossPercent = 10, -- This is the percent of the players totoal bank balance they will lose
- -- You can add extra items here that can prevent item loss
- itemProtection = {
- -- Amulet of loss
- [1] = {
- item = {
- id = 2173, -- The ID of any the item
- slot = CONST_SLOT_NECKLACE, -- Slot that the item must be in
- },
- },
- },
- -- You can add extra items here that can prevent item Money loss
- moneyProtection = {
- -- Amulet of loss
- [1] = {
- item = {
- id = 2173, -- The ID of any the item
- slot = CONST_SLOT_NECKLACE, -- Slot that the item must be in
- },
- },
- },
- }
- -- End Config
- -- Custom Functions ---
- local function dropItems(player, corpse)
- for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
- local item = player:getSlotItem(i)
- if item then
- if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) or math.random(item:isContainer() and 100 or 1000) <= player:getLossPercent() then
- if not item:moveTo(corpse) then
- item:remove()
- end
- end
- end
- end
- end
- local function dropBankMoney(player, killer)
- local money = player:getBankBalance() / 100 * config.bankLossPercent
- local killerName = killer:getName()
- local playerName = player:getName()
- -- Player actions
- player:setBankBalance(player:getBankBalance() - money)
- player:sendTextMessage(MESSAGE_STATUS_WARNING, killerName.." stole "..money.." gold from your bank!")
- -- Killer actions
- killer:addMoney(money)
- killer:sendTextMessage(MESSAGE_STATUS_WARNING, "You stole "..money.." from "..playerName.."!")
- end
- -- End Custom Functions --
- -- Script --
- function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
- -- Dont lose anything if player has no vocation.
- if config.noVocLose == true then
- if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
- return true
- end
- end
- -- Check if player was killed by another player if true drop % of players bank balance
- local isPlayer = false
- if killer then
- if killer:isPlayer() then
- isPlayer = true
- else
- local playerSummon = killer:getMaster()
- if playerSummon and playerSummon:isPlayer() then
- isPlayer = true
- end
- end
- end
- if isPlayer == true and config.noMoneyLoss == false then
- dropBankMoney(player, killer)
- end
- -- Dont lose any items if player has an item in the above array
- local i = {}
- if config.noItemLoss == false then
- for i = 1, #config.items do
- -- Check if player has a item protection item in the correct slot
- if player:getSlotItem(config.items[i].item.slot) == config.items[i].item.id then
- -- If player is wearing an AOL and realAOl is set to true, then check if player has a red or black skull or blessing, If they dont remove the AOL and dont drop items.
- if player:hasItem(config.items[i].item.id) == ITEM_AMULETOFLOSS and config.realAOL == true then
- if not isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) or not player:hasBlessing(6) then
- player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
- break;
- return true
- else
- player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
- player:dropItems(player, corpse)
- end
- end
- -- If player has another proctection item, remove it and dont drop items
- player:removeItem(config.items[i].item.id)
- break;
- return true
- end
- -- If player doesnt have an item protection item in the right slot or doesnt have blessing, drop items.
- if player:getSlotItem(config.items[i].item.slot) ~= config.items[i].item.id or not player:hasBlessing(6) then
- dropItems(player, corpse)
- end
- -- Give player a bag on death.
- if not player:getSlotItem(CONST_SLOT_BACKPACK) then
- player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement