English How to set stacked item count

5 replies
Goto Page
To the start Previous 1 Next To the start
30.04.21 01:46:40 pm
Up
Mami Tomoe
User
Offline Off
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?

cs2d cmd setammo does not work.

Currently the best approach I found was using cs2d cmd spawnitem and cs2d cmd setpos, but that's less reliable than I'd prefer due to it depending on a 0 millisecond timer.

Thank you.
fish
30.04.21 02:26:09 pm
Up
Masea
Super User
Online On
There's no way
02.05.21 04:52:38 pm
Up
DX
User
Offline Off
×
05.05.21 03:13:07 pm
Up
ttoni
User
Offline Off
Code:
1
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


Is it what you want?
07.05.21 12:04:33 am
Up
DX
User
Offline Off
@user 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
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
07.05.21 12:59:57 am
Up
Mami Tomoe
User
Offline Off
It's okay, I decided to use teleporting instead.
fish
To the start Previous 1 Next To the start