Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Need help?

    Create a topic in the appropriate section
    Don't write everything in the chat!
  • Take a look at the marketplace

    There you can buy
    everything related to game servers
  • Don't want a ban?

    Please read our rules
    Don't disturb the order!
  • Sell or buy?

    Use services of the guarantor
    We will make your deal safe
  • 0
billylee

Вывод даты сервера в сообщения игрокам

Господа, спасители!
Настроена погода, но она сильно разнится по месяцам, дабы игроков не путать, возникла идея создать сообщения, настает новый день и в чат глобал админ или хз кто\что - пишет - день такой-то, октябрь... Насколько много я захотел?)

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0
modded class PlayerBase
{
	override void OnConnect()
	{
		super.OnConnect();
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(this.OnConnectMessage, 10000, false);
	}
	void OnConnectMessage()
	{
		int year, month, day, hour, minute;
		GetGame().GetWorld().GetDate(year, month, day, hour, minute);
		MessageAction("Сегодня " + day + "." + month + "." + year);
	}
}

GetDate - это игровое время
месяц по номеру можно превратит в текстовый

Share this post


Link to post
Share on other sites



  • 0

Спасибо! эту радость сервермодом надо  я так понял?

Share this post


Link to post
Share on other sites
  • 0

но и персистент тайм не забудь включить в сервердз.сфг

Share this post


Link to post
Share on other sites
  • 0
28.12.2023 в 13:56, Archon7th сказал:

 

 


modded class PlayerBase и т.д.
 

Я дико извиняюсь, не подскажете в каком файле внести эти изменения?

Edited by billylee (see edit history)

Share this post


Link to post
Share on other sites
  • 0

@billylee сервермод используете ServerListMod ?
если да, то можете в любой папке с 4-ми скриптами  создать файл например PlayerConnMessage.c
прописать к нему путь в ServerListMod\4_World_modded.txt
ну и всё

Share this post


Link to post
Share on other sites
  • 0

....а слабо вывод текущей даты, времени и температуры в чат через каждые 15 минут?

 

 

Share this post


Link to post
Share on other sites
  • 0

@paranoyk А в чем проблема-то?
если не личная температура каждого игрока
без учета высоты
без учета поверхности на которой находится игрок
без учета "в машине" и "в здании"
именно температура воздуха, то вот так:

modded class MissionServer
{
	override void OnInit()
	{
		super.OnInit();
		GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( this.Every15MinMessage, 15*60000, true );
	}

	void Every15MinMessage()
	{
		Weather weather	= GetGame().GetWeather();
		float temperature;
		temperature = GetGame().GetMission().GetWorldData().GetBaseEnvTemperature();
		temperature += Math.AbsFloat(temperature * weather.GetOvercast().GetActual() * GameConstants.ENVIRO_CLOUDS_TEMP_EFFECT);
		
		temperature -= GameConstants.ENVIRO_TEMPERATURE_WIND_COEF * weather.GetWindSpeed() / weather.GetWindMaximumSpeed();
		temperature -= Math.AbsFloat(temperature * weather.GetFog().GetActual() * GameConstants.ENVIRO_FOG_TEMP_EFFECT);
		
		int year, month, day, hour, minute;
		GetGame().GetWorld().GetDate(year, month, day, hour, minute);
		
		array<Man> players = new array<Man>();
		GetGame().GetPlayers(players);
			
		foreach (Man man : players)
		{
			PlayerBase player;
			if (Class.CastTo(player, man))
				player.MessageAction("Сегодня " + day + "." + month + "." + year + " температура воздуха "+Math.Round(temperature));
		}
	}
};


если личная температура окружения игрока (типа термометр на игроке)
то достаточно убрать все подсчеты температуры выше 

if (Class.CastTo(player, man) && player.m_Environment)
{
	float temperature = player.m_Environment.GetTemperature();
	player.MessageAction("Сегодня " + day + "." + month + "." + year + " температура "+Math.Round(temperature));
}

но не забыть убедиться что m_Environment уже проинициализировался, а-то будет ошибко

Share this post


Link to post
Share on other sites
  • 0
20 часов назад, Archon7th сказал:

сервермод используете ServerListMod ?

"-servermod= вот так использую в батнике строку)

Edited by billylee (see edit history)

Share this post


Link to post
Share on other sites
  • 0

ОГРОМНОЕ СПАСИБО! Заработало, добавил первый самый код сервермодом, второй с температурой чтото не захотел))), но там уже расковыряю что к чему, безмерно благодарен.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site, you automaticly agree to our Guidelines and Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.