diff --git a/python/commands/autojail.py b/python/commands/autojail.py new file mode 100644 index 000000000..a8e388a37 --- /dev/null +++ b/python/commands/autojail.py @@ -0,0 +1,18 @@ +import Crossfire + +who = Crossfire.WhoAmI() + +if who.DungeonMaster: + value = Crossfire.ScriptParameters() + dict = Crossfire.GetSharedDictionary() + if value == '1': + dict['autojail'] = 1 + who.Message('Autojail enabled') + elif value == '0': + dict['autojail'] = 0 + who.Message('Autojail disabled') + else: + autojail = 0 + if 'autojail' in dict and dict['autojail'] == 1: + autojail = 1 + who.Message('Autojail is %d'%autojail) diff --git a/python/events/death/autojail.py b/python/events/death/autojail.py new file mode 100644 index 000000000..cffe2d747 --- /dev/null +++ b/python/events/death/autojail.py @@ -0,0 +1,31 @@ +# +# This module will automaticall arrest players killing other players, +# provided the option was activated by a DM through 'autojail 1'. +# Note the settings defaults to 0 and isn't kept during server resets. + +import Crossfire + + +def check_autojail(): + killer = Crossfire.WhoIsActivator() + + if killer.Type != Crossfire.Type.PLAYER or killer.DungeonMaster: + return + + dict = Crossfire.GetSharedDictionary() + if not 'autojail' in dict or dict['autojail'] != 1: + return + + victim = Crossfire.WhoAmI() + killer.Message('You are auto-jailed for PKing %s'%victim.Name) + ret = killer.Arrest() + if ret == 0: + msg = '%s was auto-jailed for PKing %s'%(killer.Name, victim.Name) + else: + msg = 'Failed to auto-jail %s for PKing %s, code %d'%(killer.Name, victim.Name, ret) + players = Crossfire.GetPlayers() + for player in players: + if player.DungeonMaster: + player.Message(msg) + +check_autojail() diff --git a/python/events/init/autojail_command.py b/python/events/init/autojail_command.py new file mode 100644 index 000000000..2599010c4 --- /dev/null +++ b/python/events/init/autojail_command.py @@ -0,0 +1,2 @@ +import Crossfire +Crossfire.RegisterCommand("autojail", "/python/commands/autojail", 0) diff --git a/python/events/login/autojail_login.py b/python/events/login/autojail_login.py new file mode 100644 index 000000000..81e6cbc04 --- /dev/null +++ b/python/events/login/autojail_login.py @@ -0,0 +1,7 @@ +import Crossfire + +dict = Crossfire.GetSharedDictionary() + +if 'autojail' in dict and dict['autojail'] == 1: + activator = Crossfire.WhoIsActivator() + activator.Message("Notice: killing another player will automatically send you to jail.")