mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-11-14 17:46:03 +00:00
basic role management and chatcmd
This commit is contained in:
parent
0fd45fb29e
commit
826f433e38
15 changed files with 236 additions and 1 deletions
89
dist/ba_root/mods/playersData/pdata.py
vendored
Normal file
89
dist/ba_root/mods/playersData/pdata.py
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
roles={}
|
||||
data={}
|
||||
|
||||
|
||||
def roles():
|
||||
global roles
|
||||
if roles=={}:
|
||||
f=open("roles.json","r")
|
||||
dat=json.loads(f.read())
|
||||
roles=dat
|
||||
f.close()
|
||||
return roles
|
||||
|
||||
def create_role(role):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role not in _roles:
|
||||
_roles[role]={
|
||||
"tag":role,
|
||||
"tagcolor":(1,1,1),
|
||||
"commands":[],
|
||||
"ids":[]
|
||||
}
|
||||
roles=_roles
|
||||
comit()
|
||||
return 'created successfully'
|
||||
|
||||
|
||||
return 'already exists'
|
||||
|
||||
def add_player_role(role,id):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].ids.append(id)
|
||||
roles=_roles
|
||||
commit()
|
||||
return 'added to '+role
|
||||
return "role not exists"
|
||||
|
||||
def add_command_role(role,command):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].commands.append(command)
|
||||
roles=_roles
|
||||
commit()
|
||||
return 'added '+command+"to "+role
|
||||
return role+"not exists"
|
||||
|
||||
|
||||
def remove_player_role(role,id):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].ids.remove(id)
|
||||
roles=_roles
|
||||
commit()
|
||||
return "removed"
|
||||
return "role not exists"
|
||||
|
||||
def remove_command_role():
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].commands.remove(command)
|
||||
roles=_roles
|
||||
commit()
|
||||
return 'removed '+command+"from "+role
|
||||
return role+"not exists"
|
||||
|
||||
def change_role_tag(role,tag):
|
||||
global roles
|
||||
_roles=roles()
|
||||
if role in _roles:
|
||||
_roles[role].tag=tag
|
||||
roles=_roles
|
||||
commit()
|
||||
return "tag changed"
|
||||
return "role not exists"
|
||||
|
||||
|
||||
def commit():
|
||||
global roles
|
||||
f=open("roles.json",'w')
|
||||
json.dump(roles,f,indent=4)
|
||||
f.close()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue