Advertisement
jdrecarp

Frag Reward (TFS 0.3/0.4)

Jan 25th, 2015
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. local config = {
  2.     useTrophy = "no", -- Use the trophy reward system?
  3.     useHeart = "yes", -- Use the heart reward system?
  4.     killers = 1 -- The # of people whom receive the reward.
  5. }
  6.  
  7. local BRONZE, SILVER, GOLD = 10129, 10128, 10127
  8. function onDeath(cid, corpse, deathList)
  9.     local reward, var = 0, {
  10.         KILLER_NAME = getCreatureName(deathList),
  11.         TARGET_NAME = getCreatureName(cid),
  12.         KILLER_LEVEL = getPlayerLevel(deathList),
  13.         TARGET_LEVEL = getPlayerLevel(cid)
  14.     }
  15.     config.useTrophy = getBooleanFromString(config.useTrophy)
  16.     config.useHeart = getBooleanFromString(config.useHeart)
  17.     local worldType = getConfigValue("worldType")
  18.     if(worldType == "open") then
  19.         for i = 1, config.killers do
  20.             if(isPlayer(cid) and isPlayer(deathList)) then
  21.                 if(getPlayerIp(cid) ~= getPlayerIp(deathList)) then
  22.                
  23.                     if(var.TARGET_LEVEL > 8 and var.TARGET_LEVEL < 100) then
  24.                         reward = BRONZE
  25.                     elseif(var.TARGET_LEVEL > 99 and var.TARGET_LEVEL < 200) then
  26.                         reward = SILVER
  27.                     elseif(var.TARGET_LEVEL > 199) then
  28.                         reward = GOLD
  29.                     end
  30.                    
  31.                     local trophy, heart = 0, 0
  32.                     if(config.useHeart) then
  33.                         heart = doAddContainerItem(corpse.uid, 5943, 1)
  34.                     end
  35.                     if(config.useTrophy) then
  36.                         trophy = doPlayerAddItem(deathList, reward, 1)
  37.                     end
  38.                    
  39.                     local killers = ""
  40.                     for i = 1, math.min(getConfigInfo('deathAssistCount') + 1, #deathList) do
  41.                         killers = killers .. (i == 1 and "" or ", ") .. (isMonster(deathList) and "a " or "") .. getCreatureName(deathList)
  42.                     end
  43.                     if(config.useHeart) then
  44.                         doItemSetAttribute(heart, "name", "Heart of " .. var.TARGET_NAME)
  45.                         doItemSetAttribute(heart, "description", "It was taken from " .. var.TARGET_NAME .. "'s body. " .. (getPlayerSex(cid) == 0 and "She" or "He") .. " was killed at level " .. var.TARGET_LEVEL .. " by " .. var.KILLER_NAME .. ". " .. (getCreatureSkullType(cid) <= SKULL_GREEN and "(Unjustified)" or "(Justified)"))
  46.                     end
  47.                     if(config.useTrophy) then
  48.                         doItemSetAttribute(trophy, "description", "It was awarded to " .. var.KILLER_NAME .. " for killing " .. var.TARGET_NAME .. ". " .. (getPlayerSex(cid) == 0 and "She" or "He") .. " was killed at level " .. var.TARGET_LEVEL .. " by " .. var.KILLER_NAME .. " who was level " .. var.KILLER_LEVEL .. " at the time. " .. (getCreatureSkullType(cid) <= SKULL_GREEN and "(Unjustified)" or "(Justified)"))
  49.                     end
  50.                     doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
  51.                 end
  52.             end
  53.         end
  54.     end
  55.     return true
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement