Forum

> > CS2D > Scripts > LUA: Strip Knife
Forums overviewCS2D overview Scripts overviewLog in to reply

English LUA: Strip Knife

6 replies
To the start Previous 1 Next To the start

old LUA: Strip Knife

inzec
User Off Offline

Quote
Hey people.

I'm new to LUA, just starting out, so yeah I suck.

How would you script a command where you type "@knife" and then all players weapons are stripped so they only have knife?

Thanks.

EDIT*

here is my fail attempt.
1
2
3
4
5
6
addhook("say","strip")
function strip(id)
     if(txt=="@knife") then
          parse("strip "..id.."")
                   end
     end

old Re: LUA: Strip Knife

MikuAuahDark
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook("say","nooo")
function nooo(id,txt)
	if txt=="@knife" then
		weaponlist = playerweapons(id)	-- i hope im right
		for num, val in pairs(weaponlist) do
			if val~=50 then
				parse("strip "..id.." "..val)
			end
		end
	end
end

old Re: LUA: Strip Knife

Apache uwu
User Off Offline

Quote
you type "@knife" and then all players weapons are stripped

1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("say","_say")

function _say(id,message)
	if message=="@knife" then
		for _,id2 in pairs(player(0,"tableliving")) do
			for _,wpn in pairs(playerweapons(id2)) do
				parse("strip "..id2.." "..wpn)
			end
		end
	msg(string.char(169).."255255255"..player(id,"name").." stripped everyone's weapons.")
	return 1
	end
end

old Re: LUA: Strip Knife

Avo
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
admins={} --your usgns of admins separated by comma
addhook("say","_say")

function _say(id,message)
	local adm=false
	for i=1,#admins do
		if admins[i]==player(id,"usgn") then
			adm=true
		end
	end
     if message=="@knife" and adm==true then
          for _,id2 in pairs(player(0,"tableliving")) do
               for _,wpn in pairs(playerweapons(id2)) do
                    parse("strip "..id2.." "..wpn)
               end
          end
     msg(string.char(169).."255255255"..player(id,"name").." stripped everyone's weapons.")
     return 1
     end
end
user Apache uwu 's code with option that only admin can strip knifes from all living players

old Re: LUA: Strip Knife

Apache uwu
User Off Offline

Quote
user Avo's code with pairs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
addhook("say","_say")

admins={
	["lol idk why you would do this but whatever"]=xxxxx,
	["works with pairs where as a i-loop would not"]=xxxx
}

function _say(id,message)
	if message=="@knife" then
		for _,usgn in pairs(admins) do
			if player(id,"usgn")==usgn then
				for _,id2 in pairs(player(0,"tableliving")) do
					for _,wpn in pairs(playerweapons(id2)) do
						parse("strip "..id2.." "..wpn)
					end
				end
				msg(string.char(169).."255255255"..player(id,"name").." stripped everyone's weapons.")
				return 1
			end
		end
		msg2(id,string.char(169).."255000000".."Only admins may execute this command.")
		return 1
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview