Example #1
0
def _fake_death(attacker, dominated, headshot, revenge, userid, weapon):
    event = game_event_manager.create_event('player_death', True)
    event.set_int('attacker', attacker)
    event.set_int('dominated', dominated)
    event.set_bool('headshot', headshot)
    event.set_int('revenge', revenge)
    event.set_int('userid', userid)
    event.set_string('weapon', weapon)
    game_event_manager.fire_event(event)
Example #2
0
    def fire(self):
        """Fire the event with the stored variable values."""
        # Get the event's instance
        event = game_event_manager.create_event(self.name, True)

        # Loop through the event's variables
        for variable in self._odict:

            # Set the event variable values
            getattr(event, "set_" + self._odict[variable]._method)(variable, getattr(self, "_" + variable))

        # Fire the event
        game_event_manager.fire_event(event)
Example #3
0
def eventscripts_unregister(command):
    if len(command) < 2:
        _print_all_registered_cfg_scripts()
        return

    import es
    scriptpack = command[1]

    event = game_event_manager.create_event('es_scriptpack_unregister', True)
    event.set_string('scriptpack', scriptpack)
    game_event_manager.fire_event(event)

    cfg_scripts[scriptpack] = 0
    es.dbgmsg(0, '[EventScripts] Unregistered script pack: {}'.format(
        command.arg_string))
Example #4
0
def on_query_cvar_value_finished(cookie, index, status, cvar_name, cvar_value):
    event = game_event_manager.create_event('es_player_variable')
    if event is None:
        return

    try:
        userid = userid_from_index(index)
    except ValueError:
        userid = 0

    event.set_int('userid', userid)
    event.set_string('status', QUERY_STATUS.get(status, ''))
    event.set_string('variable', cvar_name)
    event.set_string('value', cvar_value)
    game_event_manager.fire_event(event)
def send_win_message(message='', recipients=None):
    event = game_event_manager.create_event('cs_win_panel_round')
    event.set_string('funfact_token', message)

    if recipients is None:
        game_event_manager.fire_event(event)

    else:
        for index in recipients:
            try:
                # Try to get a Player instance.
                Player(index).base_client.fire_game_event(event)
            except ValueError:
                continue
        game_event_manager.free_event(event)
Example #6
0
def eventscripts_register(command):
    if len(command) < 2:
        _print_all_registered_cfg_scripts()
        return

    import es

    scriptpack = command[1]
    cfg_scripts[scriptpack] = 1
    es.setinfo('{}_dir'.format(scriptpack), '"{}/{}/"'.format(
        scriptdir_cvar.get_string(), scriptpack))

    es.dbgmsg(0, '[EventScripts] Registered script pack: {}'.format(command.arg_string))

    event = game_event_manager.create_event('es_scriptpack_register', True)
    event.set_string('scriptpack', scriptpack)
    game_event_manager.fire_event(event)
Example #7
0
def on_level_init(map_name):
    currentmap_cvar.set_string(map_name)
    if defaultevents_cvar.get_int() != 0:
        default_event_registration()

    event = game_event_manager.create_event('es_map_start')
    if event is not None:
        event.set_string('mapname', map_name)
        game_event_manager.fire_event(event)

    import es
    es.dbgmsg(3, 'es_map_start fired.')
    if autorefreshvars_cvar.get_int() > 0:
        es.refreshpublicvars()

    muparser.clear_vars()
    es.dbgmsg(6, ' Reset variables for muParser.')
Example #8
0
def fire_es_player_chat(command, userid, team_only):
    if len(command) <= 1:
        return

    event = game_event_manager.create_event('es_player_chat')
    if event is None:
        return

    event.set_int('userid', userid)
    event.set_bool('teamonly', team_only)

    full_text = command.arg_string
    if (userid > 0 and full_text[0] == '"' and full_text[-1] == '"'
            and full_text.count('"') <= 2):
        event.set_string('text', full_text[1:-1])
    else:
        event.set_string('text', full_text)

    game_event_manager.fire_event(event)
Example #9
0
    def fire_game_event(self, event_name, **kwargs):
        """Creates and fires an event to this player.

        :param str event_name:
            The name of the event to create and fire.
        :param dict kwargs:
            The variables to set to the event.
        """
        # Create the event
        game_event = game_event_manager.create_event(event_name, True)

        # Set the variables
        game_event.variables.recursive_copy(
            KeyValues.from_dict(event_name, kwargs))

        # Fire the event
        self.base_client.fire_game_event(game_event)

        # Free the event
        game_event_manager.free_event(game_event)
Example #10
0
def on_client_command(command, index):
    import es
    userid = userid_from_index(index)
    if not es.addons.clientCommand(userid):
        return CommandReturn.BLOCK

    command_name = command[0]
    fire_client_command = command_name[0] in cmdprefix_cvar.get_string()
    if fire_client_command or command_name == 'menuselect':
        event = game_event_manager.create_event('es_client_command', True)
        if event is not None:
            event.set_int('userid', userid)
            event.set_string('command', command_name)
            event.set_string('commandstring', command.arg_string)
            try:
                game_event_manager.fire_event(event)
            except RuntimeError:
                # TODO:
                # I have no idea why that happens, but the event gets fired...
                pass
        else:
            es.dbgmsg(0, 'es_client_command not fired! =(')

    return CommandReturn.CONTINUE
Example #11
0
def on_client_command(command, index):
    import es
    userid = userid_from_index(index)
    if not es.addons.clientCommand(userid):
        return CommandReturn.BLOCK

    command_name = command[0]
    fire_client_command = command_name[0] in cmdprefix_cvar.get_string()
    if fire_client_command or command_name == 'menuselect':
        event = game_event_manager.create_event('es_client_command', True)
        if event is not None:
            event.set_int('userid', userid)
            event.set_string('command', command_name)
            event.set_string('commandstring', command.arg_string)
            try:
                game_event_manager.fire_event(event)
            except RuntimeError:
                # TODO:
                # I have no idea why that happens, but the event gets fired...
                pass
        else:
            es.dbgmsg(0, 'es_client_command not fired! =(')

    return CommandReturn.CONTINUE
Example #12
0
def on_network_id_validated(name, networkid):
    event = game_event_manager.create_event('es_player_validated')
    if event is not None:
        event.set_string('name', name)
        event.set_string('networkid', networkid)
        game_event_manager.fire_event(event)