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
222Orbita

Серверостроение – Объявление переменной

Всем добра! У меня есть скрипт с объявлением переменной на включение текстового уведомления при нажатии определённой клавиши.

int Rotation_R = 1;
static bool sendMensage_R = false;
static bool sendMensage_R()
{
	return sendMensage_R;
}
static void MensageSend_R()
{
    sendMensage_R = !sendMensage_R;
	PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
	string Picture = "set:dayz_inventory image:paper";
	if (sendMensage_R)
	{

		NotificationSystem.AddNotificationExtended(0.5, "BaseBuild", "Rotaçao lenta ativada", Picture);
		//GetGame().GetMission().OnEvent(ChatMessageEventTypeID, new ChatMessageEventParams(CCDirect, "BaseBuild", "Rotaçao lenta ativada", "RED"));
		Rotation_R = 6;
		//Print("Rotation Change Test");
	}
	else
	{
		
		NotificationSystem.AddNotificationExtended(0.5, "BaseBuild", "Rotaçao lenta desativada", Picture);
		//GetGame().GetMission().OnEvent(ChatMessageEventTypeID, new ChatMessageEventParams(CCDirect, "BaseBuild", "Rotaçao lenta desativada", "RED"));
		Rotation_R = 1;
	}
}

Мне нужно перевести выделенный цветом текст в строках:

NotificationSystem.AddNotificationExtended(0.5, "BaseBuild", "Rotaçao lenta ativada", Picture);

NotificationSystem.AddNotificationExtended(0.5, "BaseBuild", "Rotaçao lenta desativada", Picture);

Перевожу, добавляю в свой мод, но при старте сервера ругается на многократное объявление переменной Rotation_R.

Переменная int Rotation_R = 1; уже объявлена в оригинале, так вот собственно вопрос: что нужно дописать перед переменной, чтобы скрипт понял, что я хочу объявить одну и ту же переменную второй раз?

Пробовал прописать extern, но что-то пошло не так, говорит, что такой переменной не существует, может не правильно прописал.

Спасибо!

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Переменную ты можешь объявить единажды. Т.е. никакого повторения ее. Если тебе ее надо использовать, то тут 2 варианта, либо ты ее объявляешь единажды и потом попросту используешь, либо ты меняешь имя этой переменной там, где ты ее 2 раз объявлять пытаешься (и далее по коду соответственно)

Это правило по сути здравого смысла, логики, да и програмирования здравого человека.

А если у тебя 2 одинаковые функции, разрящиеся в зависимости от переменной - добавь эту несчастную переменную в параметры вызова функции и не мучайся, сильно сократишь себе нервы и время.

Edited by 123new (see edit history)

Share this post


Link to post
Share on other sites



  • 0

@123new Спасибо, изменил имя переменой, далее по коду и всё пошло.

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.