in game chat feature

This commit is contained in:
Ayush Saini 2022-05-08 21:56:22 +05:30
parent db5782b6f1
commit 07f6b304f5
3 changed files with 100 additions and 88 deletions

View file

@ -9,12 +9,15 @@ from .commands import Cheats
from .Handlers import clientid_to_accountid
from .Handlers import check_permissions
from chatHandle.chatFilter import ChatFilter
from bastd.actor import popuptext
import ba, _ba
import setting
from serverData import serverdata
settings = setting.get_settings_data()
def command_type(command):
"""
Checks The Command Type
@ -38,11 +41,6 @@ def command_type(command):
return "Cheats"
def Command(msg, clientid):
"""
Command Execution
@ -58,7 +56,6 @@ def Command(msg, clientid):
arguments = msg.lower().split(" ")[1:]
accountid = clientid_to_accountid(clientid)
if command_type(command) == "Normal":
NormalCommands.ExcelCommand(command, arguments, clientid, accountid)
@ -86,9 +83,6 @@ def Command(msg, clientid):
else:
_ba.screenmessage("access denied", transient=True, clients=[clientid])
if accountid in serverdata.clients:
if serverdata.clients[accountid]["isMuted"]:
_ba.screenmessage("You are on mute", transient=True, clients=[clientid])
@ -100,19 +94,34 @@ def Command(msg, clientid):
return None
def QuickAccess(msg,client_id):
def QuickAccess(msg, client_id):
if msg.startswith(","):
acid=""
teamid=0
acid = ""
teamid = 0
for i in _ba.get_foreground_host_session().sessionplayers:
if i.inputdevice.client_id==client_id:
teamid=i.sessionteam.id
if i.inputdevice.client_id == client_id:
teamid = i.sessionteam.id
for i in _ba.get_foreground_host_session().sessionplayers:
if i.sessionteam and teamid==i.sessionteam.id and i.inputdevice.client_id!=client_id:
_ba.screenmessage(i.getname(True)+":"+msg[1:],clients=[i.inputdevice.client_id],color=(0.3,0.6,0.3),transient=True)
if i.sessionteam and teamid == i.sessionteam.id and i.inputdevice.client_id != client_id:
_ba.screenmessage(i.getname(True) + ":" + msg[1:], clients=[i.inputdevice.client_id],
color=(0.3, 0.6, 0.3), transient=True)
return None;
return None
elif msg.startswith("."):
msg=msg[1:]
msgAr=msg.split(" ")
if len(msg) > 25 or int(len(msg)/5) > len(msgAr):
_ba.screenmessage("msg/word length too long", clients=[client_id], transient=True)
return None
msgAr.insert(int(len(msgAr)/2),"\n")
for player in _ba.get_foreground_host_activity().players:
if player.sessionplayer.inputdevice.client_id == client_id:
pos=player.actor.node.position
with _ba.Context(_ba.get_foreground_host_activity()):
popuptext.PopupText(" ".join(msgAr), (pos[0],pos[1]+1,pos[2])).autoretain()
return None
return None

View file

@ -38,6 +38,8 @@ def filter_chat_message(msg, client_id):
if msg.startswith(",") and settings["allowTeamChat"]:
return Main.QuickAccess(msg, client_id)
if msg.startswith(".") and settings["allowInGameChat"]:
return Main.QuickAccess(msg, client_id)
if msg == "end" and settings["allowEndVote"]:
EndVote.vote_end(acid, client_id)

View file

@ -88,6 +88,7 @@
},
"allowTeamChat":true,
"allowEndVote":true,
"allowInGameChat":true,
"sameCharacterForTeam":false,
"newResultBoard":true,
"HostDeviceName":"v1.4",