Forum
CS2D Scripts Listing player itemsListing player items
9 replies 1
This can't be the only way!
http://www.cs2d.com/help.php?luacat=player&luacmd=player#cmd
however, there is no table for ALL current held weapons. One thing you could do is to monitor the history of the weapons.
Example
spawn - he has glock/usp
walkover - check weapon, add ID if picked up
etc.
but for right now there seems to be no way to runaround this.
There is a function playerweapons(id) but it returns a table of weapon types not item ids. I don't know why it isn't listed in the help page. Thanks for your suggestion but I can't use any hooks in my script.
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
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
function playeritems(id) 	local t = {} 	if player(id,"exists") and player(id,"health") > 0 then 		for _, w in ipairs(playerweapons(id)) do 			table.insert(t,w) 		end 		if player(id,"defusekit") then 			table.insert(t,56) 		end 		if player(id,"nightvision") then 			table.insert(t,59) 		end 		if player(id,"gasmask") then 			table.insert(t,60) 		end 		if player(id,"armor") >= 1 and player(id,"armor") <= 65 then 			table.insert(t,57) 		end 		if player(id,"armor") >= 66 and player(id,"armor") <= 200 then 			table.insert(t,58) 		end 		if player(id,"armor") > 200 then 			local s = player(id,"armor") - 200 			local r = 78 + s 			table.insert(t,r) 		end 	end 	return t end
Cure Pikachu has written
I guess this would be it. This one checks for all weapons (including bombs & flags), defuse kits, nightvision googles, gas masks and armors on a living person.
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
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
function playeritems(id) 	local t = {} 	if player(id,"exists") and player(id,"health") > 0 then 		for _, w in ipairs(playerweapons(id)) do 			table.insert(t,w) 		end 		if player(id,"defusekit") then 			table.insert(t,56) 		end 		if player(id,"nightvision") then 			table.insert(t,59) 		end 		if player(id,"gasmask") then 			table.insert(t,60) 		end 		if player(id,"armor") >= 1 and player(id,"armor") <= 65 then 			table.insert(t,57) 		end 		if player(id,"armor") >= 66 and player(id,"armor") <= 200 then 			table.insert(t,58) 		end 		if player(id,"armor") > 200 then 			local s = player(id,"armor") - 200 			local r = 78 + s 			table.insert(t,r) 		end 	end 	return t end
In a way irrelevant, since Livia specifies that he needs item IDs, not item types.
I guess this code would do what you need, Livia:
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
function playeritems(id) --Sorry Pikachu 	local t={} 	for i=0,512 do --Just to be on the safe side, could be less 		if item(i,"exists") then 			if item(i,"player")==id then 				t[#t+1]=i 			end 		end 	end 	return 1 end
It should work.
Admin/mod comment
Read the topic. 'it returns a table of weapon types not item ids'. /EngiIt's quite heavy so I'll probably live without it.
Infinite Rain:
ID is the item's indentifier where Type tells you what kind of item it is. I bet you know the difference between player's id and type (is he bot or not).
edited 1×, last 06.10.12 07:29:57 pm
1