summaryrefslogtreecommitdiff
path: root/gamemode/cl_inventory.lua
blob: 33bad6b4859f4c75a78a9fa920dfe3ffdbbe9060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
LocalInventory = {}
LocalStash = {}
LocalStashCash = 0
PreviewStyle = "Stash"
PreviewPriceScale = 1

function Inv_HasItem( id )

	for k,v in pairs( LocalInventory ) do

		local tbl = item.GetByID( v )

		if ( type( id ) == "number" and tbl.ID == id ) or ( type( id ) == "string" and tbl.Model == id ) then

			return tbl

		end

	end

end

function Inv_ItemCount( id )

	local count = 0

	for k,v in pairs( LocalInventory ) do

		if v == id then

			count = count + 1

		end

	end

	return count

end

function Inv_Get( pos )

	return LocalInventory[ pos ]

end

function Inv_UniqueItems()

	local ids = {}

	for k,v in pairs( LocalInventory ) do

		if not table.HasValue( ids, v ) then

			table.insert( ids, v )

		end

	end

	return ids

end

function Inv_Size()

	return #LocalInventory

end

function Inv_GetStashCash()

	return LocalStashCash

end

function Inv_SetStashCash( amt )

	LocalStashCash = amt

end