'''
File name: __init__.py
Author: /u/robbychampagne, ThePyrotechnic
Date created: 9/29/2018
Date last modified: 9/29/2018
'''
from twisted.internet import task
class RobbysPlayerPlugin:
''' Player plugin for DayZ servers'''
def __init__(self, instance):
self.bec = instance
# Create a Task that calls the function Send_PlayerCount each 15 min.
self.PlayerCount_Task = task.LoopingCall(self.Send_PlayerCount)
self.PlayerCount_Task.start(900, False)
def get_players(self):
return self.bec.Bec_playersconnected
def Send_PlayerCount(self):
'''Send a message to all players in game.'''
players = self.get_players()
if len(players) > 0:
rcon_msg = 'Say -1 There are %i players online' % len(players)
else:
rcon_msg = 'Say -1 There no player online'
self.bec._Bec_queuelist.append(rcon_msg)
def start(x):
RobbysPlayerPlugin(x)
Would this not make more sense as in if there is players show the player count and if there is no player say that there is no player or 0 players online?
maybe even
def Send_PlayerCount(self):
'''Send a message to all players in game.'''
players = self.get_players()
rcon_msg = 'Say -1 There are %i players online' % len(players)
self.bec._Bec_queuelist.append(rcon_msg)