Beispiel #1
0
 def on_chat_message_recieved(self, contained: loaders.ChatMessage) -> None:
     if not self.name:
         return
     value = contained.value
     if value.startswith('/'):
         self.on_command(*parse_command(value[1:]))
     else:
         global_message = contained.chat_type == CHAT_ALL
         result = self.on_chat(value, global_message)
         if result == False:
             return
         elif result is not None:
             value = result
         contained.chat_type = CHAT_ALL if global_message else CHAT_TEAM
         contained.value = value
         contained.player_id = self.player_id
         if global_message:
             team = None
         else:
             team = self.team
         for player in self.protocol.players.values():
             if not player.deaf:
                 if team is None or team is player.team:
                     player.send_contained(contained)
         self.on_chat_sent(value, global_message)
Beispiel #2
0
 def on_animation_update(self, jump, crouch, sneak, sprint):
     markers_allowed = (VV_ENABLED and self.allow_markers and
                        self.protocol.allow_markers)
     if markers_allowed and sneak and self.world_object.sneak != sneak:
         now = seconds()
         if self.last_marker is None or now - self.last_marker > COOLDOWN:
             presses = self.sneak_presses
             presses.append(now)
             if len(presses) == 2 and presses[0] >= now - VV_TIMEFRAME:
                 location = self.get_there_location()
                 if location:
                     coords = to_coordinates(*location)
                     chat_message = ChatMessage()
                     chat_message.chat_type = CHAT_TEAM
                     chat_message.player_id = self.player_id
                     chat_message.value = S_SPOTTED.format(
                         coords=coords)
                     self.protocol.send_contained(
                         chat_message, team=self.team)
                     self.make_marker(Enemy, location)
                     presses.clear()
     return connection.on_animation_update(self, jump, crouch, sneak,
                                           sprint)
'''
This script prevents accidentally typing a staff password.
Keep in mind that it doesn't prevent against brute force. Please only use safe passwords.

Author: Rakete175
License: BSD-3
'''

from twisted.internet.reactor import callLater
from pyspades.contained import ChatMessage
chat_message = ChatMessage()


def apply_script(protocol, connection, config):
    class dontrevealyourpasswordconnection(connection):
        def on_chat(self, value, type):
            for jobs, passwords in self.protocol.passwords.items():
                for eachpassword in passwords:
                    if eachpassword in value:
                        if self.client_info:
                            if self.client_info["client"] == "OpenSpades":
                                callLater(0.5, self.send_chat_error,
                                          "Error occured")
                            elif self.client_info["client"] == "BetterSpades":
                                chat_message.player_id = self.player_id
                                chat_message.chat_type = 6
                                chat_message.value = "Error occured"
                                callLater(0.5, self.send_contained,
                                          chat_message)
                            else:
                                callLater(0.5, self.send_chat, "Error occured")