


Syntax: Select all
from random import choice
import colors
from cvars import ConVar
from listeners.tick import Delay
from messages import SayText
from messages.hooks import HookUserMessage
from players.entity import Player
CHAT_STRINGS = {
'HL2MP_Chat_All': '{color}{data.param1}\x01 : {data.param2}',
'HL2MP_Chat_Team': '\x01(Team) {color}{data.param1}\x01 : {data.param2}',
}
# Add any colors not represented in the 'colors' package
CONFIG_COLOR_CHOICES = [
'87CEEB',
]
COLOR_CHOICES = [
str(getattr(colors, color))
for color in dir(colors)
if isinstance(getattr(colors, color), colors.Color)
] + [f'\07{color}' for color in CONFIG_COLOR_CHOICES]
@HookUserMessage('SayText2')
def _saytext2_hook(recipients, data):
if int(ConVar('mp_teamplay')):
return
key = data.message
if key not in CHAT_STRINGS:
return
Delay(
0,
_send_new_message,
(key, data.index, list(recipients)),
{
'data': data,
'color': choice(COLOR_CHOICES)
}
)
recipients.remove_all_players()
def _send_new_message(key, index, *ply_indexes, **tokens):
"""Send the message to the given players."""
message = SayText(
message=CHAT_STRINGS[key],
index=index,
)
message.send(*ply_indexes, **tokens)
Code: Select all
2020-10-29 10:46:35 - sp - MESSAGE [SP] Loading plugin 'colors'...
2020-10-29 10:46:35 - sp - EXCEPTION
[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\plugins\command.py", line 164, in load_plugin
plugin = self.manager.load(plugin_name)
File "..\addons\source-python\packages\source-python\plugins\manager.py", line 180, in load
spec = find_spec(plugin.import_name)
AttributeError: module 'colors' has no attribute '__path__'
satoon101 wrote:Don't call the plugin 'colors'. There's a package called 'colors' inside SP itself, which is what is imported and causing that error.
satoon101 wrote:Don't call the plugin 'colors'. There's a package called 'colors' inside SP itself, which is what is imported and causing that error.
Ayuto wrote:satoon101 wrote:Don't call the plugin 'colors'. There's a package called 'colors' inside SP itself, which is what is imported and causing that error.
I thought we would have a check for that in the plug-in loading logic
Syntax: Select all
sp plugin load os
[SP] Loading plugin 'os'...
[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\plugins\command.py", line 164, in load_plugin
plugin = self.manager.load(plugin_name)
File "..\addons\source-python\packages\source-python\plugins\manager.py", line 180, in load
spec = find_spec(plugin.import_name)
AttributeError: module 'os' has no attribute '__path__'
Syntax: Select all
sp plugin load asyncio
[SP] Loading plugin 'asyncio'...
[SP] Cannot load plugin 'asyncio'. Plugin name cannot be name of a built-in module
Syntax: Select all
spec = find_spec(plugin_name)
if spec is not None and (
spec.origin != 'namespace' and
Path(spec.origin).parent != plugin.file_path.parent):
raise PluginHasBuiltInName(
'Plugin "{}" has the name of a built-in module.'.format(
plugin_name))
Code: Select all
2020-10-31 22:32:46 - sp - MESSAGE [SP] Loading plugin 'alpha_props'...
2020-10-31 22:32:46 - sp - MESSAGE [SP] Successfully loaded plugin 'alpha_props'.
2020-10-31 22:32:46 - sp - MESSAGE [SP] Loading plugin 'culurs'...
2020-10-31 22:32:46 - sp - MESSAGE [SP] Successfully loaded plugin 'culurs'.
2020-10-31 22:32:46 - sp - MESSAGE [SP] Loading plugin 'fiery_bolts'...
2020-10-31 22:32:46 - sp - MESSAGE [SP] Successfully loaded plugin 'fiery_bolts'.
2020-10-31 22:32:46 - sp - MESSAGE [SP] Loading plugin 'npc_points'...
2020-10-31 22:32:46 - sp - MESSAGE [SP] Successfully loaded plugin 'npc_points'.
2020-10-31 22:32:46 - sp - MESSAGE [SP] Loading plugin 'sawblade_trail'...
2020-10-31 22:32:46 - sp - MESSAGE [SP] Successfully loaded plugin 'sawblade_trail'.
2020-10-31 22:32:46 - sp - MESSAGE [SP] Loading plugin 'silent_hill'...
2020-10-31 22:32:46 - sp - MESSAGE [SP] Successfully loaded plugin 'silent_hill'.
2020-10-31 22:32:46 - sp - MESSAGE [SP] Loading plugin 'temp_scanner'...
2020-10-31 22:32:46 - sp - MESSAGE [SP] Successfully loaded plugin 'temp_scanner'.
2020-10-31 22:32:46 - sp - MESSAGE [SP] Loading plugin 'throwables'...
2020-10-31 22:32:46 - sp - MESSAGE [SP] Successfully loaded plugin 'throwables'.
2020-10-31 22:44:54 - sp - EXCEPTION
[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\messages\hooks.py", line 273, in _pre_message_end
data = impl.read(buffer_read)
File "..\addons\source-python\packages\source-python\messages\impl.py", line 112, in read
return cls.read_bitbuffer(buffer)
File "..\addons\source-python\packages\source-python\messages\impl.py", line 159, in read_bitbuffer
param2=buffer.read_string(),
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 21: invalid continuation byte
Users browsing this forum: No registered users and 57 guests