Koenrad

DeathMSG

Nov 3rd, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.00 KB | None | 0 0
  1. __author__ = 'DreTaX'
  2. __version__ = '1.4'
  3.  
  4. import clr
  5.  
  6. clr.AddReferenceByPartialName("Pluton")
  7. import Pluton
  8. import math
  9. import System
  10. from System import *
  11.  
  12. """
  13.    Brought to you by XCorrosionX and DreTaX
  14.    KLS support by koenrad
  15. """
  16.  
  17. class DeathMSG:
  18.     BodyParts = {
  19.     '2801294865': 'Head',
  20.     '4040387367': 'Head',
  21.     '1607781229': 'Head',
  22.     '2910575312': 'Head',
  23.     '2341211393': 'Head',
  24.     '2881065196': 'Body',
  25.     '405856008': 'Body',
  26.     '497750834': 'Body',
  27.     '2107788330': 'Body',
  28.     '998083258': 'Body',
  29.     '1469249236': 'Body',
  30.     '3856158477': 'Body',
  31.     '487549081': 'Body',
  32.     '1819052778': 'Legs',
  33.     '3428008992': 'Legs',
  34.     '3847102050': 'Legs',
  35.     '2868606315': 'Foot',
  36.     '2590633211': 'Foot',
  37.     '1020274123': 'Foot',
  38.     '935136153': 'Hand',
  39.     '3847415609': 'Hand',
  40.     '1286581443': 'Hand'
  41.     }
  42.     LevelingSystem = False
  43.  
  44.     @staticmethod
  45.     def DeathMSGConfig():
  46.         if not Plugin.IniExists("DeathMSGConfig"):
  47.             loc = Plugin.CreateIni("DeathMSGConfig")
  48.             loc.AddSetting("Settings", "SysName", "Equinox DeathMSG")
  49.             loc.AddSetting("Settings", "NaturalDies", "1")
  50.             loc.AddSetting("Settings", "KillLog", "1")
  51.             loc.AddSetting("Settings", "SuicideMsg", "victim suicided...")
  52.             loc.AddSetting("Settings", "Bite", "victim was Bitten to Death")
  53.             loc.AddSetting("Settings", "BluntTrauma", "victim died from a Blunt Trauma")
  54.             loc.AddSetting("Settings", "Heat", "victim died from heat")
  55.             loc.AddSetting("Settings", "Hunger", "victim died from starvation")
  56.             loc.AddSetting("Settings", "Radiation", "victim died from radiation")
  57.             loc.AddSetting("Settings", "Thirst", "victim died from dehydration")
  58.             loc.AddSetting("Settings", "FallMsg", "victim died because he fell off from something")
  59.             loc.AddSetting("Settings", "BledMsg", "victim bled out. He was killed by: killer")
  60.             loc.AddSetting("Settings", "BledMsg2", "victim bled out.")
  61.             loc.AddSetting("Settings", "DrownedMsg", "victim Drowned")
  62.             loc.AddSetting("Settings", "ColdMsg", "victim Caught Cold, and died.")
  63.             loc.AddSetting("Settings", "XyzMsg", "victim suicided....")
  64.             loc.AddSetting("Settings", "KillMessage", "victim was killed by killer | Damage: dmg | Distance: dist | With: weapon | Part: bodypart")
  65.             loc.Save()
  66.         return Plugin.GetIni("DeathMSGConfig")
  67.  
  68.  
  69.     def On_PluginInit(self):
  70.         self.DeathMSGConfig()
  71.         Plugin.CreateTimer("PluginCheckTimer", 1000).Start()
  72.  
  73.     def IsNatural(self, type):
  74.         ini = self.DeathMSGConfig()
  75.         msg = ini.GetSetting("Settings", type)
  76.         if type == "Bite":
  77.             return msg
  78.         elif type == "BluntTrauma":
  79.             return msg
  80.         elif type == "Heat":
  81.             return msg
  82.         elif type == "Hunger":
  83.             return msg
  84.         elif type == "Radiation":
  85.             return msg
  86.         elif type == "Thirst":
  87.             return msg
  88.         return False
  89.  
  90.     def On_PlayerDied(self, PlayerDeathEvent):
  91.         if PlayerDeathEvent.Attacker.ToPlayer() is None:
  92.             return
  93.  
  94.         attacker = PlayerDeathEvent.Attacker
  95.         victim = PlayerDeathEvent.Victim
  96.         victimID = str(victim.SteamID)
  97.         attackerID = str(attacker.userID)
  98.         if self.LevelingSystem:
  99.             #get levels
  100.             attackerLVL = str(self.getLvl(attackerID))
  101.             victimLVL = str(self.getLvl(victimID))
  102.             #add [lvl X] after the name
  103.             attackername = str(attacker.displayName) + "[lvl " + attackerLVL + "]"
  104.             victimname = str(victim.Name) + "[lvl " + victimLVL + "]"
  105.         else:
  106.             attackername = str(attacker.displayName)
  107.             victimname = str(victim.Name)
  108.  
  109.         if attackerID == victimID:
  110.             ini = self.DeathMSGConfig()
  111.             NaturalDies = ini.GetSetting("Settings", "NaturalDies")
  112.             sysname = ini.GetSetting("Settings", "SysName")
  113.             if int(NaturalDies) == 1:
  114.                 type = str(PlayerDeathEvent.DamageType)
  115.                 if self.IsNatural(type) and self.IsNatural(type) is not False:
  116.                     ntrmsg = ini.GetSetting("Settings", "NaturalMsg")
  117.                     ntrmsg = ntrmsg.replace("victim", victimname)
  118.                     #ntrmsg = ntrmsg.replace("type", type)
  119.                     Server.BroadcastFrom(sysname, ntrmsg)
  120.                 elif type == "Generic":
  121.                     cmsg = ini.GetSetting("Settings", "XyzMsg")
  122.                     cmsg = cmsg.replace("victim", victimname)
  123.                     Server.BroadcastFrom(sysname, cmsg)
  124.                 elif type == "Suicide":
  125.                     smsg = ini.GetSetting("Settings", "SuicideMsg")
  126.                     smsg = smsg.replace("victim", victimname)
  127.                     Server.BroadcastFrom(sysname, smsg)
  128.                 elif type == "Fall":
  129.                     fmsg = ini.GetSetting("Settings", "FallMsg")
  130.                     fmsg = fmsg.replace("victim", victimname)
  131.                     Server.BroadcastFrom(sysname, fmsg)
  132.                 elif type == "Drowned":
  133.                     dmsg = ini.GetSetting("Settings", "DrownedMsg")
  134.                     dmsg = dmsg.replace("victim", victimname)
  135.                     Server.BroadcastFrom(sysname, dmsg)
  136.                 elif type == "Cold":
  137.                     cmsg = ini.GetSetting("Settings", "ColdMsg")
  138.                     cmsg = cmsg.replace("victim", victimname)
  139.                     Server.BroadcastFrom(sysname, cmsg)
  140.                 elif type == "Bleeding":
  141.                     bmsg = ini.GetSetting("Settings", "BledMsg2")
  142.                     bmsg = bmsg.replace("victim", victimname)
  143.                     Server.BroadcastFrom(sysname, bmsg)
  144.         elif attackerID != victimID:
  145.             ini = self.DeathMSGConfig()
  146.             sysname = ini.GetSetting("Settings", "SysName")
  147.             dmgmsg = ini.GetSetting("Settings", "KillMessage")
  148.             type = str(PlayerDeathEvent.DamageType)
  149.             weapon = str(PlayerDeathEvent._info.Weapon.info.displayname)
  150.             if type == "Bullet" or type == "Slash":
  151.                 bodypart = str(PlayerDeathEvent._info.HitPart)
  152.                 vloc = victim.Location
  153.                 aloc = attacker.transform.position
  154.                 dist = round(Util.GetVectorsDistance(vloc, aloc), 2)
  155.                 damage = PlayerDeathEvent.DamageAmount
  156.                 dmgmsg = dmgmsg.replace("killer", str(attackername))
  157.                 dmgmsg = dmgmsg.replace("victim", victimname)
  158.                 dmgmsg = dmgmsg.replace("dmg", str(damage))
  159.                 dmgmsg = dmgmsg.replace("dist", str(dist))
  160.                 dmgmsg = dmgmsg.replace("weapon", weapon)
  161.                 try:
  162.                     dmgmsg = dmgmsg.replace("bodypart", str(self.BodyParts[bodypart]))
  163.                 except KeyError:
  164.                     dmgmsg = dmgmsg.replace("bodypart", "Unknown")
  165.                 KillLog = ini.GetSetting("Settings", "KillLog")
  166.                 Server.BroadcastFrom(sysname, dmgmsg)
  167.                 if int(KillLog) == 1:
  168.                     Plugin.Log("KillLog", str(System.DateTime.Now) + " " + dmgmsg)
  169.             elif type == "Bleeding":
  170.                 bmsg = ini.GetSetting("Settings", "BledMsg")
  171.                 bmsg = bmsg.replace("victim", victimname)
  172.                 bmsg = bmsg.replace("killer", attackername)
  173.                 Server.BroadcastFrom(sysname, bmsg)
  174.  
  175.     def PluginCheckTimerCallback(self, timer):
  176.         self.LevelingSystem = self.checkPlugin("KoenradsLevelingSystem")
  177.         timer.Kill()
  178.  
  179.     @staticmethod
  180.     def checkPlugin(name):
  181.         try:
  182.             Plugin.GetPlugin(name)
  183.         except KeyError:
  184.             return False
  185.         return True
  186.  
  187.     @staticmethod
  188.     def getLvl(userID):
  189.         if not DataStore.ContainsKey("level", userID):
  190.                 DataStore.Add("level", userID, 1)
  191.                 return 1
  192.         else:
  193.             return DataStore.Get("level", userID)
Advertisement
Add Comment
Please, Sign In to add comment