Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
splititemutils.c
Go to the documentation of this file.
2{
3 static void TakeOrSplitToInventory ( notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
4 {
5 ItemBase item_base = ItemBase.Cast( item );
6
7 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
8 return;
9
11 if( target.GetInventory().FindFreeLocationFor( item, FindInventoryLocationType.ANY, il) )
12 {
13 if( item_base.GetTargetQuantityMax(il.GetSlot()) >= item_base.GetQuantity() )
14 {
15 if( il.GetType() == InventoryLocationType.ATTACHMENT )
16 {
17 player.PredictiveTakeEntityToTargetAttachmentEx(il.GetParent(), item, il.GetSlot());
18 }
19 else
20 {
22 if (item.GetInventory().GetCurrentInventoryLocation(src))
23 player.PredictiveTakeToDst(src, il);
24
25 }
26 }
27 else
28 {
29 item_base.SplitIntoStackMaxClient( il.GetParent(), il.GetSlot() );
30 }
31 }
32 }
33
34 static void TakeOrSplitToInventoryLocation ( notnull PlayerBase player, notnull InventoryLocation dst)
35 {
36 ItemBase item_base = ItemBase.Cast( dst.GetItem() );
37 int slot = dst.GetSlot();
38
39 if( !dst.GetItem().GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
40 return;
41
42 float stack_max = item_base.GetTargetQuantityMax(slot);
43
44 if( stack_max >= item_base.GetQuantity() )
45 {
47 if (dst.GetItem().GetInventory().GetCurrentInventoryLocation(src))
48 {
49 player.PredictiveTakeToDst(src, dst);
50 }
51 else
52 Error("TakeIntoCargoEx cannot get src for dst=" + dst.DumpToString());
53 }
54 else
55 {
56 item_base.SplitIntoStackMaxToInventoryLocationClient( dst );
57 }
58 }
59}
InventoryLocation.
proto native int GetSlot()
returns slot id if current type is Attachment
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetType()
returns type of InventoryLocation
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location