Forum

> > CS2D > Scripts > Show carried weapons
Forums overviewCS2D overview Scripts overviewLog in to reply

English Show carried weapons

7 replies
To the start Previous 1 Next To the start

old Show carried weapons

Alistaire
User Off Offline

Quote
Is there a command / way to return the weapon (id's) a player carries?

I need it for;

1
2
3
4
if player(id, "weapontype") == 49 then
	parse('strip '..id..' 49')
	msg2(id, "Your Grenadelauncher is stripped hahaha trololol etc etc")
end

It only works when the player has the weapon EQUIPPED, but I want it to strip the weapon whenever he carries it.

I can't just remove player(id,"weapontype") so that everyone gets the message..

old Re: Show carried weapons

TimeQuesT
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
test = playerweapons(id);

for i=1,#test do

if (test[i]==49) then
parse ("execute commands here!");
break;
end

end

should work.

old Re: Show carried weapons

Flacko
User Off Offline

Quote
user Alistaire has written
if playerweapons(id) == 49 then?

1
2
3
4
5
6
7
8
9
10
11
12
function table.find(t,v)
	for _k,_v in pairs(t) do
		if _v == v then
			return _k
		end
	end
end

--
if table.find(playerweapons(id),49) then
	parse("strip "..id.." 49")
end

edit: whops, 2 minutes too late.

old Re: Show carried weapons

Alistaire
User Off Offline

Quote
Thanks!

----

user Flacko has written
user Alistaire has written
if playerweapons(id) == 49 then?

1
2
3
4
5
6
7
8
9
10
11
12
function table.find(t,v)
	for _k,_v in pairs(t) do
		if _v == v then
			return _k
		end
	end
end

--
if table.find(playerweapons(id),49) then
	parse("strip "..id.." 49")
end

edit: whops, 2 minutes too late.


Works better for me, I'll need the function multiple times in the script so yea.

old Re: Show carried weapons

MikuAuahDark
User Off Offline

Quote
it's better if like this. small line and very simple:
1
2
3
4
5
6
7
8
stripped={49}	-- add weaponid here, separated by comma

addhook("walkover","troll")
function troll(id,iid,type)
	if type==stripped then
		return 1
	end
end
or this code
1
2
3
4
5
6
7
8
9
10
11
12
13
stripped={49}	-- add weaponid here, separated by comma

addhook("second","lolol")
function lolol()
	for _, id in ipairs(player(0,"table")) do
		for num, val in ipairs(stripped) do
			if player(id,"weapontype")==val then
				parse("strip "..id.." "..val)
				msg2(id, "Your "..itemtype(val,"name").." is stripped hahaha trololol etc etc")
			end
		end
	end
end
just choice what you want
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview