-
Notifications
You must be signed in to change notification settings - Fork 49
Usergroups and Restrictions
Certain commands shouldn't be made available to all players. In order to grant specific players access to those commands, you will need to create a password & restricting identifier (e.g. 'admin', 'mod', 'user1') for each user/group which you can then assign to your commands.
Players can access these commands by typing /login {password}
where {password} is the password they've been assigned.
Follow these steps to create a new group:
- Open
config/base.py
- Find the following lines:
passwords = {
'PASSWORDREPLACEME': ['admin']
}
You should change PASSWORDREPLACEME
with a new password used to login as admin
3. To create a new usergroup, add a comma to the end of the second line, and copy the formatting style on a new line:
passwords = {
'admin_password': ['admin'],
'mod_password': ['mod']
}
Change admin_password
and mod_password
to the passwords you wish to use for each group
4. You may now login to either the admin group or the mod group by typing in /login {password}
where {password} is 'admin/mod_password' in the example
NOTE: By default, the console/terminal that is running the cuwo server will have access to all unrestricted commands, and those restricted to either/both the 'admin' and 'console' usergroup.
To restrict a command to multiple usergroups, follow these two simple steps:
- Import
restrict
from cuwo.script - Add
@restrict('group1', 'group2', 'group3')
between the@command
decorator and the command definition
from cuwo.script import ServerScript, command, admin
@command
@admin
def say(script, *args):
message = ' '.join(args)
script.server.send_chat(message)
from cuwo.script import ServerScript, command, restrict
@command
@restrict('admin', 'mod')
def say(script, *args):
message = ' '.join(args)
script.server.send_chat(message)
To avoid copying the same @restrict
value and needing to edit multiple copies, you may assign a decorator which only requires you to update a single copy.
To change @restrict('admin', 'supermod', 'mod')
to @staff
, follow these steps:
- Below your imports, add
staff = restrict('admin', 'supermod', 'mod')
- Place
@staff
between the@command
decorator and command definition
@command
@restrict('admin', 'supermod', 'mod')
def say(script, *args):
message = ' '.join(args)
script.server.send_chat(message)
@command
@restrict('admin', 'supermod', 'mod')
def kick(script, name):
player = script.get_player(name)
player.kick()
staff = restrict('admin', 'supermod', 'mod')
@command
@staff
def say(script, *args):
message = ' '.join(args)
script.server.send_chat(message)
@command
@staff
def kick(script, name):
player = script.get_player(name)
player.kick()