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
thessend

Патроны при распаковке рандом( от состояния пачки)

Recommended Posts

Данный скрипт позволяет при распаковке пачек патронов получать разное кол-во пуль в зависимости от состояния коробки.
Скрип является онли серверным

enum BoxTypes
{
	NAIL, // Перечислены коробки которые мы хотим сделать рандомное выпадения
	AMMO556X45,
	AMMO556X45T,
	AMMO308WIN,
	AMMO308WINT,
	AMMO762X54,
	AMMO762X54T,
	AMMO762X39,
	AMMO762X39T,
	AMMO22,
	AMMO357,
	AMMO45ACP,
	AMMO9X19,
	AMMO380,
	AMMO00BUCK,
	AMMO12GASLUG,
	AMMO12GARUBBERSLUG,
	AMMO12GABEANBAG,
	AMMO545X39,
	AMMO545X39T,
	AMMO9X39AP,
	AMMO9X39
}

modded class ActionUnpackBox: ActionContinuousBase
{	
	override void OnFinishProgressServer( ActionData action_data )
	{
		if ( action_data.m_MainItem && action_data.m_MainItem.GetHierarchyRootPlayer() == action_data.m_Player )
		{
			int boxType = GetBoxType(action_data.m_MainItem.GetType());
			float quantityMinBD;
			float quantityMaxBD;
			float quantityMinD;
			float quantityMaxD;
			float quantityMinW;
			float quantityMaxW;
			float quantityMinP;
			float quantityMaxP;
			bool hasPaper;
			
			switch(boxType)
			{
				case BoxTypes.NAIL: // Добавляем тут тип тот же что и в ENUM
					quantityMinBD = 0.10;//Минимальный процент количества в стадии сильно поврежденного
					quantityMaxBD = 0.15;//Максимальный процент количества в стадии сильно поврежденного
					quantityMinD = 0.20;//Минимальный процент количества в стадии поврежденного
					quantityMaxD = 0.30;//Максимальный процент количества в стадии поврежденного
					quantityMinW = 0.30;//Минимальный процент количества в стадии поношенного
					quantityMaxW = 0.65;//Максимальный процент количества в стадии поношенного
					quantityMinP = 0.70;//Минимальный процент количества в стадии нетронутого
					quantityMaxP = 0.85;//Максимальный процент количества в стадии нетронутого
					hasPaper = true;//Будет ли бумажка при распаковке  true \ false
					break;
				case BoxTypes.AMMO556X45:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO556X45T:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO308WIN:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO308WINT:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO762X54:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO762X54T:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO762X39:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO762X39T:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO22:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO357:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO45ACP:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO9X19:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO380:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO00BUCK:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO12GASLUG:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO12GARUBBERSLUG:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO12GABEANBAG:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO545X39:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO545X39T:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO9X39AP:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO9X39:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				default:
					quantityMinBD = 1;
					quantityMaxBD = 1;
					quantityMinD = 1;
					quantityMaxD = 1;
					quantityMinW = 1;
					quantityMaxW = 1;
					quantityMinP = 1;
					quantityMaxP = 1;
					hasPaper = true;
					break;
			}
			
			string path = "CfgVehicles " + action_data.m_MainItem.GetType();
			string child_name = "";
			int count;
			array<string> resources = new array<string>;
			
			if( GetGame().ConfigIsExisting( path ) && GetGame().ConfigIsExisting( path + " Resources") )
			{
				path = path + " Resources";
				count = GetGame().ConfigGetChildrenCount ( path );
				for (int i = 0; i < count; i++)
				{
					GetGame().ConfigGetChildName ( path, i, child_name );
					
					if ( GetGame().ConfigGetInt( path + " " + child_name + " value" ) )
					{
						resources.Insert( child_name );
					}
				}

				string itemType = resources.Get(0);
				
				string itemPath = "CfgVehicles " + itemType;
				int quantityMax;
				int itemCount = GetGame().ConfigGetInt( path + " " + itemType + " value" );
				
				if (GetGame().ConfigIsExisting(itemPath + " varQuantityMax"))
				{
					quantityMax = GetGame().ConfigGetInt(itemPath + " varQuantityMax");
				}
				else
				{
					quantityMax = Math.Round(GetGame().ConfigGetFloat( CFG_MAGAZINESPATH + " " + itemType + " count" ));
				}
				
				int healthLevel = action_data.m_MainItem.GetHealthLevel();
				switch(healthLevel)
				{
					case GameConstants.STATE_BADLY_DAMAGED://Стадия сильно поврежденного
						itemCount = Math.Round(Math.RandomFloat(quantityMinBD,quantityMaxBD) * quantityMax);
						break;
					case GameConstants.STATE_DAMAGED://Стадия поврежденного
						itemCount = Math.Round(Math.RandomFloat(quantityMinD,quantityMaxD) * quantityMax);
						break;
					case GameConstants.STATE_WORN://Стадия поношенного
						itemCount = Math.Round(Math.RandomFloat(quantityMinW,quantityMaxW) * quantityMax);
						break;
					case GameConstants.STATE_PRISTINE://Стадия нетронуто
						itemCount = Math.Round(Math.RandomFloat(quantityMinP,quantityMaxP) * quantityMax);
						break;
				}
				
				UnboxLambda lambda = new UnboxLambda(action_data.m_MainItem, itemType, action_data.m_Player, itemCount);
				action_data.m_Player.ServerReplaceItemInHandsWithNew(lambda);
				
				//spawns wrapping Paper
				if (hasPaper)
					ItemBase paper = ItemBase.Cast( GetGame().CreateObjectEx("Paper", action_data.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE) );
				
				action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
			}
		}
	}
	
	int GetBoxType(string name)
	{
		int type = -1;
		if (name == "NailBox")
			type = BoxTypes.NAIL; // Тут тоже добавляем что и в ENUM
		else if (name == "AmmoBox_556x45_20Rnd")
			type = BoxTypes.AMMO556X45;
		else if (name == "AmmoBox_556x45Tracer_20Rnd")
			type = BoxTypes.AMMO556X45T;
		else if (name == "AmmoBox_308Win_20Rnd")
			type = BoxTypes.AMMO308WIN;
		else if (name == "AmmoBox_308WinTracer_20Rnd")
			type = BoxTypes.AMMO308WINT;
		else if (name == "AmmoBox_762x54_20Rnd")
			type = BoxTypes.AMMO762X54;
		else if (name == "AmmoBox_762x54Tracer_20Rnd")
			type = BoxTypes.AMMO762X54T;
		else if (name == "AmmoBox_762x39_20Rnd")
			type = BoxTypes.AMMO762X39;
		else if (name == "AmmoBox_762x39Tracer_20Rnd")
			type = BoxTypes.AMMO762X39T;
		else if (name == "AmmoBox_22_50Rnd")
			type = BoxTypes.AMMO22;
		else if (name == "AmmoBox_357_20Rnd")
			type = BoxTypes.AMMO357;
		else if (name == "AmmoBox_45ACP_25rnd")
			type = BoxTypes.AMMO45ACP;
		else if (name == "AmmoBox_9x19_25rnd")
			type = BoxTypes.AMMO9X19;
		else if (name == "AmmoBox_380_35rnd")
			type = BoxTypes.AMMO380;
		else if (name == "AmmoBox_00buck_10rnd")
			type = BoxTypes.AMMO00BUCK;
		else if (name == "AmmoBox_12gaSlug_10Rnd")
			type = BoxTypes.AMMO12GASLUG;
		else if (name == "AmmoBox_12gaRubberSlug_10Rnd")
			type = BoxTypes.AMMO12GARUBBERSLUG;
		else if (name == "AmmoBox_12gaBeanbag_10Rnd")
			type = BoxTypes.AMMO12GABEANBAG;
		else if (name == "AmmoBox_545x39_20Rnd")
			type = BoxTypes.AMMO545X39;
		else if (name == "AmmoBox_545x39Tracer_20Rnd")
			type = BoxTypes.AMMO545X39T;
		else if (name == "AmmoBox_9x39AP_20Rnd")
			type = BoxTypes.AMMO9X39AP;
		else if (name == "AmmoBox_9x39_20Rnd")
			type = BoxTypes.AMMO9X39;
		return type;
	}
};

Обновил скрипт 28.02.2021.
- Теперь можно добавить каждый тип коробок отдельно( задать ему минимальное \ максимальное кол-во патронов от состояния коробки).
- Теперь можно запретить или добавить выпадения бумажки при распаковке той или иной пачки.
- Возможно добавление моддовских пачек патронов и их регулирования количества.

Edited by thessend
update (see edit history)

Share this post


Link to post
Share on other sites



25.02.2021 в 20:11, thessend сказал:

P.s на выходных будет чуть доделан, и добавлен по класснеймам( разные патроны, или гвозди).

в идеале бы еще json реализовать, но всё таки я думаю в скрипте от еква больше функционал.

Share this post


Link to post
Share on other sites
8 часов назад, DOPHAMINE сказал:

в идеале бы еще json реализовать, но всё таки я думаю в скрипте от еква больше функционал.

Юзай его, только этот бесплатный)

Share this post


Link to post
Share on other sites

Будет без конфига, но с возможностью выбирать у каждого патрона или гвоздей то или иное кол-во
А те кто хоть немного шарят без проблем смогут поменять на свое усмотрение

Share this post


Link to post
Share on other sites

Обновил скрипт 28.02.2021.
- Теперь можно добавить каждый тип коробок отдельно( задать ему минимальное \ максимальное кол-во патронов от состояния коробки).
- Теперь можно запретить или добавить выпадения бумажки при распаковке той или иной пачки.
- Возможно добавление моддовских пачек патронов и их регулирования количества.

========

Конфиг на мой взгляд для данного скрипта смысла делать вообще нету, потому что все параметры добавляются \ меняются \ удаляются через один файл + мод является СЕРВЕРНЫМ
 

enum BoxTypes
{
	NAIL, // Перечислены коробки которые мы хотим сделать рандомное выпадения
	AMMO556X45,
	AMMO556X45T,
	AMMO308WIN,
	AMMO308WINT,
	AMMO762X54,
	AMMO762X54T,
	AMMO762X39,
	AMMO762X39T,
	AMMO22,
	AMMO357,
	AMMO45ACP,
	AMMO9X19,
	AMMO380,
	AMMO00BUCK,
	AMMO12GASLUG,
	AMMO12GARUBBERSLUG,
	AMMO12GABEANBAG,
	AMMO545X39,
	AMMO545X39T,
	AMMO9X39AP,
	AMMO9X39
}

modded class ActionUnpackBox: ActionContinuousBase
{	
	override void OnFinishProgressServer( ActionData action_data )
	{
		if ( action_data.m_MainItem && action_data.m_MainItem.GetHierarchyRootPlayer() == action_data.m_Player )
		{
			int boxType = GetBoxType(action_data.m_MainItem.GetType());
			float quantityMinBD;
			float quantityMaxBD;
			float quantityMinD;
			float quantityMaxD;
			float quantityMinW;
			float quantityMaxW;
			float quantityMinP;
			float quantityMaxP;
			bool hasPaper;
			
			switch(boxType)
			{
				case BoxTypes.NAIL: // Добавляем тут тип тот же что и в ENUM
					quantityMinBD = 0.10;//Минимальный процент количества в стадии сильно поврежденного
					quantityMaxBD = 0.15;//Максимальный процент количества в стадии сильно поврежденного
					quantityMinD = 0.20;//Минимальный процент количества в стадии поврежденного
					quantityMaxD = 0.30;//Максимальный процент количества в стадии поврежденного
					quantityMinW = 0.30;//Минимальный процент количества в стадии поношенного
					quantityMaxW = 0.65;//Максимальный процент количества в стадии поношенного
					quantityMinP = 0.70;//Минимальный процент количества в стадии нетронутого
					quantityMaxP = 0.85;//Максимальный процент количества в стадии нетронутого
					hasPaper = true;//Будет ли бумажка при распаковке  true \ false
					break;
				case BoxTypes.AMMO556X45:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO556X45T:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO308WIN:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO308WINT:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO762X54:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO762X54T:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO762X39:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO762X39T:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO22:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO357:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO45ACP:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO9X19:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO380:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO00BUCK:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO12GASLUG:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO12GARUBBERSLUG:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO12GABEANBAG:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO545X39:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO545X39T:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO9X39AP:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				case BoxTypes.AMMO9X39:
					quantityMinBD = 0.10;
					quantityMaxBD = 0.15;
					quantityMinD = 0.20;
					quantityMaxD = 0.30;
					quantityMinW = 0.30;
					quantityMaxW = 0.65;
					quantityMinP = 0.70;
					quantityMaxP = 0.85;
					hasPaper = true;
					break;
				default:
					quantityMinBD = 1;
					quantityMaxBD = 1;
					quantityMinD = 1;
					quantityMaxD = 1;
					quantityMinW = 1;
					quantityMaxW = 1;
					quantityMinP = 1;
					quantityMaxP = 1;
					hasPaper = true;
					break;
			}
			
			string path = "CfgVehicles " + action_data.m_MainItem.GetType();
			string child_name = "";
			int count;
			array<string> resources = new array<string>;
			
			if( GetGame().ConfigIsExisting( path ) && GetGame().ConfigIsExisting( path + " Resources") )
			{
				path = path + " Resources";
				count = GetGame().ConfigGetChildrenCount ( path );
				for (int i = 0; i < count; i++)
				{
					GetGame().ConfigGetChildName ( path, i, child_name );
					
					if ( GetGame().ConfigGetInt( path + " " + child_name + " value" ) )
					{
						resources.Insert( child_name );
					}
				}

				string itemType = resources.Get(0);
				
				string itemPath = "CfgVehicles " + itemType;
				int quantityMax;
				int itemCount = GetGame().ConfigGetInt( path + " " + itemType + " value" );
				
				if (GetGame().ConfigIsExisting(itemPath + " varQuantityMax"))
				{
					quantityMax = GetGame().ConfigGetInt(itemPath + " varQuantityMax");
				}
				else
				{
					quantityMax = Math.Round(GetGame().ConfigGetFloat( CFG_MAGAZINESPATH + " " + itemType + " count" ));
				}
				
				int healthLevel = action_data.m_MainItem.GetHealthLevel();
				switch(healthLevel)
				{
					case GameConstants.STATE_BADLY_DAMAGED://Стадия сильно поврежденного
						itemCount = Math.Round(Math.RandomFloat(quantityMinBD,quantityMaxBD) * quantityMax);
						break;
					case GameConstants.STATE_DAMAGED://Стадия поврежденного
						itemCount = Math.Round(Math.RandomFloat(quantityMinD,quantityMaxD) * quantityMax);
						break;
					case GameConstants.STATE_WORN://Стадия поношенного
						itemCount = Math.Round(Math.RandomFloat(quantityMinW,quantityMaxW) * quantityMax);
						break;
					case GameConstants.STATE_PRISTINE://Стадия нетронуто
						itemCount = Math.Round(Math.RandomFloat(quantityMinP,quantityMaxP) * quantityMax);
						break;
				}
				
				UnboxLambda lambda = new UnboxLambda(action_data.m_MainItem, itemType, action_data.m_Player, itemCount);
				action_data.m_Player.ServerReplaceItemInHandsWithNew(lambda);
				
				//spawns wrapping Paper
				if (hasPaper)
					ItemBase paper = ItemBase.Cast( GetGame().CreateObjectEx("Paper", action_data.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE) );
				
				action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
			}
		}
	}
	
	int GetBoxType(string name)
	{
		int type = -1;
		if (name == "NailBox")
			type = BoxTypes.NAIL; // Тут тоже добавляем что и в ENUM
		else if (name == "AmmoBox_556x45_20Rnd")
			type = BoxTypes.AMMO556X45;
		else if (name == "AmmoBox_556x45Tracer_20Rnd")
			type = BoxTypes.AMMO556X45T;
		else if (name == "AmmoBox_308Win_20Rnd")
			type = BoxTypes.AMMO308WIN;
		else if (name == "AmmoBox_308WinTracer_20Rnd")
			type = BoxTypes.AMMO308WINT;
		else if (name == "AmmoBox_762x54_20Rnd")
			type = BoxTypes.AMMO762X54;
		else if (name == "AmmoBox_762x54Tracer_20Rnd")
			type = BoxTypes.AMMO762X54T;
		else if (name == "AmmoBox_762x39_20Rnd")
			type = BoxTypes.AMMO762X39;
		else if (name == "AmmoBox_762x39Tracer_20Rnd")
			type = BoxTypes.AMMO762X39T;
		else if (name == "AmmoBox_22_50Rnd")
			type = BoxTypes.AMMO22;
		else if (name == "AmmoBox_357_20Rnd")
			type = BoxTypes.AMMO357;
		else if (name == "AmmoBox_45ACP_25rnd")
			type = BoxTypes.AMMO45ACP;
		else if (name == "AmmoBox_9x19_25rnd")
			type = BoxTypes.AMMO9X19;
		else if (name == "AmmoBox_380_35rnd")
			type = BoxTypes.AMMO380;
		else if (name == "AmmoBox_00buck_10rnd")
			type = BoxTypes.AMMO00BUCK;
		else if (name == "AmmoBox_12gaSlug_10Rnd")
			type = BoxTypes.AMMO12GASLUG;
		else if (name == "AmmoBox_12gaRubberSlug_10Rnd")
			type = BoxTypes.AMMO12GARUBBERSLUG;
		else if (name == "AmmoBox_12gaBeanbag_10Rnd")
			type = BoxTypes.AMMO12GABEANBAG;
		else if (name == "AmmoBox_545x39_20Rnd")
			type = BoxTypes.AMMO545X39;
		else if (name == "AmmoBox_545x39Tracer_20Rnd")
			type = BoxTypes.AMMO545X39T;
		else if (name == "AmmoBox_9x39AP_20Rnd")
			type = BoxTypes.AMMO9X39AP;
		else if (name == "AmmoBox_9x39_20Rnd")
			type = BoxTypes.AMMO9X39;
		return type;
	}
};

 

Share this post


Link to post
Share on other sites
17 часов назад, DOPHAMINE сказал:

в идеале бы еще json реализовать, но всё таки я думаю в скрипте от еква больше функционал.

Теперь не превосходит,  а даже проигрывает на мой взгляд)

Share this post


Link to post
Share on other sites

Если прошлый можно было понять куда и что,то.....что с этим скриптом то делать то? Вместо чего,куда...

Share this post


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

Если прошлый можно было понять куда и что,то.....что с этим скриптом то делать то? Вместо чего,куда...

Если немного подумать и посмотреть..🤦‍♂️То можно понять, что это все тот же скрипт, но немного обновленный.
Очевидно туда же, где был и прошлый.

Share this post


Link to post
Share on other sites

Патроны после распаковки всегда "нетронутые"?....

 

Share this post


Link to post
Share on other sites
19 минут назад, paranoyk сказал:

Патроны после распаковки всегда "нетронутые"?....

 

Да.

Share this post


Link to post
Share on other sites
26 минут назад, thessend сказал:

Да.

"А можно вот такой же,но с перламутровыми пуговицами?"

 

Share this post


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

"А можно вот такой же,но с перламутровыми пуговицами?"

 

Добавлю в следующей обнове

Share this post


Link to post
Share on other sites

как его инициализировать?

Share this post


Link to post
Share on other sites

Уважаемый автор thessend! А как установить сие чудо?

 

Добавил скрипт в файл .cpp на сервер в отдельной папке, запаковал в .pbo, подключил в батнике и не работает.

PS: я начинающий, сильно не ругайте)

Edited by OrganicMax (see edit history)

Share this post


Link to post
Share on other sites
28.12.2022 в 22:04, OrganicMax сказал:

Уважаемый автор thessend! А как установить сие чудо?

 

Добавил скрипт в файл .cpp на сервер в отдельной папке, запаковал в .pbo, подключил в батнике и не работает.

PS: я начинающий, сильно не ругайте)

Гайд по созданию серверного мода есть на форуме. А скрипт нужно не в плюсы совать) Это в разрешении .c

Share this post


Link to post
Share on other sites

нужно сделать файл .c тогда будет работать и положить его в 4 world

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.