[BMS] Dissolver Help

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

[BMS] Dissolver Help

Postby Painkiller » Sat Oct 08, 2016 2:47 pm

Hello, this plugin does not work with the latest SP version.

Could someone help me to repair?

Syntax: Select all

# ../dissolver/dissolver.py

"""Dissolves player ragdolls on death."""

# =============================================================================
# >> IMPORTS
# =============================================================================
# Python Imports
# Random
from random import randrange
# Warnings
from warnings import warn

# Source.Python Imports
# Config
from config.manager import ConfigManager
# Entities
from entities.constants import DissolveType
from entities.constants import INVALID_ENTITY_INTHANDLE
from entities.entity import Entity
from entities.helpers import index_from_inthandle
# Events
from events import Event
# Listeners
from listeners.tick import Delay
# Players
from players.entity import Player
from players.helpers import index_from_userid
# Translations
from translations.strings import LangStrings

# Script Imports
from .info import info


# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Store the number of dissolve types
_num_dissolve_types = len(DissolveType)

# Get the configuration strings
_config_strings = LangStrings(info.basename)


# =============================================================================
# >> CONFIGURATION
# =============================================================================
# Create the cfg file
with ConfigManager(info.basename, 'dissolver_') as _config:

# Create the dissolver type cvar
dissolver_type = _config.cvar('type', 0, _config_strings['Type'])

# Loop through all dissolver types
for _name in DissolveType.__members__:

# Add the current dissolver type to the list of options
dissolver_type.Options.append('{0} = {1}'.format(
getattr(DissolveType, _name).real, _name))

# Add random and remove to the list of options
for _num, _option in enumerate(('RANDOM', 'REMOVE')):
dissolver_type.Options.append('{0} = {1}'.format(
_num_dissolve_types + _num, _option))

# Create the dissolver magnitude cvar
dissolver_magnitude = _config.cvar(
'magnitude', 2, _config_strings['Magnitude'])

# Create the delay cvar
dissolver_delay = _config.cvar('delay', 0, _config_strings['Delay'])


# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('player_death')
def dissolve_player_ragdoll(game_event):
"""Dissolve/remove the player's ragdoll on death."""
# Get the type of dissolver to use
current_type = dissolver_type.get_int()

# Is the type valid?
if current_type < 0 or current_type > _num_dissolve_types + 2:

# Raise a warning
warn('Invalid value for {0} cvar "{1}".'.format(
dissolver_type.name, current_type))

# Use the remove setting
current_type = _num_dissolve_types + 2

# Delay the dissolving
Delay(
max(0, dissolver_delay.get_int()),
dissolve_ragdoll, game_event['userid'], current_type)


# =============================================================================
# >> HELPER FUNCTIONS
# =============================================================================
def dissolve_ragdoll(userid, current_type):
"""Dissolve/remove the player's ragdoll."""
# Get the ragdoll entity
inthandle = Player(index_from_userid(userid)).ragdoll
if inthandle == INVALID_ENTITY_INTHANDLE:
return
entity = Entity(index_from_inthandle(inthandle))

# Should the ragdoll just be removed?
if current_type == _num_dissolve_types + 2:
entity.remove()
return

# Set the target name for the player's ragdoll
entity.target_name = 'ragdoll_{0}'.format(userid)

# Get the dissolver entity
dissolver_entity = Entity.find_or_create('env_entity_dissolver')

# Should a random dissolve type be chosen?
if current_type == _num_dissolve_types + 1:
current_type = randrange(_num_dissolve_types)

# Set the magnitude
dissolver_entity.magnitude = dissolver_magnitude.get_int()

# Set the dissolve type
dissolver_entity.dissolve_type = current_type

# Dissolve the ragdoll
dissolver_entity.dissolve('ragdoll_{0}'.format(userid))


Code: Select all

sp plugin reload dissolver
[SP] Unable to unload plugin 'dissolver' as it is not currently loaded.
[SP] Loading plugin 'dissolver'...

[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/plugins/manager.py", line 75, in __missing__
    instance = self.instance(plugin_name, self.base_import)
  File "../addons/source-python/packages/source-python/plugins/instance.py", line 82, in __init__
    self._plugin = import_module(import_name)
  File "../addons/source-python/plugins/dissolver/dissolver.py", line 43, in <module>
    _config_strings = LangStrings(info.basename)
  File "../addons/source-python/packages/source-python/translations/strings.py", line 67, in __init__
    'No file found at {0}'.format(self._mainfile))

FileNotFoundError: No file found at ../resource/source-python/translations/dissolver.ini


[SP] Plugin 'dissolver' was unable to be loaded.


Thanks in Advance
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [BMS] Dissolver Help

Postby satoon101 » Sat Oct 08, 2016 3:28 pm

You know, since there is a thread for that plugin, you should probably post this in there:
viewtopic.php?f=7&t=1101

However, it seems to me that you have just forgotten to upload the translations file that is included in the zip.
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [BMS] Dissolver Help

Postby Painkiller » Sat Oct 08, 2016 3:36 pm

Thanks this work good

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 33 guests