VIP Pick weapons
5 replies



12.03.23 11:53:57 am
Is it possible to make the main VIP that is in ct group able to pick weapons? i was wondering if that is even possible or someone could make a script about it
Bad Life
Possible through scripting but is quite tedious to make.
I could make a script for that later today if nobody snipes me to it.
I could make a script for that later today if nobody snipes me to it.
It's hard being the best girl in the whole entire world
I'm not sure if
walkover fires when a VIPs walk over items he can't collect.
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.

If it does you could simply use that in combination with



If it doesn't you would have to use


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

@
NanuPlayer: You can also use as skin the image of the VIP and that appears the skin of the VIP in any player of the anti-terrorist team (random) From that code you add a line that allows only to pick up the weapon or any other adjustment, ej: Surely the VIP will be used in an escape or coperacion game mode, at the beginning of the round you give this player who is using the vip image position x and the y position on the tiles of the map, Doing it this way also solves the problem that when the VIP dies the round ends.

edited 2×, last 12.03.23 09:40:19 pm
I tried making it, it wasn't hard to get to this point but this is far from complete.
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:
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
I gave up the moment I realised that the command


I didn't want to finish this with that dead-end in mind.
For whoever wants to pick up from where I left off:
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
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()
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:




It's hard being the best girl in the whole entire world
@
Mami Tomoe: Thanks! it is ok if it can't pick stacked items as long as someone finally said that the script is possible to be made


Bad Life



