Jump to content
Sign in to follow this  
mrwolv

Player Count in game

Recommended Posts

i used to use a chunk of code in my mp mission init.c and it used to call out the ammount of  players perfectly on the server when they connect here is the code

 

//Player Call Start//
	override void OnInit()
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 300000, 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()); 

			}
		}
		
	}
	//Player Call End//

 

but i have added the trader mod to my server now and this stops the trader mod working is there a mod or plugin that will solve this for me as i want it to call players out when they join the server thanks

Edited by mrwolv

Share this post


Link to post
Share on other sites

you add it under class CustomMission: MissionServer but if you use the trader plugin it will break the plugin for you but it dose work

 

class CustomMission: MissionServer
{	
    
	
	//Player Call Start//
	override void OnInit()
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 300000, 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()); 

			}
		}
		
	}
	//Player Call End//


 

  • Thanks 1

Share this post


Link to post
Share on other sites
45 minutes ago, mrwolv said:

you add it under class CustomMission: MissionServer but if you use the trader plugin it will break the plugin for you but it dose work

 


class CustomMission: MissionServer
{	
    
	
	//Player Call Start//
	override void OnInit()
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 300000, 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()); 

			}
		}
		
	}
	//Player Call End//


 

Beans for u. Now Working perfectly

 

  • 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
Sign in to follow this  

×