How to set stacked item count
5 replies



30.04.21 01:46:40 pm
Hello, how can one approach setting a stacked item's amount in a player's inventory?
For example, player A has 2 Flashbangs, and I want them to only have one, how can I change it to 1?
setammo does not work.
Currently the best approach I found was using
spawnitem and
setpos, but that's less reliable than I'd prefer due to it depending on a 0 millisecond timer.
Thank you.
For example, player A has 2 Flashbangs, and I want them to only have one, how can I change it to 1?

Currently the best approach I found was using


Thank you.
Look at me standing, here on my own again
05.05.21 03:13:07 pm
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
addhook("walkover", "walkover")
function walkover(pid, iid, type, ain, a, mode)
if(type == 52) then--flashbang
local wpns = playerweapons(pid)
for _, wpntype in pairs(wpns) do
if(wpntype == 52) then
return 1--don't collect
end
end
end
return 0
end
function walkover(pid, iid, type, ain, a, mode)
if(type == 52) then--flashbang
local wpns = playerweapons(pid)
for _, wpntype in pairs(wpns) do
if(wpntype == 52) then
return 1--don't collect
end
end
end
return 0
end
Is it what you want?
@
ttoni:

Code:
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
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
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
flsh=initArray(32)
addhook("drop","drop")
function drop(id,wpn)
if flsh[id]==1 then
flsh[id]=0
end
end
addhook("collect","clct")
function clct(id,wpn)
if wpn==52 then
if flsh[id]==0 then
flsh[id]=1
end
end
end
addhook("attack","att")
function att(id,wpn)
if wpn==52 then
if flsh[id]==1 then
flsh[id]=0
end
end
end
addhook("walkover","wlk")
function wlk(id,wpn)
if wpn==52 then
if flsh[id]==1 then
flsh[id]=0
return 1
end
end
end
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
flsh=initArray(32)
addhook("drop","drop")
function drop(id,wpn)
if flsh[id]==1 then
flsh[id]=0
end
end
addhook("collect","clct")
function clct(id,wpn)
if wpn==52 then
if flsh[id]==0 then
flsh[id]=1
end
end
end
addhook("attack","att")
function att(id,wpn)
if wpn==52 then
if flsh[id]==1 then
flsh[id]=0
end
end
end
addhook("walkover","wlk")
function wlk(id,wpn)
if wpn==52 then
if flsh[id]==1 then
flsh[id]=0
return 1
end
end
end



