Advertisement
Guest User

Untitled

a guest
Jun 9th, 2016
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. --- Config ---
  2. local config = {
  3. noMoneyLoss = false, -- Set this to true if you dont want players to lose money by being killed by a player
  4. noItemLoss = false, -- Set this to true if you dont want players to lose any items.
  5. noVocLoss = true, -- If this is set to true, and the player has no vocation dont lose any items
  6. realAOL = true, -- Set this to true if you want AOL to be ignored if player has skull (Make it work like Real Tibia)
  7. bankLossPercent = 10, -- This is the percent of the players totoal bank balance they will lose
  8.  
  9. -- You can add extra items here that can prevent item loss
  10. itemProtection = {
  11. -- Amulet of loss
  12. [1] = {
  13. item = {
  14. id = 2173, -- The ID of any the item
  15. slot = CONST_SLOT_NECKLACE, -- Slot that the item must be in
  16. },
  17. },
  18. },
  19.  
  20. -- You can add extra items here that can prevent item Money loss
  21. moneyProtection = {
  22. -- Amulet of loss
  23. [1] = {
  24. item = {
  25. id = 2173, -- The ID of any the item
  26. slot = CONST_SLOT_NECKLACE, -- Slot that the item must be in
  27. },
  28. },
  29. },
  30. }
  31. -- End Config
  32.  
  33. -- Custom Functions ---
  34. local function dropItems(player, corpse)
  35. for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
  36. local item = player:getSlotItem(i)
  37. if item then
  38. if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) or math.random(item:isContainer() and 100 or 1000) <= player:getLossPercent() then
  39. if not item:moveTo(corpse) then
  40. item:remove()
  41. end
  42. end
  43. end
  44. end
  45. end
  46.  
  47. local function dropBankMoney(player, killer)
  48. local money = player:getBankBalance() / 100 * config.bankLossPercent
  49. local killerName = killer:getName()
  50. local playerName = player:getName()
  51.  
  52. -- Player actions
  53. player:setBankBalance(player:getBankBalance() - money)
  54. player:sendTextMessage(MESSAGE_STATUS_WARNING, killerName.." stole "..money.." gold from your bank!")
  55.  
  56. -- Killer actions
  57. killer:addMoney(money)
  58. killer:sendTextMessage(MESSAGE_STATUS_WARNING, "You stole "..money.." from "..playerName.."!")
  59. end
  60. -- End Custom Functions --
  61.  
  62.  
  63. -- Script --
  64. function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
  65.  
  66. -- Dont lose anything if player has no vocation.
  67. if config.noVocLose == true then
  68. if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
  69. return true
  70. end
  71. end
  72.  
  73. -- Check if player was killed by another player if true drop % of players bank balance
  74. local isPlayer = false
  75. if killer then
  76.  
  77. if killer:isPlayer() then
  78. isPlayer = true
  79. else
  80. local playerSummon = killer:getMaster()
  81. if playerSummon and playerSummon:isPlayer() then
  82. isPlayer = true
  83. end
  84. end
  85. end
  86.  
  87. if isPlayer == true and config.noMoneyLoss == false then
  88. dropBankMoney(player, killer)
  89. end
  90.  
  91. -- Dont lose any items if player has an item in the above array
  92. local i = {}
  93. if config.noItemLoss == false then
  94. for i = 1, #config.items do
  95.  
  96. -- Check if player has a item protection item in the correct slot
  97. if player:getSlotItem(config.items[i].item.slot) == config.items[i].item.id then
  98.  
  99. -- 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.
  100. if player:hasItem(config.items[i].item.id) == ITEM_AMULETOFLOSS and config.realAOL == true then
  101. if not isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) or not player:hasBlessing(6) then
  102. player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
  103. break;
  104. return true
  105. else
  106. player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
  107. player:dropItems(player, corpse)
  108. end
  109. end
  110.  
  111. -- If player has another proctection item, remove it and dont drop items
  112. player:removeItem(config.items[i].item.id)
  113. break;
  114. return true
  115. end
  116.  
  117. -- If player doesnt have an item protection item in the right slot or doesnt have blessing, drop items.
  118. if player:getSlotItem(config.items[i].item.slot) ~= config.items[i].item.id or not player:hasBlessing(6) then
  119. dropItems(player, corpse)
  120. end
  121.  
  122. -- Give player a bag on death.
  123. if not player:getSlotItem(CONST_SLOT_BACKPACK) then
  124. player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
  125. end
  126. end
  127. end
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement