This repository has been archived by the owner on Nov 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPermissions.py
66 lines (61 loc) · 2.71 KB
/
Permissions.py
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
__author__ = 'Corrosion X'
__version__ = '0.5'
__name__ = 'Permissions'
import clr
import sys
clr.AddReferenceByPartialName("UnityEngine")
clr.AddReferenceByPartialName("Pluton")
import UnityEngine
import Pluton
class Permissions:
def On_PluginInit(self):
##create perm. file if doesnt exist or load it if does
if not Plugin.IniExists("Permissions"):
setini = Plugin.CreateIni("Permissions")
setini.Save()
if not Plugin.IniExists("Settings"):
setini = Plugin.CreateIni("Settings")
setini.Save()
Commands.Register("permission")\
.setCallback("permission")\
.setDescription("Allow admin to add or remove permissions")\
.setUsage("/permission add/remove username permission")
##register commands for adding permissions
##def On_PlayerConnected(self, player):
##check what perms they have from perm file if not give them "default"
##For admins override all, for moderators have defined set amount
def On_CommandPermission(self, cpe):
player = cpe.player
if player is not player.Admin:
playerid = player.SteamID
name = player.Name
command = cpe.command
ini = Plugin.GetIni("Permissions")
ini2 = Plugin.GetIni("Settings")
debug = bool(ini2.GetSetting("Settings", Debug))
##setting = ini.GetSetting(playerid, "Permissions")
setting = ini.GetSetting(PluginName, command)
if setting is None or playerid not in setting:
BlockCommand("You Don't Have Permissions For That!")
if not debug:
Util.Log(name + " with steamid " + playerid + " attempted to executed command " + command +
" from plugin " + PluginName)
elif debug:
Util.Log(name + " with steamid " + playerid + " executed command " + command + " from plugin " +
PluginName)
##Check when player executes command if they have permissions to do so else prevent
def permissions(self, args, player):
if not player.Admin:
player.Message("Only admins can modify permissions!")
return
elif len(args) == 0:
player.Message("Use /permission add/remove username permission")
return
quoted = Util.GetQuotedArgs(args)
ini = Plugin.GetIni("Permissions")
ini2 = Plugin.GetIni("Settings")
if len(quoted) == 3:
if (quoted[0] or quoted[1] or quoted[2]) is not None:
##getplayer info: quoted[3]
if quoted[0] == "add":
ini.AddSetting(quoted[1], quoted[2])