[HL2:DM] problems with admin join sound
Posted: Sat Apr 27, 2019 2:54 pm
The plugin loads without problems.
I think it is missing the downloadable in the script.
So I added by hand sound files to the client but even then the sound did not play.
I do not know where that problem lies.
PLUGIN:
CONFIG:
I think it is missing the downloadable in the script.
So I added by hand sound files to the client but even then the sound did not play.
I do not know where that problem lies.
PLUGIN:
Syntax: Select all
import os
from configobj import ConfigObj
from events import Event
from players.helpers import index_from_userid
from players.entity import Player
from engines.sound import Sound
from filters.recipients import RecipientFilter
from filters.players import PlayerIter
from listeners.tick import Delay
admin_list = []
def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path
class InI(object):
def __init__(self):
self.path = get_addon_path()
self.admins = os.path.join(self.path, 'admins', 'admins.ini')
def getAdmin(self, steamid):
return self.admins[steamid]
@property
def getAdmins(self):
return ConfigObj(self.admins)
ini = InI()
def load():
alladmins = ini.getAdmins
for steamid in alladmins:
admin_list.append(steamid)
print(admin_list)
def play_sound(sound):
if sound != "":
for player in PlayerIter():
Sound(sound).play(player.index)
@Event('player_activate')
def _player_activate(event):
player = Player(index_from_userid(event.get_int('userid')))
steamid = player.steamid.strip('[')
steamid = steamid.strip(']')
if steamid in admin_list:
all_admins = ini.getAdmins
admin_info = all_admins[steamid]
join_sound = admin_info['join_sound']
Delay(35, play_sound, join_sound)
@Event('player_disconnect')
def _player_disconnect(event):
player = Player(index_from_userid(event.get_int('userid')))
steamid = player.steamid.strip('[')
steamid = steamid.strip(']')
if steamid in admin_list:
all_admins = ini.getAdmins
admin_info = all_admins[steamid]
disconnect_sound = admin_info['disconnect_sound']
Delay(35, play_sound, disconnect_sound)
CONFIG:
Code: Select all
[U:1:43907303]
join_sound = "/connect/personal.mp3"
disconnect_sound = "/connect/see you.mp3"