Debian Codegraph @

python/events/death/autojail.py

raw
1 #
2 # This module will automaticall arrest players killing other players,
3 # provided the option was activated by a DM through 'autojail 1'.
4 # Note the settings defaults to 0 and isn't kept during server resets.
5
6 import Crossfire
7
8
9 def check_autojail():
10 killer = Crossfire.WhoIsActivator()
11
12 # If a player dies by starvation, there is no killer.
13 # Bail if that is the case.
14 if killer is None:
15 return
16
17 if killer.Type != Crossfire.Type.PLAYER or killer.DungeonMaster:
18 return
19
20 dict = Crossfire.GetSharedDictionary()
21 if not 'autojail' in dict or dict['autojail'] != 1:
22 return
23
24 victim = Crossfire.WhoAmI()
25 killer.Message('You are auto-jailed for PKing %s'%victim.Name)
26 ret = killer.Arrest()
27 if ret == 0:
28 msg = '%s was auto-jailed for PKing %s'%(killer.Name, victim.Name)
29 else:
30 msg = 'Failed to auto-jail %s for PKing %s, code %d'%(killer.Name, victim.Name, ret)
31 players = Crossfire.GetPlayers()
32 for player in players:
33 if player.DungeonMaster:
34 player.Message(msg)
35
36 check_autojail()