Forum
CS2D Scripts VIP Pick weaponsVIP Pick weapons
5 replies 1
I could make a script for that later today if nobody snipes me to it.
If it does you could simply use that in combination with equip, setammo and removeitem.
If it doesn't you would have to use movetile and item to first retrieve a list of all items and then details about the item(s) on the specified tile. Then you could use the same commands as mentioned above to "collect" the item(s) (equip same item type, set ammo and remove from map).
In both cases you would also have to check first if the item can be collected (e.g. allow only 1 primary and 1 secondary weapon etc). You can check what the player already carries with playerweapons.
edited 2×, last 12.03.23 09:40:19 pm
I gave up the moment I realised that the command removeitem did not trigger items to respawn from the env_item entity, which as far as I'm concerned, cannot be fixed by Lua.
I didn't want to finish this with that dead-end in mind.
For whoever wants to pick up from where I left off:
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
83
84
85
86
87
88
89
90
91
92
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
83
84
85
86
87
88
89
90
91
92
local rules = { 	maxPrimaryItems		= 1, 	maxSecondaryItems	= 1 } -- Items CS2D allows the V.I.P. to pick-up. local whitelistedItems = { 	[01] = true, -- USP 	[57] = true, -- Kevlar 	[58] = true, -- Kevlar+Helm 	[59] = true, -- Night Vision 	[60] = true, -- Gas Mask 	[62] = true, -- Secondary Ammo 	[64] = true, -- Medikit 	[65] = true, -- Bandage 	[66] = true, -- Coins 	[67] = true, -- Money 	[68] = true, -- Gold 	[70] = true, -- Red Flag 	[79] = true, -- Light Armour 	[80] = true, -- Armour 	[81] = true, -- Heavy Armour 	[82] = true, -- Medic Armour 	[83] = true, -- Super Armour 	[84] = true -- Stealth Suit } -- Items CS2D does not allow the V.I.P. to pick-up. -- I never got to using this part, and I'm unsure on -- whether this is even needed. local blockedItems = { } -- Items that the V.I.P. should not pick-up. local ignoredItems = { 	[55] = true, -- Bomb 	[63] = true, -- Planted Bomb 	[71] = true -- Blue Flag } local function getHeldCount(p, slot) 	local pWpns = playerweapons(p) 	local count = 0 	for _, itemTypeId in pairs(pWpns) do 		if itemtype(itemTypeId, 'slot') == slot then 			count = count + 1 		end 	end 	return count end function walkover_hook(p, itemId, itemTypeId, ammoIn, ammo, mode) 	if player(p, 'team') ~= 3 then 		-- Not a V.I.P. 		return 	elseif whitelistedItems[itemTypeId] then 		return 	elseif ignoredItems[itemTypeId] then 		return 	end 	local slot = itemtype(itemTypeId, 'slot') 	if slot == 1 then 		if getHeldCount(p, 1) >= rules.maxPrimaryItems then 			return 		end 	elseif slot == 2 then 		if getHeldCount(p, 2) >= rules.maxSecondaryItems then 			return 		end 	end 	parse('sv_soundpos "items/pickup.wav" ' .. item(itemId, 'x') .. ' ' .. item(itemId, 'y')) 	parse('removeitem "' .. itemId .. '"') 	parse('equip "' .. p .. '" "' .. itemTypeId .. '"') 	parse('setammo "' .. p .. '" "' .. itemTypeId .. '" "' .. ammoIn .. '" "' .. ammo .. '"') end local function init() 	-- Hooks. 	addhook('walkover',		'walkover_hook',	 0) end init()
Problems:
Cannot properly pick up items that stack (like grenades)
The above stated issue with env_item
Possibly more that I never got to find
1