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
AlexCa31

Спавн аттачмента через скрипт

Задача : Сделать так, что бы при спавне пушки на ней появлялся прицел.
На модели оружия стоит прокси прицела, цфг слотс и прокси аттачмент прицела прописаны, все вешается и работает. 
Написал для этого скрипт, но он не работает 
 

class air_weapon_g36_base: RifleBoltFree_Base
{
	void AssembleGun()
	{
		if (!FindAttachmentBySlotName("red_dotg36"))
		{
			GetInventory().CreateAttachment("air_module_g36_red");
		}
	}
}

Может кто-то подсказать, где я продолбался (в скриптах я пень). 

Share this post


Link to post
Share on other sites

13 answers to this question

Recommended Posts

  • 1
30 минут назад, AlexCa31 сказал:

Теперь проблема в том, что бы задействовать функции AssembleGun при появлении оружия 

class air_weapon_g36_base: RifleBoltFree_Base
{
	void air_weapon_g36_base () 
    {
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(AssembleGun, (1 * 1000), false);
    }
	void AssembleGun()
	{
		if (!this.FindAttachmentBySlotName("red_dotg36"))
		{
			this.GetInventory().CreateAttachment("air_module_g36_red");
		}
	}
}

 

Share this post


Link to post
Share on other sites



  • 1

Не рекомендую использовать CallLater

Кстати какой сакральный смысл использования математической операции умножения на 1 ? (1 * 1000)
 

Используйте либо таймер

 

либо

GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(AssembleGun);

 

а еще лучше шататную инициализацию вызываемую в конце конструктора базового класса

это наименее затратный с тз ресурсов сервера способ
 

override void InitStateMachine ()
{
	super.InitStateMachine();
	GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(AssembleGun);
}



 

Share this post


Link to post
Share on other sites
  • 0
14 минут назад, AlexCa31 сказал:

На модели оружия стоит прокси прицела, цфг слотс и прокси аттачмент прицела прописаны, все вешается и работает. 

Если сделал все правильно и на сервере все вешается, остается прописать только в cfgspawnabletypes.xml

Вот пример калашика:

<type name="AK101">
		<attachments chance="0.30">
			<item name="AK_FoldingBttstck" chance="0.30" />
		</attachments>
		<attachments chance="0.30">
			<item name="AK_WoodBttstck" chance="0.30" />
		</attachments>
		<attachments chance="1.00">
			<item name="AK_PlasticBttstck" chance="1.00" />
		</attachments>
		<attachments chance="0.30">
			<item name="AK_WoodHndgrd" chance="0.30" />
		</attachments>
		<attachments chance="1.00">
			<item name="AK_PlasticHndgrd" chance="1.00" />
		</attachments>
		<attachments chance="0.30">
			<item name="KashtanOptic" chance="0.50" />
			<item name="PSO11Optic" chance="0.30" />
		</attachments>
		<attachments chance="0.30">
			<item name="AK_Suppressor" chance="0.50" />
		</attachments>
		<attachments chance="0.30">
			<item name="Mag_AK101_30Rnd" chance="0.50" />
		</attachments>
	</type>

Пробуй.

Помог? Савь Лайк!

Share this post


Link to post
Share on other sites
  • 0
1 минуту назад, Funduk сказал:

Если сделал все правильно и на сервере все вешается, остается прописать только в cfgspawnabletypes.xml

Вот пример калашика:

<type name="AK101"> <attachments chance="0.30"> <item name="AK_FoldingBttstck" chance="0.30" /> </attachments> <attachments chance="0.30"> <item name="AK_WoodBttstck" chance="0.30" /> </attachments> <attachments chance="1.00"> <item name="AK_PlasticBttstck" chance="1.00" /> </attachments> <attachments chance="0.30"> <item name="AK_WoodHndgrd" chance="0.30" /> </attachments> <attachments chance="1.00"> <item name="AK_PlasticHndgrd" chance="1.00" /> </attachments> <attachments chance="0.30"> <item name="KashtanOptic" chance="0.50" /> <item name="PSO11Optic" chance="0.30" /> </attachments> <attachments chance="0.30"> <item name="AK_Suppressor" chance="0.50" /> </attachments> <attachments chance="0.30"> <item name="Mag_AK101_30Rnd" chance="0.50" /> </attachments> </type>


<type name="AK101">
		<attachments chance="0.30">
			<item name="AK_FoldingBttstck" chance="0.30" />
		</attachments>
		<attachments chance="0.30">
			<item name="AK_WoodBttstck" chance="0.30" />
		</attachments>
		<attachments chance="1.00">
			<item name="AK_PlasticBttstck" chance="1.00" />
		</attachments>
		<attachments chance="0.30">
			<item name="AK_WoodHndgrd" chance="0.30" />
		</attachments>
		<attachments chance="1.00">
			<item name="AK_PlasticHndgrd" chance="1.00" />
		</attachments>
		<attachments chance="0.30">
			<item name="KashtanOptic" chance="0.50" />
			<item name="PSO11Optic" chance="0.30" />
		</attachments>
		<attachments chance="0.30">
			<item name="AK_Suppressor" chance="0.50" />
		</attachments>
		<attachments chance="0.30">
			<item name="Mag_AK101_30Rnd" chance="0.50" />
		</attachments>
	</type>

Пробуй.

Помог? Савь Лайк!

Мне нужен клиентский скрипт внутри мода. Что бы при спавне через админку на определенном слоте находился определенный прицел

 

Share this post


Link to post
Share on other sites
  • 0
32 минуты назад, AlexCa31 сказал:

Что бы при спавне через админку на определенном слоте находился определенный прицел

Это уже в админке прописывается набор, в клиентском моде этого делать не нужно.

Share this post


Link to post
Share on other sites
  • 0
Только что, Funduk сказал:

Это уже в админке прописывается набор, в клиентском моде этого делать не нужно.

Вот нужно что бы это было в моде. Тобишь что бы это работало и при спавне через спавн меню,  и через спавн из трейдера и т.д.

Share this post


Link to post
Share on other sites
  • 0
2 минуты назад, AlexCa31 сказал:

Тобишь что бы это работало и при спавне через спавн меню,  и через спавн из трейдера и т.д.

Либо лыжи у меня не едут, либо асфальт хреновый, не догоняю, а зачем? Если так нужно то можно сделать модель уже готовую с прицелом, не нужно тогда ни чего аттачить.

В противном случае нет смысла это делать.

Share this post


Link to post
Share on other sites
  • 0
1 минуту назад, Funduk сказал:

Либо лыжи у меня не едут, либо асфальт хреновый, не догоняю, а зачем? Если так нужно то можно сделать модель уже готовую с прицелом, не нужно тогда ни чего аттачить.

В противном случае нет смысла это делать.

Есть пушка, для нее сделан прицел, который ставится только на нее. Я хочу что-бы пушка спавнилась сразу с этим прицелом. Прицел в модели пушки сделать - не вариант 

 

Share this post


Link to post
Share on other sites
  • 0
class air_weapon_g36_base: RifleBoltFree_Base
{
	void AssembleGun()
	{
		if (!this.FindAttachmentBySlotName("red_dotg36"))
		{
			this.GetInventory().CreateAttachment("air_module_g36_red");
		}
	}
}

 

Share this post


Link to post
Share on other sites
  • 0
16 минут назад, 123new сказал:

class air_weapon_g36_base: RifleBoltFree_Base { void AssembleGun() { if (!this.FindAttachmentBySlotName("red_dotg36")) { this.GetInventory().CreateAttachment("air_module_g36_red"); } } }


class air_weapon_g36_base: RifleBoltFree_Base
{
	void AssembleGun()
	{
		if (!this.FindAttachmentBySlotName("red_dotg36"))
		{
			this.GetInventory().CreateAttachment("air_module_g36_red");
		}
	}
}

 

Теперь проблема в том, что бы задействовать функции AssembleGun при появлении оружия 

Share this post


Link to post
Share on other sites
  • 0
12 минут назад, 123new сказал:

class air_weapon_g36_base: RifleBoltFree_Base { void air_weapon_g36_base () { GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(AssembleGun, (1 * 1000), false); } void AssembleGun() { if (!this.FindAttachmentBySlotName("red_dotg36")) { this.GetInventory().CreateAttachment("air_module_g36_red"); } } }


class air_weapon_g36_base: RifleBoltFree_Base
{
	void air_weapon_g36_base () 
    {
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(AssembleGun, (1 * 1000), false);
    }
	void AssembleGun()
	{
		if (!this.FindAttachmentBySlotName("red_dotg36"))
		{
			this.GetInventory().CreateAttachment("air_module_g36_red");
		}
	}
}

 

Спасибо большое, все работает

Share this post


Link to post
Share on other sites
  • 0
1 час назад, 123new сказал:

class air_weapon_g36_base: RifleBoltFree_Base { void air_weapon_g36_base () { GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(AssembleGun, (1 * 1000), false); } void AssembleGun() { if (!this.FindAttachmentBySlotName("red_dotg36")) { this.GetInventory().CreateAttachment("air_module_g36_red"); } } }


class air_weapon_g36_base: RifleBoltFree_Base
{
	void air_weapon_g36_base () 
    {
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(AssembleGun, (1 * 1000), false);
    }
	void AssembleGun()
	{
		if (!this.FindAttachmentBySlotName("red_dotg36"))
		{
			this.GetInventory().CreateAttachment("air_module_g36_red");
		}
	}
}

 

Еще вопрос, как повысить интервалы запроса? Ибо серверный фпс жрет много

Share this post


Link to post
Share on other sites
  • 0
22 минуты назад, BorizzK сказал:

Не рекомендую использовать CallLater

Кстати какой сакральный смысл использования математической операции умножения на 1 ? (1 * 1000)
 

Используйте либо таймер

 

либо

GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(AssembleGun);


GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(AssembleGun);

 

а еще лучше шататную инициализацию вызываемую в конце конструктора базового класса

это наименее затратный с тз ресурсов сервера способ
 

override void InitStateMachine () { super.InitStateMachine(); GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(AssembleGun); }


override void InitStateMachine ()
{
	super.InitStateMachine();
	GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(AssembleGun);
}



 

Спасибо за последний скрипт, разгрузило фпс 

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.