-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_debug.py
More file actions
68 lines (54 loc) · 2.12 KB
/
command_debug.py
File metadata and controls
68 lines (54 loc) · 2.12 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
command_debug - Toggle debug powers for players in-game.
Registers the !debug admin command, which grants or revokes realitydebug
developer powers for a named player.
Usage:
!debug <player_name>
Initialization:
import command_debug
command_debug.init() # default permissions (0)
command_debug.init(permissions=1) # require permission level 1
"""
import realitydebug
import realityserver
import realityadmin as radmin
DEBUG_PERMISSIONS = 0
def init(permissions=DEBUG_PERMISSIONS):
radmin.addCommand("debug", commandDebug, permissions)
def commandDebug(args, p):
if len(args) < 1:
radmin.personalMessage(
"Please specify a player to toggle debug for", p)
return False
foundPlayers = radmin.findPlayer(args[0], p)
if len(foundPlayers) == 0:
radmin.adminPM("Player %s not found." % (args[0]), p)
radmin.logAdmin("!debug", p.getName(), "",
"Player %s not found." % (args[0]))
return False
if len(foundPlayers) > 1:
radmin.adminPM("Multiple players found matching %s:" %
(args[0]), p)
for player in foundPlayers:
radmin.adminPM("- %s" % (player.getName()), p)
radmin.logAdmin("!debug", p.getName(), "",
"Multiple players found matching %s" % (args[0]))
return False
hash = realityserver.getPlayerHash(foundPlayers[0])
if hash in realitydebug.PRDEBUG_DEVS.values():
del realitydebug.PRDEBUG_DEVS[foundPlayers[0].getName()]
radmin.adminPM(
"%s's debug powers have been revoked." %
(foundPlayers[0].getName()), p
)
radmin.logAdmin("!debug", p.getName(), foundPlayers[0].getName(),
"Revoked debug powers")
else:
realitydebug.PRDEBUG_DEVS[player.getName()] = hash
radmin.adminPM(
"%s has been granted debug powers." %
(foundPlayers[0].getName()), p
)
radmin.logAdmin("!debug", p.getName(), foundPlayers[0].getName(),
"Granted debug powers")
return True