Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
splititemutils.c
Go to the documentation of this file.
1
class
SplitItemUtils
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
10
InventoryLocation
il =
new
InventoryLocation
;
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
{
21
InventoryLocation
src =
new
InventoryLocation
;
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
{
46
InventoryLocation
src =
new
InventoryLocation
;
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
}
EntityAI
Definition
inventoryitem.c:2
InventoryLocation
InventoryLocation.
Definition
inventorylocation.c:30
InventoryLocation::GetSlot
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation::GetParent
proto native EntityAI GetParent()
returns parent of current inventory location
InventoryLocation::GetType
proto native int GetType()
returns type of InventoryLocation
ItemBase
Definition
inventoryitem.c:742
PlayerBase
Definition
playerbaseclient.c:2
SplitItemUtils
Definition
splititemutils.c:2
SplitItemUtils::TakeOrSplitToInventory
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
Definition
splititemutils.c:3
SplitItemUtils::TakeOrSplitToInventoryLocation
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
Definition
splititemutils.c:34
Error
void Error(string err)
Messagebox with error message.
Definition
endebug.c:90
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition
inventorylocation.c:18
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition
inventorylocation.c:4
Games
Dayz
scripts
5_mission
gui
inventorynew
splititemutils.c
Generated by
1.17.0