Kann mir jemand sagen wo in Zeile 46 der Syntax error ist ?
Python
from players.entity import Player
from events import Event
from events.hooks import PreEvent, EventAction
from filters.players import PlayerIter
from lms import config
from messages import SayText2, HudMsg
from listeners.tick import Delay,Repeat
from commands.server import ServerCommand
from commands.client import ClientCommand
from commands.say import SayCommand
from commands import CommandReturn
from engines.server import queue_command_string
from configobj import ConfigObj
from paths import PLUGIN_DATA_PATH
import os
import re
already_played = {}
if not os.path.isdir(PLUGIN_DATA_PATH+"/lms"):
os.makedirs (PLUGIN_DATA_PATH+"/lms")
db_path = os.path.join(PLUGIN_DATA_PATH,'lms','database.ini')
database = ConfigObj(db_path)
for player in PlayerIter():
steamid = player.steamid
already_played[steamid] = 0
if "BOT" in steamid:
steamid = "BOT_"+player.name
else:
steamid = steamid.replace("[","").replace("]","")
if not steamid in database:
database[steamid] = {}
database[steamid]['points'] = 0
def display_players():
living_players = get_living_player_count()
all_players = get_player_count()
if living_players >= 2:
HudMsg("Last Man Standing\n"+str(living_players)+" von "+str(all_players)+" Spielern sind noch übrig",-1,0.02,channel=1).send()
else:
count = 0
for player in PlayerIter('alive'):
count += 1
name = player.name
if count > 0:
HudMsg("Last Man Standing\n"+str(name)+" hat diese Runde gewonnen",-1,0.02,channel=1).send()
display_players_repeat = Repeat(display_players)
display_players_repeat.start(0.5)
@PreEvent('player_activate')
def activate(ev):
player = Player.from_userid(int(ev['userid']))
steamid = player.steamid
if player.steamid not in already_played:
already_played[player.steamid] = 0
if already_played[player.steamid] == 1:
Delay(0.1,_late_join,(player.index,))
if "BOT" in steamid:
steamid = "BOT_"+player.name
else:
steamid = steamid.replace("[","").replace("]","")
if not steamid in database:
database[steamid] = {}
database[steamid]['points'] = 0
def _late_join(index):
Player(index).team = 1
SayText2("\x04[LastManStanding] \x03Du musst warten bis die neue Runde beginnt").send(index)
@Event('player_death')
def player_death(ev):
player = Player.from_userid(int(ev['userid']))
player.team = 1
attacker = Player.from_userid(int(ev['attacker']))
player_steamid = player.steamid
already_played[player.steamid] = 1
if "BOT" in player_steamid:
player_steamid = "BOT_"+player.name
else:
player_steamid = player_steamid.replace("[","").replace("]","")
attacker_steamid = attacker.steamid
if "BOT" in attacker_steamid:
attacker_steamid = "BOT_"+attacker.name
else:
attacker_steamid = attacker_steamid.replace("[","").replace("]","")
if attacker != player:
give_points(attacker_steamid,config.cfg['ppk'])
living_players = get_living_player_count()
if living_players == 2:
give_points(player_steamid, config.cfg['ptp'])
SayText2("\x04[LastManStanding] "+player.name+" \x03ist auf dem \x04dritten \x03Platz!").send()
if living_players == 1:
give_points(player_steamid, config.cfg['psp'])
SayText2("\x04[LastManStanding] "+player.name+" \x03ist auf dem \x04zweiten \x03Platz!").send()
if attacker.name != player.name:
give_points(attacker_steamid, config.cfg['pfp'])
SayText2("\x04[LastManStanding] "+attacker.name+" \x03ist der \x04Last Man Standing!").send()
HudMsg(""+attacker.name+" ist der Last Man Standing",-1,0.4).send()
else:
for player in PlayerIter('alive'):
steamid = player.steamid
if "BOT" in steamid:
steamid = "BOT_"+player.name
else:
steamid = steamid.replace("[","").replace("]","")
give_points(steamid, config.cfg['pfp'])
SayText2("\x04[LastManStanding] "+player.name+" \x03ist der \x04Last Man Standing!").send()
HudMsg(""+player.name+" ist der Last Man Standing",-1,0.4).send()
_restart_game()
def _restart_game():
SayText2("\x04[LastManStanding] \x03Die neue Runde beginnt in\x04 5 Sekunden").send()
already_played = {}
for player in PlayerIter():
player.team = 0
already_played[player.steamid] = 0
queue_command_string("mp_restartgame 5")
def save_database():
database.write()
def give_points(steamid,amount):
points = int(database[steamid]['points'])
database[steamid]['points'] = (points+amount)
save_database()
#Get the amount of living players
def get_living_player_count():
count = 0
for player in PlayerIter('alive'):
count += 1
return count
def get_player_count():
count = 0
for player in PlayerIter():
count += 1
return count
#Block teamchange messages
@PreEvent('player_team')
def team(ev):
if int(ev['team']) in [0,1]:
return EventAction.BLOCK
#Block usage of jointeam
@ClientCommand('jointeam')
def join_test(command,index):
return CommandReturn.BLOCK
#Rank command and helper function
def get_rank(steamid):
steamid = steamid.replace("[","").replace("]","")
ranks = sorted(database, key=lambda x: int(database[x]['points']),reverse=True)
i = 0
for x in ranks:
i += 1
if x == steamid:
break
return(i,len(ranks))
@SayCommand('rank')
@ClientCommand('rank')
def rank(command,index,team=None):
player = Player(index)
rank,ofall = get_rank(player.steamid)
SayText2("\x04[LastManStanding] \x03Du bist auf Platz \x04"+str(rank)+"\x03 von \x04"+str(ofall)+".").send(player.index)
return CommandReturn.BLOCK
#ServerCommand that restarts the current round and respawns every player
@ServerCommand('lms_restart')
def _restart(command):
_restart_game()
Alles anzeigen
Code
21:42:55 sp plugin reload lms
21:42:55 [SP] Unloading plugin 'lms'...
[SP] Unable to unload plugin 'lms' as it is not currently loaded.
[SP] Loading plugin 'lms'...
[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/packages/source-python/plugins/command.py", line 162, in load_plugin
plugin = self.manager.load(plugin_name)
File "../addons/source-python/packages/source-python/plugins/manager.py", line 194, in load
plugin._load()
File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
self.module = import_module(self.import_name)
File "../addons/source-python/plugins/lms/lms.py", line 46
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xfc in position 20: invalid start byte
[SP] Plugin 'lms' was unable to be loaded.
Alles anzeigen