Jump to content
robbyj

How to display player count on your server

Recommended Posts

ThePyrotechnic and I developed a BEC plugin for DayZStandalone servers that will display the number of players on your server. I have this plugin running on my server r/dayzPub if you'd like to see it in action before installing.

Tutorial: https://www.twitch.tv/videos/316793437

Github: https://github.com/robbyjm/RobbysPlayerPlugin

 

  • Thanks 1
  • Beans 1

Share this post


Link to post
Share on other sites
57 minutes ago, robbyj said:

ThePyrotechnic and I developed a BEC plugin for DayZStandalone servers that will display the number of players on your server. I have this plugin running on my server r/dayzPub if you'd like to see it in action before installing.

Tutorial: https://www.twitch.tv/videos/316793437

Github: https://github.com/robbyjm/RobbysPlayerPlugin

 

Checking it out now, thanks.

Share this post


Link to post
Share on other sites

Works great thanks, I notice it includes the Rcon login as a player is there away around that so It says 0 player when there are no players in the server?, Good work btw.

Share this post


Link to post
Share on other sites
5 hours ago, ICEMAN-FMCS said:

Works great thanks, I notice it includes the Rcon login as a player is there away around that so It says 0 player when there are no players in the server?, Good work btw.

Are you using any other RCon tool besides BEC?

Share this post


Link to post
Share on other sites
5 hours ago, robbyj said:

Are you using any other RCon tool besides BEC?

Yea im using DaRT all good.

 

4 hours ago, SilvioDoHOTS said:

@robbyj it is possible to create a plugin that shows a massage everytime a player dies? If yes, can you help me with a plugin?

This seems good....

Share this post


Link to post
Share on other sites
8 hours ago, SilvioDoHOTS said:

@robbyj it is possible to create a plugin that shows a massage everytime a player dies? If yes, can you help me with a plugin?

Not possible with BEC

Share this post


Link to post
Share on other sites

Hey, i am sorry but it does not work for me, i dont know why, i created a new Folder called it "Plugins" moved your "RobbysPlayerPlugin" Folder in (with the __init__.py inside) but it does not load anything, just connecting to the Server. Do i miss something in my Config ?

Greetz Gondalf

 

 

Share this post


Link to post
Share on other sites
34 minutes ago, G0ndalf said:

Hey, i am sorry but it does not work for me, i dont know why, i created a new Folder called it "Plugins" moved your "RobbysPlayerPlugin" Folder in (with the __init__.py inside) but it does not load anything, just connecting to the Server. Do i miss something in my Config ?

Greetz Gondalf

 

 

hii guys, i have same problem like @G0ndalf , i checked everything but my bec doesnt load the plugin.

Share this post


Link to post
Share on other sites
On 9/30/2018 at 3:04 PM, robbyj said:

ThePyrotechnic and I developed a BEC plugin for DayZStandalone servers that will display the number of players on your server. I have this plugin running on my server r/dayzPub if you'd like to see it in action before installing.

Tutorial: https://www.twitch.tv/videos/316793437

Github: https://github.com/robbyjm/RobbysPlayerPlugin

 

 

Works great!  Thanks!

Share this post


Link to post
Share on other sites

Is this version dependant? I'm using BEC version 1.496 and don't seem to be able to get it to work!

My problem is that I can't get the latest version of BEC to work on my server, only 1.496 works.

Share this post


Link to post
Share on other sites
'''
    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)

 

Share this post


Link to post
Share on other sites
19 minutes ago, freak69 said:

'''
    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)

 

 

The thing is functional, although there are some issue in naming variables/functions and some other stuff. 

@robbyj there is an open pull request 

Share this post


Link to post
Share on other sites

never used python for anything ^_^ I don't even understand why people need this as battleye remote control tools like DaRT do this already

Share this post


Link to post
Share on other sites
1 hour ago, freak69 said:

never used python for anything ^_^ I don't even understand why people need this as battleye remote control tools like DaRT do this already

Python is a great language tbh and dart doesnt do this out of the box you have to get a modified version of it, so the standard admin uses bec & dart in conjunction

  • Like 1

Share this post


Link to post
Share on other sites

It's complicated. There is a simpler method.

 

zQRTWZq4KLM.jpg

 

Add the script to a file:

..\DayZServer\mpmissions\dayzOffline.chernarusplus\init.c

 

	override void OnInit()
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 30000, true);		// 30 seconds
	}
	
	void NumPLayersOnServer()
	
	{
		ref array<Man> players = new array<Man>;
		GetGame().GetPlayers( players );
		int numPlayers = players.Count();
		
		for ( int i = 0; i < players.Count(); ++i )
		{
			Man player = players.Get(i);
			if( player )
			{
				string messPlayers = "Players on the server: " + numPlayers.ToString();
				Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
				GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 

			}
		}
		
	}
	

 

znUdrLcPrk4.jpg


        

    

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
On 03/10/2018 at 2:47 AM, freak69 said:

'''
    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)

 

why does rcon need to be told when there are no players online? If it's a tool like dart, you'll see no players on the list... BEC even shows the number of players at the top by default. So if there are no players online, there is no real logical reason to output the text.

That's what I gathered from going through the code of it. It just doesn't make sense to need to handle sending a "no players" message, because there are no players to receive the message.

Share this post


Link to post
Share on other sites
6 hours ago, Mizev said:

It's complicated. There is a simpler method.

 

zQRTWZq4KLM.jpg

 

Add the script to a file:

..\DayZServer\mpmissions\dayzOffline.chernarusplus\init.c

 


	override void OnInit()
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 30000, true);		// 30 seconds
	}
	
	void NumPLayersOnServer()
	
	{
		ref array<Man> players = new array<Man>;
		GetGame().GetPlayers( players );
		int numPlayers = players.Count();
		
		for ( int i = 0; i < players.Count(); ++i )
		{
			Man player = players.Get(i);
			if( player )
			{
				string messPlayers = "Players on the server: " + numPlayers.ToString();
				Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
				GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 

			}
		}
		
	}
	

 

znUdrLcPrk4.jpg


        

    

Nice idea, how can I display the display 1 or 2 lines higher, if you have a weapon in hand, the number of players is hidden

Share this post


Link to post
Share on other sites
3 minutes ago, ulli_123 said:

Nice idea, how can I display the display 1 or 2 lines higher, if you have a weapon in hand, the number of players is hidden

By sending X amount of messages afterwards containing only whitespaces

Share this post


Link to post
Share on other sites

Are you so nice and give me an example, have blank lines already synonymous rumprobiert, but did not work, it was only error messages when starting the server

Share this post


Link to post
Share on other sites

Param1<string> empty = new Param1<string>(" "); 
GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, empty, true, player.GetIdentity()); 

Thats how you send a message to a single player. you have to place that in the loop

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, Mizev said:

It's complicated. There is a simpler method.

 

zQRTWZq4KLM.jpg

 

Add the script to a file:

..\DayZServer\mpmissions\dayzOffline.chernarusplus\init.c

 


	override void OnInit()
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 30000, true);		// 30 seconds
	}
	
	void NumPLayersOnServer()
	
	{
		ref array<Man> players = new array<Man>;
		GetGame().GetPlayers( players );
		int numPlayers = players.Count();
		
		for ( int i = 0; i < players.Count(); ++i )
		{
			Man player = players.Get(i);
			if( player )
			{
				string messPlayers = "Players on the server: " + numPlayers.ToString();
				Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
				GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 

			}
		}
		
	}
	

 

znUdrLcPrk4.jpg


        

    

Nice and how to change loop for show this message to every 10 mins?

  • Like 1

Share this post


Link to post
Share on other sites
49 minutes ago, Ton_41 said:

Nice and how to change loop for show this message to every 10 mins?

GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 30000, true); // 30 seconds

GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 600000, true); // 10 Min.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×