MaXwEllDeN

Untitled

Jun 16th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.21 KB | None | 0 0
  1. local config = {
  2.     affected = 10, -- how many players (deathAssits) from table deathList should this script be executed for?
  3.     killStorageValue = 9943,
  4.     deathStorageValue = 9944,
  5.     -- commands for the texts (those inside of ||, example: |KILLS| to show skills): KILLS, KILLERNAME, TARGETNAME
  6.     rewardItem = {
  7.         use = true,
  8.         itemid = 2152,
  9.         minLevel = false, -- false if you don't want any level req
  10.         minLevelDiff = false, -- false if you don't want any level diff req (negative numbers allowed).
  11.     },
  12.  
  13.     killMessage = {
  14.         use = true,
  15.         text = "You owned |TARGETNAME|!",
  16.         messageClass = MESSAGE_STATUS_CONSOLE_RED
  17.     },
  18.  
  19.     broadcastMessage = {
  20.         use = true,
  21.         minLevel = false, -- false if you don't want any level req
  22.         minLevelDiff = false, -- false if you don't want any level diff req (negative numbers allowed).
  23.         text = "|KILLERNAME| [|KILLERLEVEL|] matou |TARGETNAME| [|TARGETLEVEL|]",
  24.         messageClass = MESSAGE_STATUS_CONSOLE_BLUE
  25.     },
  26.  
  27.     killerAnimation = {
  28.         use = true,
  29.         text = "Frag!", -- Only 9 letters! No "commands" here.
  30.         color = 144
  31.     },
  32.  
  33.     targetAnimation = {
  34.         use = true,
  35.         text = "Owned!", -- Only 9 letters! No "commands" here.
  36.         color = 180
  37.     }
  38. }
  39.  
  40. function formateString(str)
  41.     return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
  42. end
  43.  
  44. function onDeath(cid, corpse, deathList)
  45.     for i = 1, math.min(config.affected, getConfigInfo('deathAssistCount')) do
  46.  
  47.     local killer = deathList[i]
  48.  
  49.         if(isPlayer(killer) == TRUE) then
  50.             local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1
  51.             local targetDeaths = math.max(0, getPlayerStorageValue(cid, config.deathStorageValue)) + 1
  52.  
  53.             local killerKills = math.max(0, getPlayerStorageValue(killer, config.killStorageValue)) + 1
  54.             local killerDeaths = math.max(0, getPlayerStorageValue(killer, config.deathStorageValue)) + 1
  55.  
  56.             setPlayerStorageValue(killer, config.killStorageValue, targetKills)
  57.             setPlayerStorageValue(cid, config.deathStorageValue, targetDeaths)
  58.  
  59.             local killerLevel = getPlayerLevel(killer)
  60.             local targetLevel = getPlayerLevel(cid)
  61.             local levelDiff = targetLevel - killerLevel
  62.  
  63.             local values = {
  64.                 ["KILLERKILLS"] = killerKills,
  65.                 ["KILLERDEATHS"] = killerDeaths,
  66.                 ["KILLERNAME"] = getCreatureName(killer),
  67.                 ["KILLERLEVEL"] = killerLevel,
  68.  
  69.                 ["TARGETKILLS"] = targetKills,
  70.                 ["TARGETDEATHS"] = targetDeaths,
  71.                 ["TARGETNAME"] = getCreatureName(cid),
  72.                 ["TARGETLEVEL"] = targetLevel
  73.             }
  74.  
  75.  
  76.             if(config.killMessage.use) then
  77.                 doPlayerSendTextMessage(killer, config.killMessage.messageClass, formateString(config.killMessage.text))
  78.             end
  79.  
  80.             if(config.broadcastMessage.use and (not config.broadcastMessage.minLevel or getPlayerLevel(cid) >= config.broadcastMessage.minLevel) and (not config.broadcastMessage.minLevelDiff or levelDiff >= config.broadcastMessage.minLevelDiff)) then
  81.                 broadcastMessage(formateString(config.broadcastMessage.text), config.broadcastMessage.messageClass)
  82.             end
  83.  
  84.             if(config.killerAnimation.use) then
  85.                 doSendAnimatedText(getCreaturePosition(killer), config.killerAnimation.text, config.killerAnimation.color)
  86.             end
  87.  
  88.             if(config.targetAnimation.use) then
  89.                 doSendAnimatedText(getCreaturePosition(cid), config.targetAnimation.text, config.targetAnimation.color)
  90.             end
  91.         end
  92.     end
  93.  
  94.     return true
  95. end
Advertisement
Add Comment
Please, Sign In to add comment