-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra_dodkills.py
More file actions
53 lines (40 loc) · 1.7 KB
/
extra_dodkills.py
File metadata and controls
53 lines (40 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
extra_dodkills - Announce vehicle kills that occur inside DoD zones.
Listens for PlayerEnemyKilled events and broadcasts an admin message whenever a
vehicle kill happens within a DoD zone of the victim's team. The message includes
attacker name, weapon used, kill distance (metres), and victim name.
Intended to be registered with command_toggler so it can be toggled at runtime.
Usage (standalone):
import extra_dodkills
extra_dodkills.init() # start listening
extra_dodkills.deinit() # stop listening
Usage (via toggler):
# enabled=True means the module starts active (init already called by you);
# enabled=False means it starts inactive (deinit already called / never init'd).
g_toggler.register("dodkills", extra_dodkills.init, extra_dodkills.deinit, enabled=True)
"""
import host
import realityadmin as radmin
import realitycore as rcore
import realityzones as rzones
def init():
host.registerHandler('PlayerEnemyKilled', onPlayerEnemyKilled)
def deinit():
host.unregisterHandler(onPlayerEnemyKilled)
def onPlayerEnemyKilled(victim, attacker, weapon, assists, obj):
if victim.getVehicle():
victimPosition = victim.getVehicle().getPosition()
if rzones.getPointDODs(victimPosition, victim.getTeam(), (rzones.ALL,)):
return
else:
return
if attacker.getVehicle() and victim.getVehicle():
distance = int(
rcore.getVectorDistance(
attacker.getVehicle().getPosition(),
victim.getVehicle().getPosition()
)
)
radmin.adminPM("DODKILL: %s [%s : %s m] %s" % (
attacker.getName(), weapon, distance, victim.getName()
), None, history=False)