mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-10-20 00:00:39 +00:00
bugs fix
now server can start atleast
This commit is contained in:
parent
ff982c8a66
commit
bd5bbb4995
23 changed files with 706 additions and 462 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
|
||||
from PlayersData import pdata
|
||||
from playersData import pdata
|
||||
import ba, _ba
|
||||
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ def clientid_to_accountid(clientid):
|
|||
|
||||
|
||||
|
||||
def cheak_permissions(accountid, command):
|
||||
def check_permissions(accountid, command):
|
||||
"""
|
||||
Checks The Permission To Player To Executive Command
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
|
||||
|
||||
from .Objects import NormalCommands
|
||||
from .Objects import Management
|
||||
from .Objects import Fun
|
||||
from .Objects import Cheats
|
||||
from .commands import NormalCommands
|
||||
from .commands import Management
|
||||
from .commands import Fun
|
||||
from .commands import Cheats
|
||||
|
||||
from .Handlers import clientid_to_accountid
|
||||
from .Handlers import cheak_permissions
|
||||
from .Handlers import check_permissions
|
||||
|
||||
import ba, _ba
|
||||
import setting
|
||||
|
|
@ -65,17 +65,17 @@ def Command(msg, clientid):
|
|||
|
||||
|
||||
elif command_type(command) == "Manage":
|
||||
if cheak_permissions(accountid, command):
|
||||
if check_permissions(accountid, command):
|
||||
Management.ExcelCommand(command, arguments, clientid, accountid)
|
||||
|
||||
|
||||
elif command_type(command) == "Fun":
|
||||
if cheak_permissions(accountid, command):
|
||||
if check_permissions(accountid, command):
|
||||
Fun.ExcelCommand(command, arguments, clientid, accountid)
|
||||
|
||||
|
||||
elif command_type(command) == "Cheats":
|
||||
if cheak_permissions(accountid, command):
|
||||
if check_permissions(accountid, command):
|
||||
Cheats.ExcelCommand(command, arguments, clientid, accountid)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,310 +1,310 @@
|
|||
from .Handlers import handlemsg, handlemsg_all, clientid_to_myself
|
||||
import ba, _ba
|
||||
|
||||
|
||||
Commands = ['kill', 'heal', 'curse', 'sleep', 'superpunch', 'gloves', 'shield', 'freeze', 'unfreeze', 'godmode']
|
||||
CommandAliases = ['die', 'heath', 'cur', 'sp', 'punch', 'protect', 'ice', 'thaw', 'gm']
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def ExcelCommand(command, arguments, clientid, accountid):
|
||||
"""
|
||||
Checks The Command And Run Function
|
||||
|
||||
Parameters:
|
||||
command : str
|
||||
arguments : str
|
||||
clientid : int
|
||||
accountid : int
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
|
||||
if command in ['kill', 'die']:
|
||||
kill(arguments, clientid)
|
||||
|
||||
elif command in ['heal', 'heath']:
|
||||
heal(arguments, clientid)
|
||||
|
||||
elif command in ['curse', 'cur']:
|
||||
curse(arguments, clientid)
|
||||
|
||||
elif command == 'sleep':
|
||||
sleep(arguments, clientid)
|
||||
|
||||
elif command in ['sp', 'superpunch']:
|
||||
super_punch(arguments, clientid)
|
||||
|
||||
elif command in ['gloves', 'punch']:
|
||||
gloves(arguments, clientid)
|
||||
|
||||
elif command in ['shield', 'protect']:
|
||||
shield(arguments, clientid)
|
||||
|
||||
elif command in ['freeze', 'ice']:
|
||||
freeze(arguments, clientid)
|
||||
|
||||
elif command in ['unfreeze', 'thaw']:
|
||||
un_freeze(arguments, clientid)
|
||||
|
||||
elif command in ['gm', 'godmode']:
|
||||
god_mode(arguments, clientid)
|
||||
|
||||
|
||||
|
||||
|
||||
def kill(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.DieMessage())
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.DieMessage())
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.DieMessage())
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def heal(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.PowerupMessage(poweruptype='health'))
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.PowerupMessage(poweruptype='health'))
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.PowerupMessage(poweruptype='health'))
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def curse(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.PowerupMessage(poweruptype='curse'))
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.PowerupMessage(poweruptype='curse'))
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.PowerupMessage(poweruptype='curse'))
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def sleep(arguments, clientid):
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
activity.players[myself].actor.node.handlemessage('knockout', 8000)
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
for i in activity.players:
|
||||
i.actor.node.handlemessage('knockout', 8000)
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
activity.players[req_player].actor.node.handlemessage('knockout', 8000)
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def super_punch(arguments, clientid):
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
|
||||
myself = clientid_to_myself(clientid)
|
||||
|
||||
if activity.players[myself].actor._punch_power_scale != 15:
|
||||
activity.players[myself].actor._punch_power_scale = 15
|
||||
activity.players[myself].actor._punch_cooldown = 0
|
||||
else:
|
||||
activity.players[myself].actor._punch_power_scale = 1.2
|
||||
activity.players[myself].actor._punch_cooldown = 400
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
for i in activity.players:
|
||||
if i.actor._punch_power_scale != 15:
|
||||
i.actor._punch_power_scale = 15
|
||||
i.actor._punch_cooldown = 0
|
||||
else:
|
||||
i.actor._punch_power_scale = 1.2
|
||||
i.actor._punch_cooldown = 400
|
||||
|
||||
else:
|
||||
try:
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
req_player = int(arguments[0])
|
||||
|
||||
if activity.players[req_player].actor._punch_power_scale != 15:
|
||||
activity.players[req_player].actor._punch_power_scale = 15
|
||||
activity.players[req_player].actor._punch_cooldown = 0
|
||||
else:
|
||||
activity.players[req_player].actor._punch_power_scale = 1.2
|
||||
activity.players[req_player].actor._punch_cooldown = 400
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def gloves(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.PowerupMessage(poweruptype='punch'))
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.PowerupMessage(poweruptype='punch'))
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.PowerupMessage(poweruptype='punch'))
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def shield(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.PowerupMessage(poweruptype='shield'))
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.PowerupMessage(poweruptype='shield'))
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.PowerupMessage(poweruptype='shield'))
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def freeze(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.FreezeMessage())
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.FreezeMessage())
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.FreezeMessage())
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def un_freeze(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.ThawMessage())
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.ThawMessage())
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.ThawMessage())
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def god_mode(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
player = activity.players[myself].actor
|
||||
|
||||
if player._punch_power_scale != 7:
|
||||
player._punch_power_scale = 7
|
||||
player.node.hockey = True
|
||||
player.node.invincible = True
|
||||
|
||||
else:
|
||||
player._punch_power_scale = 1.2
|
||||
player.node.hockey = False
|
||||
player.node.invincible = False
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
for i in activity.players:
|
||||
if i.actor._punch_power_scale != 7:
|
||||
i.actor._punch_power_scale = 7
|
||||
i.actor.node.hockey = True
|
||||
i.actor.node.invincible = True
|
||||
else:
|
||||
i.actor._punch_power_scale = 1.2
|
||||
i.actor.node.hockey = False
|
||||
i.actor.node.invincible = False
|
||||
|
||||
else:
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
req_player = int(arguments[0])
|
||||
player = activity.players[req_player].actor
|
||||
|
||||
if player._punch_power_scale != 7:
|
||||
player._punch_power_scale = 7
|
||||
player.node.hockey = True
|
||||
player.node.invincible = True
|
||||
|
||||
else:
|
||||
player._punch_power_scale = 1.2
|
||||
player.node.hockey = False
|
||||
player.node.invincible = False
|
||||
from .Handlers import handlemsg, handlemsg_all, clientid_to_myself
|
||||
import ba, _ba
|
||||
|
||||
|
||||
Commands = ['kill', 'heal', 'curse', 'sleep', 'superpunch', 'gloves', 'shield', 'freeze', 'unfreeze', 'godmode']
|
||||
CommandAliases = ['die', 'heath', 'cur', 'sp', 'punch', 'protect', 'ice', 'thaw', 'gm']
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def ExcelCommand(command, arguments, clientid, accountid):
|
||||
"""
|
||||
Checks The Command And Run Function
|
||||
|
||||
Parameters:
|
||||
command : str
|
||||
arguments : str
|
||||
clientid : int
|
||||
accountid : int
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
|
||||
if command in ['kill', 'die']:
|
||||
kill(arguments, clientid)
|
||||
|
||||
elif command in ['heal', 'heath']:
|
||||
heal(arguments, clientid)
|
||||
|
||||
elif command in ['curse', 'cur']:
|
||||
curse(arguments, clientid)
|
||||
|
||||
elif command == 'sleep':
|
||||
sleep(arguments, clientid)
|
||||
|
||||
elif command in ['sp', 'superpunch']:
|
||||
super_punch(arguments, clientid)
|
||||
|
||||
elif command in ['gloves', 'punch']:
|
||||
gloves(arguments, clientid)
|
||||
|
||||
elif command in ['shield', 'protect']:
|
||||
shield(arguments, clientid)
|
||||
|
||||
elif command in ['freeze', 'ice']:
|
||||
freeze(arguments, clientid)
|
||||
|
||||
elif command in ['unfreeze', 'thaw']:
|
||||
un_freeze(arguments, clientid)
|
||||
|
||||
elif command in ['gm', 'godmode']:
|
||||
god_mode(arguments, clientid)
|
||||
|
||||
|
||||
|
||||
|
||||
def kill(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.DieMessage())
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.DieMessage())
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.DieMessage())
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def heal(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.PowerupMessage(poweruptype='health'))
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.PowerupMessage(poweruptype='health'))
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.PowerupMessage(poweruptype='health'))
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def curse(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.PowerupMessage(poweruptype='curse'))
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.PowerupMessage(poweruptype='curse'))
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.PowerupMessage(poweruptype='curse'))
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def sleep(arguments, clientid):
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
activity.players[myself].actor.node.handlemessage('knockout', 8000)
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
for i in activity.players:
|
||||
i.actor.node.handlemessage('knockout', 8000)
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
activity.players[req_player].actor.node.handlemessage('knockout', 8000)
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def super_punch(arguments, clientid):
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
|
||||
myself = clientid_to_myself(clientid)
|
||||
|
||||
if activity.players[myself].actor._punch_power_scale != 15:
|
||||
activity.players[myself].actor._punch_power_scale = 15
|
||||
activity.players[myself].actor._punch_cooldown = 0
|
||||
else:
|
||||
activity.players[myself].actor._punch_power_scale = 1.2
|
||||
activity.players[myself].actor._punch_cooldown = 400
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
for i in activity.players:
|
||||
if i.actor._punch_power_scale != 15:
|
||||
i.actor._punch_power_scale = 15
|
||||
i.actor._punch_cooldown = 0
|
||||
else:
|
||||
i.actor._punch_power_scale = 1.2
|
||||
i.actor._punch_cooldown = 400
|
||||
|
||||
else:
|
||||
try:
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
req_player = int(arguments[0])
|
||||
|
||||
if activity.players[req_player].actor._punch_power_scale != 15:
|
||||
activity.players[req_player].actor._punch_power_scale = 15
|
||||
activity.players[req_player].actor._punch_cooldown = 0
|
||||
else:
|
||||
activity.players[req_player].actor._punch_power_scale = 1.2
|
||||
activity.players[req_player].actor._punch_cooldown = 400
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def gloves(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.PowerupMessage(poweruptype='punch'))
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.PowerupMessage(poweruptype='punch'))
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.PowerupMessage(poweruptype='punch'))
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def shield(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.PowerupMessage(poweruptype='shield'))
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.PowerupMessage(poweruptype='shield'))
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.PowerupMessage(poweruptype='shield'))
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def freeze(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.FreezeMessage())
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.FreezeMessage())
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.FreezeMessage())
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def un_freeze(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
handlemsg(myself, ba.ThawMessage())
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
handlemsg_all(ba.ThawMessage())
|
||||
|
||||
else:
|
||||
try:
|
||||
req_player = int(arguments[0])
|
||||
handlemsg(req_player, ba.ThawMessage())
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def god_mode(arguments, clientid):
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
myself = clientid_to_myself(clientid)
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
player = activity.players[myself].actor
|
||||
|
||||
if player._punch_power_scale != 7:
|
||||
player._punch_power_scale = 7
|
||||
player.node.hockey = True
|
||||
player.node.invincible = True
|
||||
|
||||
else:
|
||||
player._punch_power_scale = 1.2
|
||||
player.node.hockey = False
|
||||
player.node.invincible = False
|
||||
|
||||
elif arguments[0] == 'all':
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
for i in activity.players:
|
||||
if i.actor._punch_power_scale != 7:
|
||||
i.actor._punch_power_scale = 7
|
||||
i.actor.node.hockey = True
|
||||
i.actor.node.invincible = True
|
||||
else:
|
||||
i.actor._punch_power_scale = 1.2
|
||||
i.actor.node.hockey = False
|
||||
i.actor.node.invincible = False
|
||||
|
||||
else:
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
req_player = int(arguments[0])
|
||||
player = activity.players[req_player].actor
|
||||
|
||||
if player._punch_power_scale != 7:
|
||||
player._punch_power_scale = 7
|
||||
player.node.hockey = True
|
||||
player.node.invincible = True
|
||||
|
||||
else:
|
||||
player._punch_power_scale = 1.2
|
||||
player.node.hockey = False
|
||||
player.node.invincible = False
|
||||
|
|
@ -1,48 +1,48 @@
|
|||
""" Some useful handlers to reduce lot of code """
|
||||
import _ba, ba
|
||||
|
||||
|
||||
|
||||
def send(msg, clientid):
|
||||
"""Shortcut To Send Private Msg To Client"""
|
||||
|
||||
_ba.chatmessage(str(msg), clients=[clientid])
|
||||
_ba.screenmessage(str(msg), transient=True, clients=[clientid])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def clientid_to_myself(clientid):
|
||||
"""Return Player Index Of Self Player"""
|
||||
|
||||
session = _ba.get_foreground_host_session()
|
||||
|
||||
for i in range(len(session.sessionplayers)):
|
||||
if session.sessionplayers[i].inputdevice.client_id == clientid:
|
||||
return int(session.sessionplayers[i].id)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def handlemsg(client, msg):
|
||||
"""Handles Spaz Msg For Single Player"""
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
activity.players[client].actor.node.handlemessage(msg)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def handlemsg_all(msg):
|
||||
"""Handle Spaz message for all players in activity"""
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
for i in activity.players:
|
||||
i.actor.node.handlemessage(msg)
|
||||
|
||||
|
||||
|
||||
""" Some useful handlers to reduce lot of code """
|
||||
import _ba, ba
|
||||
|
||||
|
||||
|
||||
def send(msg, clientid):
|
||||
"""Shortcut To Send Private Msg To Client"""
|
||||
|
||||
_ba.chatmessage(str(msg), clients=[clientid])
|
||||
_ba.screenmessage(str(msg), transient=True, clients=[clientid])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def clientid_to_myself(clientid):
|
||||
"""Return Player Index Of Self Player"""
|
||||
|
||||
session = _ba.get_foreground_host_session()
|
||||
|
||||
for i in range(len(session.sessionplayers)):
|
||||
if session.sessionplayers[i].inputdevice.client_id == clientid:
|
||||
return int(session.sessionplayers[i].id)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def handlemsg(client, msg):
|
||||
"""Handles Spaz Msg For Single Player"""
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
activity.players[client].actor.node.handlemessage(msg)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def handlemsg_all(msg):
|
||||
"""Handle Spaz message for all players in activity"""
|
||||
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
for i in activity.players:
|
||||
i.actor.node.handlemessage(msg)
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
from .Handlers import handlemsg, handlemsg_all
|
||||
from PlayersData import pdata
|
||||
from Tools.whitelist import add_to_white_list, add_commit_to_logs
|
||||
from playersData import pdata
|
||||
from tools.whitelist import add_to_white_list, add_commit_to_logs
|
||||
|
||||
import ba, _ba, time, setting
|
||||
|
||||
|
|
@ -1,81 +1,81 @@
|
|||
from .Handlers import send
|
||||
import ba, _ba
|
||||
|
||||
|
||||
Commands = ['me', 'list', 'uniqeid']
|
||||
CommandAliases = ['stats', 'score', 'rank', 'myself', 'l', 'id', 'pb-id', 'pb', 'accountid']
|
||||
|
||||
|
||||
|
||||
def ExcelCommand(command, arguments, clientid, accountid):
|
||||
"""
|
||||
Checks The Command And Run Function
|
||||
|
||||
Parameters:
|
||||
command : str
|
||||
arguments : str
|
||||
clientid : int
|
||||
accountid : int
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
if command in ['me', 'stats', 'score', 'rank', 'myself']:
|
||||
stats()
|
||||
|
||||
elif command in ['list', 'l']:
|
||||
list(clientid)
|
||||
|
||||
elif command in ['uniqeid', 'id', 'pb-id', 'pb' , 'accountid']:
|
||||
accountid_request(arguments, clientid, accountid)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def stats():
|
||||
""" Stats """
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
def list(clientid):
|
||||
"""Returns The List Of Players Clientid and index"""
|
||||
|
||||
p = u'{0:^16}{1:^15}{2:^10}'
|
||||
seprator = '\n______________________________\n'
|
||||
|
||||
|
||||
list = p.format('Name', 'Client ID' , 'Player ID')+seprator
|
||||
session = _ba.get_foreground_host_session()
|
||||
|
||||
|
||||
for i in session.sessionplayers:
|
||||
list += p.format(i.getname(icon = False),
|
||||
i.inputdevice.client_id, i.id)
|
||||
|
||||
send(list, clientid)
|
||||
|
||||
|
||||
|
||||
|
||||
def accountid_request(arguments, clientid, accountid):
|
||||
"""Returns The Account Id Of Players"""
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
send(f"Your account id is {accountid} ", clientid)
|
||||
|
||||
else:
|
||||
try:
|
||||
session = _ba.get_foreground_host_session()
|
||||
player = session.sessionplayers[int(arguments[0])]
|
||||
|
||||
name = player.getname(full=True, icon=True)
|
||||
accountid = player.get_account_id()
|
||||
|
||||
send(f" {name}'s account id is '{accountid}' ", clientid)
|
||||
except:
|
||||
return
|
||||
|
||||
from .Handlers import send
|
||||
import ba, _ba
|
||||
|
||||
|
||||
Commands = ['me', 'list', 'uniqeid']
|
||||
CommandAliases = ['stats', 'score', 'rank', 'myself', 'l', 'id', 'pb-id', 'pb', 'accountid']
|
||||
|
||||
|
||||
|
||||
def ExcelCommand(command, arguments, clientid, accountid):
|
||||
"""
|
||||
Checks The Command And Run Function
|
||||
|
||||
Parameters:
|
||||
command : str
|
||||
arguments : str
|
||||
clientid : int
|
||||
accountid : int
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
if command in ['me', 'stats', 'score', 'rank', 'myself']:
|
||||
stats()
|
||||
|
||||
elif command in ['list', 'l']:
|
||||
list(clientid)
|
||||
|
||||
elif command in ['uniqeid', 'id', 'pb-id', 'pb' , 'accountid']:
|
||||
accountid_request(arguments, clientid, accountid)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def stats():
|
||||
""" Stats """
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
def list(clientid):
|
||||
"""Returns The List Of Players Clientid and index"""
|
||||
|
||||
p = u'{0:^16}{1:^15}{2:^10}'
|
||||
seprator = '\n______________________________\n'
|
||||
|
||||
|
||||
list = p.format('Name', 'Client ID' , 'Player ID')+seprator
|
||||
session = _ba.get_foreground_host_session()
|
||||
|
||||
|
||||
for i in session.sessionplayers:
|
||||
list += p.format(i.getname(icon = False),
|
||||
i.inputdevice.client_id, i.id)
|
||||
|
||||
send(list, clientid)
|
||||
|
||||
|
||||
|
||||
|
||||
def accountid_request(arguments, clientid, accountid):
|
||||
"""Returns The Account Id Of Players"""
|
||||
|
||||
if arguments == [] or arguments == ['']:
|
||||
send(f"Your account id is {accountid} ", clientid)
|
||||
|
||||
else:
|
||||
try:
|
||||
session = _ba.get_foreground_host_session()
|
||||
player = session.sessionplayers[int(arguments[0])]
|
||||
|
||||
name = player.getname(full=True, icon=True)
|
||||
accountid = player.get_account_id()
|
||||
|
||||
send(f" {name}'s account id is '{accountid}' ", clientid)
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
4
dist/ba_root/mods/chatHandle/handlechat.py
vendored
4
dist/ba_root/mods/chatHandle/handlechat.py
vendored
|
|
@ -1,7 +1,7 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
|
||||
from PlayersData import pdata
|
||||
from ChatHandle.ChatCommands import Main
|
||||
from playersData import pdata
|
||||
from chatHandle.ChatCommands import Main
|
||||
|
||||
import ba, _ba
|
||||
|
||||
|
|
|
|||
2
dist/ba_root/mods/custom_hooks.py
vendored
2
dist/ba_root/mods/custom_hooks.py
vendored
|
|
@ -1,4 +1,4 @@
|
|||
from ChatHandle import HandleChat
|
||||
from chatHandle import handlechat
|
||||
|
||||
def filter_chat_message(msg, client_id):
|
||||
return HandleChat.filter_chat_message(msg, client_id)
|
||||
|
|
|
|||
2
dist/ba_root/mods/playersData/custom.json
vendored
2
dist/ba_root/mods/playersData/custom.json
vendored
|
|
@ -5,6 +5,6 @@
|
|||
},
|
||||
"customeffects":{
|
||||
"pb-id":"ice",
|
||||
"pb-id":"scorch",
|
||||
"pb-id":"scorch"
|
||||
}
|
||||
}
|
||||
7
dist/ba_root/mods/playersData/pdata.py
vendored
7
dist/ba_root/mods/playersData/pdata.py
vendored
|
|
@ -106,8 +106,9 @@ def change_role_tag(role, tag):
|
|||
def get_role(acc_id):
|
||||
global roles
|
||||
_roles = get_roles()
|
||||
|
||||
for role in _roles:
|
||||
if acc_id in role["ids"]:
|
||||
if acc_id in _roles[role]["ids"]:
|
||||
return role
|
||||
|
||||
|
||||
|
|
@ -124,6 +125,7 @@ def get_custom():
|
|||
with open(data_path+"custom.json","r") as f:
|
||||
custom = json.loads(f.read())
|
||||
return custom
|
||||
return custom
|
||||
|
||||
|
||||
def set_effect(effect, id):
|
||||
|
|
@ -162,3 +164,6 @@ def commit_c():
|
|||
global custom
|
||||
with open(data_path+"custom.json",'w') as f:
|
||||
json.dump(custom,f,indent=4)
|
||||
|
||||
def update_toppers(toperlist):
|
||||
pass
|
||||
|
|
|
|||
4
dist/ba_root/mods/spazmod/modifyspaz.py
vendored
4
dist/ba_root/mods/spazmod/modifyspaz.py
vendored
|
|
@ -1,5 +1,5 @@
|
|||
from SpazMod import tag
|
||||
from SpazMod import effects
|
||||
from spazmod import tag
|
||||
from spazmod import effects
|
||||
import setting
|
||||
|
||||
# all activites related to modify spaz by any how will be here
|
||||
|
|
|
|||
7
dist/ba_root/mods/spazmod/tag.py
vendored
7
dist/ba_root/mods/spazmod/tag.py
vendored
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
from PlayersData import pdata
|
||||
from playersData import pdata
|
||||
import ba
|
||||
def addtag(node,player):
|
||||
session_player=player.sessionplayer
|
||||
|
|
@ -13,8 +13,9 @@ def addtag(node,player):
|
|||
tag=customtag[account_id]
|
||||
elif role:
|
||||
tag=roles[role]['tag']
|
||||
|
||||
Tag(node,tag)
|
||||
if tag:
|
||||
Tag(node,tag)
|
||||
|
||||
from stats import mystats
|
||||
def addrank(node,player):
|
||||
session_player=player.sessionplayer
|
||||
|
|
|
|||
0
dist/ba_root/mods/stats/__init__.py
vendored
Normal file
0
dist/ba_root/mods/stats/__init__.py
vendored
Normal file
224
dist/ba_root/mods/stats/mystats.py
vendored
Normal file
224
dist/ba_root/mods/stats/mystats.py
vendored
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
damage_data = {}
|
||||
#Don't touch the above line
|
||||
"""
|
||||
mystats module for BombSquad version 1.5.29
|
||||
Provides functionality for dumping player stats to disk between rounds.
|
||||
"""
|
||||
ranks=[]
|
||||
import threading,json,os,urllib.request,ba,_ba,setting
|
||||
from ba._activity import Activity
|
||||
from ba._music import setmusic, MusicType
|
||||
from ba._enums import InputType, UIScale
|
||||
# False-positive from pylint due to our class-generics-filter.
|
||||
from ba._player import EmptyPlayer # pylint: disable=W0611
|
||||
from ba._team import EmptyTeam # pylint: disable=W0611
|
||||
from typing import Any, Dict, Optional
|
||||
from ba._lobby import JoinInfo
|
||||
from ba import _activitytypes as ba_actypes
|
||||
from ba._activitytypes import *
|
||||
our_settings = setting.get_settings_data()
|
||||
# where our stats file and pretty html output will go
|
||||
base_path = os.path.join(_ba.env()['python_directory_user'],"stats" + os.sep)
|
||||
statsfile = base_path + 'stats.json'
|
||||
htmlfile = base_path + 'stats_page.html'
|
||||
table_style = "{width:100%;border: 3px solid black;border-spacing: 5px;border-collapse:collapse;text-align:center;background-color:#fff}"
|
||||
heading_style = "{border: 3px solid black;text-align:center;}"
|
||||
html_start = f'''<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Test Server</title>
|
||||
<style>table{table_style} th{heading_style}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3 style="text-align:center">Top 200 Players </h3>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th><b>Rank</b></th>
|
||||
<th style="text-align:center"><b>Name</b></th>
|
||||
<th><b>Score</b></th>
|
||||
<th><b>Kills</b></th>
|
||||
<th><b>Deaths</b></th>
|
||||
<th><b>Games Played</b></th>
|
||||
</tr>
|
||||
'''
|
||||
# <th><b>Total Damage</b></th> #removed this line as it isn't crt data
|
||||
def refreshStats():
|
||||
# lastly, write a pretty html version.
|
||||
# our stats url could point at something like this...
|
||||
f=open(statsfile)
|
||||
stats = json.loads(f.read())
|
||||
|
||||
f=open(htmlfile, 'w')
|
||||
f.write(html_start)
|
||||
entries = [(a['scores'], a['kills'], a['deaths'], a['games'], a['name_html'], a['aid']) for a in stats.values()]
|
||||
# this gives us a list of kills/names sorted high-to-low
|
||||
entries.sort(reverse=True)
|
||||
rank = 0
|
||||
toppers = {}
|
||||
pStats = stats
|
||||
toppersIDs=[]
|
||||
_ranks=[]
|
||||
for entry in entries:
|
||||
if True:
|
||||
rank += 1
|
||||
scores = str(entry[0])
|
||||
kills = str(entry[1])
|
||||
deaths = str(entry[2])
|
||||
games = str(entry[3])
|
||||
name = str(entry[4])
|
||||
aid = str(entry[5])
|
||||
if rank < 6: toppersIDs.append(aid)
|
||||
#The below kd and avg_score will not be added to website's html document, it will be only added in stats.json
|
||||
try:
|
||||
kd = str(float(kills) / float(deaths))
|
||||
kd_int = kd.split('.')[0]
|
||||
kd_dec = kd.split('.')[1]
|
||||
p_kd = kd_int + '.' + kd_dec[:3]
|
||||
except Exception:
|
||||
p_kd = "0"
|
||||
try:
|
||||
avg_score = str(float(scores) / float(games))
|
||||
avg_score_int = avg_score.split('.')[0]
|
||||
avg_score_dec = avg_score.split('.')[1]
|
||||
p_avg_score = avg_score_int + '.' + avg_score_dec[:3]
|
||||
except Exception:
|
||||
p_avg_score = "0"
|
||||
if damage_data and aid in damage_data:
|
||||
dmg = damage_data[aid]
|
||||
dmg = str(str(dmg).split('.')[0] + '.' + str(dmg).split('.')[1][:3])
|
||||
else: dmg = 0
|
||||
|
||||
_ranks.append(aid)
|
||||
|
||||
pStats[str(aid)]["rank"] = int(rank)
|
||||
pStats[str(aid)]["scores"] = int(scores)
|
||||
pStats[str(aid)]["total_damage"] += float(dmg) #not working properly
|
||||
pStats[str(aid)]["games"] = int(games)
|
||||
pStats[str(aid)]["kills"] = int(kills)
|
||||
pStats[str(aid)]["deaths"] = int(deaths)
|
||||
pStats[str(aid)]["kd"] = float(p_kd)
|
||||
pStats[str(aid)]["avg_score"] = float(p_avg_score)
|
||||
|
||||
if rank < 201:
|
||||
#<td>{str(dmg)}</td> #removed this line as it isn't crt data
|
||||
f.write(f'''
|
||||
<tr>
|
||||
<td>{str(rank)}</td>
|
||||
<td style="text-align:center">{str(name)}</td>
|
||||
<td>{str(scores)}</td>
|
||||
<td>{str(kills)}</td>
|
||||
<td>{str(deaths)}</td>
|
||||
<td>{str(games)}</td>
|
||||
</tr>''')
|
||||
f.write('''
|
||||
</table>
|
||||
</body>
|
||||
</html>''')
|
||||
f.close()
|
||||
global ranks
|
||||
ranks=_ranks
|
||||
|
||||
f2 = open(statsfile, "w")
|
||||
f2.write(json.dumps(pStats, indent=4))
|
||||
f2.close()
|
||||
|
||||
from playersData import pdata
|
||||
pdata.update_toppers(toppersIDs)
|
||||
|
||||
def update(score_set):
|
||||
"""
|
||||
Given a Session's ScoreSet, tallies per-account kills
|
||||
and passes them to a background thread to process and
|
||||
store.
|
||||
"""
|
||||
# look at score-set entries to tally per-account kills for this round
|
||||
|
||||
account_kills = {}
|
||||
account_deaths = {}
|
||||
account_scores = {}
|
||||
|
||||
for p_entry in score_set.get_records().values():
|
||||
account_id = p_entry.player.get_account_id()
|
||||
if account_id is not None:
|
||||
account_kills.setdefault(account_id, 0) # make sure exists
|
||||
account_kills[account_id] += p_entry.accum_kill_count
|
||||
account_deaths.setdefault(account_id, 0) # make sure exists
|
||||
account_deaths[account_id] += p_entry.accum_killed_count
|
||||
account_scores.setdefault(account_id, 0) # make sure exists
|
||||
account_scores[account_id] += p_entry.accumscore
|
||||
# Ok; now we've got a dict of account-ids and kills.
|
||||
# Now lets kick off a background thread to load existing scores
|
||||
# from disk, do display-string lookups for accounts that need them,
|
||||
# and write everything back to disk (along with a pretty html version)
|
||||
# We use a background thread so our server doesn't hitch while doing this.
|
||||
print(account_kills)
|
||||
print(account_scores)
|
||||
if account_scores:
|
||||
UpdateThread(account_kills, account_deaths, account_scores).start()
|
||||
|
||||
class UpdateThread(threading.Thread):
|
||||
def __init__(self, account_kills, account_deaths, account_scores):
|
||||
threading.Thread.__init__(self)
|
||||
self._account_kills = account_kills
|
||||
self.account_deaths = account_deaths
|
||||
self.account_scores = account_scores
|
||||
print("init thread")
|
||||
def run(self):
|
||||
# pull our existing stats from disk
|
||||
print("run thead")
|
||||
try:
|
||||
if os.path.exists(statsfile):
|
||||
with open(statsfile) as f:
|
||||
stats = json.loads(f.read())
|
||||
except:
|
||||
stats={}
|
||||
|
||||
# now add this batch of kills to our persistant stats
|
||||
for account_id, kill_count in self._account_kills.items():
|
||||
# add a new entry for any accounts that dont have one
|
||||
if account_id not in stats:
|
||||
# also lets ask the master-server for their account-display-str.
|
||||
# (we only do this when first creating the entry to save time,
|
||||
# though it may be smart to refresh it periodically since
|
||||
# it may change)
|
||||
'''url = 'http://bombsquadgame.com/accountquery?id=' + account_id
|
||||
response = json.loads(
|
||||
urllib.request.urlopen(urllib.Request(url)).read())
|
||||
print('response variable from mystats.py line 183:')
|
||||
print(response)
|
||||
name_html = response['name_html']'''
|
||||
stats[account_id] = {'rank': 0,
|
||||
'name_html': str(account_id),
|
||||
'scores': 0,
|
||||
'total_damage': 0,
|
||||
'kills': 0,
|
||||
'deaths': 0,
|
||||
'games': 0,
|
||||
'kd': 0,
|
||||
'avg_score': 0,
|
||||
'aid': str(account_id)}
|
||||
# now increment their kills whether they were already there or not
|
||||
stats[account_id]['kills'] += kill_count
|
||||
stats[account_id]['deaths'] += self.account_deaths[account_id]
|
||||
stats[account_id]['scores'] += self.account_scores[account_id]
|
||||
# also incrementing the games played and adding the id
|
||||
stats[account_id]['games'] += 1
|
||||
stats[account_id]['aid'] = str(account_id)
|
||||
# dump our stats back to disk
|
||||
tempppp = None
|
||||
from datetime import datetime
|
||||
with open(statsfile, 'w') as f:
|
||||
f.write(json.dumps(stats))
|
||||
# aaand that's it! There IS no step 27!
|
||||
now = datetime.now()
|
||||
update_time = now.strftime("%S:%M:%H - %d %b %y")
|
||||
print(f"Added {str(len(self._account_kills))} account's stats entries. || {str(update_time)}")
|
||||
refreshStats()
|
||||
|
||||
def getRank(acc_id):
|
||||
global ranks
|
||||
if ranks==[]:
|
||||
refreshStats()
|
||||
if acc_id in ranks:
|
||||
return ranks.index(acc_id)+1
|
||||
14
dist/ba_root/mods/stats/stats.json
vendored
Normal file
14
dist/ba_root/mods/stats/stats.json
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"pb-IF4VAk4a": {
|
||||
"rank": 1,
|
||||
"name_html": "pb-IF4VAk4a",
|
||||
"scores": 0,
|
||||
"total_damage": 0.0,
|
||||
"kills": 0,
|
||||
"deaths": 0,
|
||||
"games": 18,
|
||||
"kd": 0.0,
|
||||
"avg_score": 0.0,
|
||||
"aid": "pb-IF4VAk4a"
|
||||
}
|
||||
}
|
||||
4
dist/ba_root/mods/tools/textonmap.py
vendored
4
dist/ba_root/mods/tools/textonmap.py
vendored
|
|
@ -18,7 +18,7 @@ class textonmap:
|
|||
self.highlights = data['center highlights']
|
||||
self.left_watermark(left)
|
||||
self.top_message(top)
|
||||
self.timer = ba.timer(8, ba.Call(self.highlights), repeat=True)
|
||||
self.timer = ba.timer(8, ba.Call(self.highlights_), repeat=True)
|
||||
|
||||
def highlights_(self):
|
||||
node = _ba.newnode('text',
|
||||
|
|
@ -43,7 +43,7 @@ class textonmap:
|
|||
'h_align': 'left',
|
||||
'v_attach':'bottom',
|
||||
'scale':1,
|
||||
'position':(0,138),
|
||||
'position':(-450,30),
|
||||
'color':(1,1,1)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue