Last active
June 3, 2018 03:20
-
-
Save DustinAlandzes/6ccdd8ed52dbb73799dce7f67a25fa7b to your computer and use it in GitHub Desktop.
An OxideMod python plugin that copies group permissions, literally a c+p from flamingmojo's blog: https://flamingmojo.wordpress.com/2016/07/15/making-a-plugin-starting-off/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BasePlayer | |
class GroupCopy: | |
def __init__(self): | |
self.Title = "Group Copyer" | |
self.Author = "FlamingMojo" | |
self.Version = V(1,0,0) | |
self.HasConfig = False | |
def Loaded(self): | |
command.AddConsoleCommand('groupcopy.copy',self.Plugin,'Copy') | |
command.AddChatCommand('copygroup',self.Plugin, 'Copychat') | |
permission.RegisterPermission('groupcopy.allowed',self.Plugin) | |
def Copychat(self,player,cmd,args): | |
arglist = list(args) | |
self.Copy(None,player,arglist) | |
def Copy(self,args, callingply = None, argslist = None): | |
if not callingply: | |
callingplyID = str(args.connection).split('/')[1] | |
for player in BasePlayer.activePlayerList: | |
if player.UserIDString == callingplyID: | |
callingply = player | |
if callingply.IsAdmin() or permission.UserHasGroup(callingply.UserIDString, 'admin') or permission.UserHasPermission(callingply.UserIDString, 'groupcopy.allowed'): | |
if args: | |
if len (args.ArgsStr.split(' ')) != 2: | |
print 'Needs 2 arguments, NO SPACES IN GROUP NAME' | |
return | |
else: | |
startgroup = args.ArgsStr.split(' ')[0] | |
finishgroup = args.ArgsStr.split(' ')[1] | |
elif argslist: | |
if len(argslist) != 2: | |
print 'Needs 2 arguments, NO SPACES IN GROUP NAME' | |
return | |
else: | |
startgroup = argslist[0] | |
finishgroup = argslist[1] | |
else: | |
print 'Invalid method call!' | |
return | |
if permission.GroupExists(startgroup): | |
if not permission.GroupExists(finishgroup): | |
rust.RunServerCommand('group add %s'%finishgroup) | |
print 'Added group' | |
permslist = permission.GetGroupPermissions(startgroup) | |
for perm in list(permslist): | |
rust.RunServerCommand('grant group %s %s'%(finishgroup,perm)) | |
print 'Granting %s Access to: %s' %(finishgroup, perm) | |
print 'Done Copying' | |
else: | |
print 'Invalid start group' | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment