Advertisement
Guest User

Untitled

a guest
Jan 18th, 2015
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.74 KB | None | 0 0
  1. # firstkill Plugin
  2.  
  3. __author__ = 'PtitBigorneau www.ptitbigorneau.fr'
  4. __version__ = '1.4.1'
  5.  
  6. import b3
  7. import b3.plugin
  8. import b3.events
  9.  
  10. class FirstkillPlugin(b3.plugin.Plugin):
  11.  
  12. _adminPlugin = None
  13. _kill = 0
  14. _tk = 0
  15. _hs = 0
  16.  
  17. def onStartup(self):
  18.  
  19. self._adminPlugin = self.console.getPlugin('admin')
  20.  
  21. if not self._adminPlugin:
  22.  
  23. self.error('Could not find admin plugin')
  24. return False
  25.  
  26. self.registerEvent(b3.events.EVT_CLIENT_KILL)
  27. self.registerEvent(b3.events.EVT_CLIENT_KILL_TEAM)
  28. self.registerEvent(b3.events.EVT_GAME_ROUND_START)
  29.  
  30. self._adminPlugin.registerCommand(self, 'firstkill',self._adminlevel, self.cmd_firstkill)
  31. self._adminPlugin.registerCommand(self, 'firsttk',self._adminlevel, self.cmd_firsttk)
  32.  
  33. self.gamename = self.console.game.gameName
  34.  
  35. if self.gamename == 'iourt41':
  36. self._adminPlugin.registerCommand(self, 'firsths',self._adminlevel, self.cmd_firsths)
  37.  
  38. def onLoadConfig(self):
  39.  
  40. self._tkonoff = self.config.get('settings', 'tkonoff')
  41. self._fkonoff = self.config.get('settings', 'fkonoff')
  42. self._hsonoff = self.config.get('settings', 'hsonoff')
  43. self._adminlevel = self.config.get('settings', 'adminlevel')
  44.  
  45. def onEvent(self, event):
  46.  
  47. if event.type == b3.events.EVT_GAME_ROUND_START:
  48.  
  49. self._kill =0
  50. self._tk =0
  51. self._hs =0
  52.  
  53. if event.type == b3.events.EVT_CLIENT_KILL:
  54.  
  55. self._kill += 1
  56.  
  57. client = event.client
  58. target = event.target
  59.  
  60. if self.gamename == 'iourt41':
  61.  
  62. weapon = event.data[1]
  63. hitlocation = event.data[2]
  64.  
  65. else:
  66.  
  67. weapon = 99
  68. hitlocation = 99
  69. self._hsonoff = "no"
  70.  
  71. if weapon not in (23, 25):
  72.  
  73. if hitlocation == "0" or hitlocation == "1":
  74.  
  75. self._hs += 1
  76.  
  77. if self._fkonoff == "on":
  78.  
  79. if self._kill == 1:
  80.  
  81. if self.gamename == 'iourt41':
  82.  
  83. if self._hs == 1 and self._hsonoff == "on":
  84.  
  85. self.console.saybig("^7First Kill By ^5Headshot ^3: %s ^7killed %s" % (client.exactName, target.exactName))
  86. self._hs += 1
  87. return
  88.  
  89. else:
  90.  
  91. self.console.saybig("^7First Kill ^3: %s ^7killed %s" % (client.exactName, target.exactName))
  92.  
  93. elif self.gamename[:3] == "cod":
  94.  
  95. self.console.saybig("^7First Kill ^3: %s ^7killed %s" % (client.exactName, target.exactName))
  96.  
  97. else:
  98.  
  99. self.console.saybig("^7First Kill ^3: %s ^7killed %s" % (client.exactName, target.exactName))
  100.  
  101. if self._hsonoff == "on":
  102.  
  103. if self._kill == 1:
  104.  
  105. return
  106.  
  107. if self._hs == 1:
  108.  
  109. self.console.saybig("^7First Kill by ^5Headshot ^3: %s" % (client.exactName))
  110. self._hs += 1
  111.  
  112. if (event.type == b3.events.EVT_CLIENT_KILL_TEAM) and (self._tkonoff=="on"):
  113.  
  114. self._tk += 1
  115.  
  116. client = event.client
  117. target = event.target
  118.  
  119. if self._tk == 1:
  120.  
  121. if self.gamename == 'iourt41':
  122.  
  123. self.console.saybig("^7First TeamKill ^3:%s ^7killed %s" % (client.exactName, target.exactName))
  124.  
  125. elif self.gamename[:3] == "cod":
  126.  
  127. self.console.say("^1First TeamKill ^3:%s killed %s" % (client.exactName, target.exactName))
  128.  
  129. else:
  130.  
  131. self.console.saybig("^1First TeamKill ^3:%s killed %s" % (client.exactName, target.exactName))
  132.  
  133. def cmd_firstkill(self, data, client, cmd=None):
  134.  
  135. """\
  136. activate / deactivate firstkill
  137. """
  138.  
  139. if data:
  140.  
  141. input = self._adminPlugin.parseUserCmd(data)
  142.  
  143. else:
  144.  
  145. if self._fkonoff == 'on':
  146.  
  147. client.message('firstkill ^2activated')
  148.  
  149. if self._fkonoff == 'off':
  150.  
  151. client.message('firstkill ^1deactivated')
  152.  
  153. client.message('!firstkill <on / off>')
  154. return
  155.  
  156. if input[0] == 'on':
  157.  
  158. if self._fkonoff != 'on':
  159.  
  160. self._fkonoff = 'on'
  161. message = '^2activated'
  162.  
  163. else:
  164.  
  165. client.message('firstkill is already ^2activated')
  166.  
  167. return False
  168.  
  169. if input[0] == 'off':
  170.  
  171. if self._fkonoff != 'off':
  172.  
  173. self._fkonoff = 'off'
  174. message = '^1deactivated'
  175.  
  176. else:
  177.  
  178. client.message('firstkill is already ^1disabled')
  179.  
  180. return False
  181.  
  182. client.message('firstkill %s'%(message))
  183.  
  184. def cmd_firsttk(self, data, client, cmd=None):
  185.  
  186. """\
  187. activate / deactivate first teamkill
  188. """
  189.  
  190. if data:
  191.  
  192. input = self._adminPlugin.parseUserCmd(data)
  193.  
  194. else:
  195.  
  196. if self._tkonoff == 'on':
  197.  
  198. client.message('first teamkill ^2activated')
  199.  
  200. if self._tkonoff == 'off':
  201.  
  202. client.message('first teamkill ^1deactivated')
  203.  
  204. client.message('!firsttk <on / off>')
  205. return
  206.  
  207. if input[0] == 'on':
  208.  
  209. if self._tkonoff != 'on':
  210.  
  211. self._tkonoff = 'on'
  212. message = '^2activated'
  213.  
  214. else:
  215.  
  216. client.message('first teamkill is already ^2activated')
  217.  
  218. return False
  219.  
  220. if input[0] == 'off':
  221.  
  222. if self._tkonoff != 'off':
  223.  
  224. self._tkonoff = 'off'
  225. message = '^1deactivated'
  226.  
  227. else:
  228.  
  229. client.message('first teamkill is already ^1disabled')
  230.  
  231. return False
  232.  
  233. client.message('first teamkill %s'%(message))
  234.  
  235. def cmd_firsths(self, data, client, cmd=None):
  236.  
  237. """\
  238. activate / deactivate first headshot
  239. """
  240.  
  241. if data:
  242.  
  243. input = self._adminPlugin.parseUserCmd(data)
  244.  
  245. else:
  246.  
  247. if self._hsonoff == 'on':
  248.  
  249. client.message('first headshot ^2activated')
  250.  
  251. if self._hsonoff == 'off':
  252.  
  253. client.message('first headshot ^1deactivated')
  254.  
  255. client.message('!firsths <on / off>')
  256. return
  257.  
  258. if input[0] == 'on':
  259.  
  260. if self._hsonoff != 'on':
  261.  
  262. self._hsonoff = 'on'
  263. message = '^2activated'
  264.  
  265. else:
  266.  
  267. client.message('first headshot is already ^2activated')
  268.  
  269. return False
  270.  
  271. if input[0] == 'off':
  272.  
  273. if self._hsonoff != 'off':
  274.  
  275. self._hsonoff = 'off'
  276. message = '^1deactivated'
  277.  
  278. else:
  279.  
  280. client.message('first headshot is already ^1disabled')
  281.  
  282. return False
  283.  
  284. client.message('first headshot %s'%(message))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement