Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
casingleusequantity.c
Go to the documentation of this file.
2 {
3  protected float m_QuantityUsedPerAction;
4  protected float m_ItemQuantity;
5  protected ref Param1<float> m_SpentUnits;
6 
7  void CASingleUseQuantity( float quantity_used_per_action )
8  {
9  m_QuantityUsedPerAction = quantity_used_per_action;
10  }
11 
12  override void Setup( ActionData action_data )
13  {
14  if ( !m_SpentUnits )
15  {
16  m_SpentUnits = new Param1<float>(0);
17  }
18  else
19  {
20  m_SpentUnits.param1 = 0;
21  }
22  m_ItemQuantity = action_data.m_MainItem.GetQuantity();
23  }
24 
25  override int Execute( ActionData action_data )
26  {
27  if ( !action_data.m_Player )
28  {
29  return UA_ERROR;
30  }
31 
32 
33  CalcAndSetQuantity( action_data );
34  return UA_FINISHED;
35  }
36 
37  //---------------------------------------------------------------------------
38 
39  void CalcAndSetQuantity( ActionData action_data )
40  {
41  if ( GetGame().IsServer() )
42  {
43  if ( m_SpentUnits )
44  {
45  m_SpentUnits.param1 = m_QuantityUsedPerAction;
46  SetACData(m_SpentUnits);
47  }
48 
49  action_data.m_MainItem.AddQuantity(- m_QuantityUsedPerAction,false,false);
50  }
51  }
52 };
GetGame
proto native CGame GetGame()
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
CASingleUseQuantity
Definition: casingleusequantity.c:1
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionData
Definition: actionbase.c:20
CASingleUseBase
Definition: casingleusebase.c:1