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
Verum

Кулинария

Ребят, есть сей код...
 

class ActionCookOnFryingPanCB : ActionContinuousBaseCB
{
	override void CreateActionComponent()
	{
		m_ActionData.m_ActionComponent = new CAContinuousTime( 30 );
	}
};

class ActionCookOnFryingPan: ActionContinuousBase
{
	void ActionCookOnFryingPan()
	{
		m_CallbackClass = ActionCookOnFryingPanCB;
		m_CommandUID = DayZPlayerConstants.CMD_GESTUREFB_CAMPFIRE;
		m_FullBody = true;
		m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
		m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
		
		m_LockTargetOnUse = false;
	}
	
	override void CreateConditionComponents()  
	{	
		m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
		m_ConditionItem = new CCINonRuined;
	}
		
	override string GetText()
	{
		return "Пожарить на сковородке";
	}

	override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
	{	
		FireplaceBase fireplace_target = FireplaceBase.Cast( target.GetObject() );
		Object targetObject = target.GetObject();
		Edible_Base item_on_cargo = Edible_Base.Cast( item.GetItemTypeFromCargo( Edible_Base ) );
		if ( fireplace_target && item_on_cargo && item_on_cargo.CanBeCookedOnStick() )
		{
			BarrelHoles_ColorBase barrel = BarrelHoles_ColorBase.Cast( fireplace_target );
			
			//barrel with holes
			if ( barrel )
			{
				if ( barrel.IsOpen() && fireplace_target.CanCookOnStick() )
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			
			//fireplace
			if ( fireplace_target.IsBaseFireplace() )
			{
				Fireplace fireplace = Fireplace.Cast( fireplace_target );
				if ( !fireplace.IsOven() && fireplace_target.CanCookOnStick() ) 
				{
					return true;
				}
			}
			
			//fireplace indoor
			if ( fireplace_target.IsFireplaceIndoor() )
			{
				if ( fireplace_target.CanCookOnStick() ) 
				{
					return true;
				}	
			}			
		}		
		return false;
	}
};

Попытка привязать к сковородке экшн - Пожарить.. По аналогии с жиркой на палке.. Выдаётся ошибка... Undefined function "GetItemTypeFromCargo"
Если заменить две строчки :
 

		Edible_Base item_on_cargo = Edible_Base.Cast( item.GetItemTypeFromCargo( Edible_Base ) );
		if ( fireplace_target && item_on_cargo && item_on_cargo.CanBeCookedOnStick() )

на
 

		Edible_Base item_on_stick = Edible_Base.Cast( item.GetAttachmentByType( Edible_Base ) );
		if ( fireplace_target && item_on_stick && item_on_stick.CanBeCookedOnStick() )

то сервер запускается, экшн проходит... но мясо не жарится..
Подскажет кто решение? Думаю данный момент и другим будет интересен к использованию.

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

В классе ItemBase (тип переменной item, с которой вызывается ваша функция) есть фуцнкция вида:

protected ItemBase GetItemTypeFromCargo( typename item_type, ItemBase cooking_equipment )
	{
		CargoBase cargo = cooking_equipment.GetInventory().GetCargo();
		
		for ( int i = 0; i < cargo.GetItemCount(); i++ )
		{
			EntityAI entity = cargo.GetItem( i );
			if ( entity.Type() == item_type )
			{
				ItemBase item = ItemBase.Cast( entity );

				return item;
			}
		}
		
		return NULL;
	}

с модификатором типа protected, что, как я понимаю (я не эксперт), означает, что эта функция не доступна к внешнему вызову вне этого класса. Также, насколько я вижу, у ункции 2 входнх значения, а не одно.

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

Share this post


Link to post
Share on other sites



  • 0
23.06.2021 в 18:00, 123new сказал:

В классе ItemBase (тип переменной item, с которой вызывается ваша функция) есть фуцнкция вида:

protected ItemBase GetItemTypeFromCargo( typename item_type, ItemBase cooking_equipment ) { CargoBase cargo = cooking_equipment.GetInventory().GetCargo(); for ( int i = 0; i < cargo.GetItemCount(); i++ ) { EntityAI entity = cargo.GetItem( i ); if ( entity.Type() == item_type ) { ItemBase item = ItemBase.Cast( entity ); return item; } } return NULL; }


protected ItemBase GetItemTypeFromCargo( typename item_type, ItemBase cooking_equipment )
	{
		CargoBase cargo = cooking_equipment.GetInventory().GetCargo();
		
		for ( int i = 0; i < cargo.GetItemCount(); i++ )
		{
			EntityAI entity = cargo.GetItem( i );
			if ( entity.Type() == item_type )
			{
				ItemBase item = ItemBase.Cast( entity );

				return item;
			}
		}
		
		return NULL;
	}

с модификатором типа protected, что, как я понимаю (я не эксперт), означает, что эта функция не доступна к внешнему вызову вне этого класса. Также, насколько я вижу, у ункции 2 входнх значения, а не одно.

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

 

Достаточно отмоддидь класс ItemBase и сделать так

 

override void GetItemTypeFromCargo (блаблабла)
{
   super.GetItemTypeFromCargo(блаблабла);
}

 

И эта функция становится доступна из-за пределов класса

 

 

Edited by BorizzK (see edit history)

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.