Forum

> > CS2D > Scripts > [Request] Remove the weapon
Forums overviewCS2D overview Scripts overviewLog in to reply

English [Request] Remove the weapon

12 replies
To the start Previous 1 Next To the start

old [Request] Remove the weapon

Gaios
Reviewer Off Offline

Quote
> How to remove weapon in slot?
Please code.

eg:
1
2
3
4
5
6
addhook('say','SayHook')
function SayHook(id,txt)
	if txt=="@remove 32" then -- m4a1
		************ CODE ************
	end
end

old Re: [Request] Remove the weapon

Bowlinghead
User Off Offline

Quote
1
2
3
4
5
6
7
addhook('say','SayHook')
function SayHook(id,txt)
     if txt=="@remove 32" then -- m4a1
         parse("strip "..id.." 32")
	msg2(id,"Your M4 is stripped!")
     end
end

-- Untestet

old Re: [Request] Remove the weapon

RedizGaming
GAME BANNED Off Offline

Quote
1
2
3
4
5
6
7
addhook('say','a')
function a(id,txt,itemtype)
	if txt=="@remove 32" or "!remove 32" ten -- m4a1
         parse("removeitem '..itemtype)
	msg2(id,"Your M4A1 As Ben Removed!")
     end
end

old Re: [Request] Remove the weapon

omg
User Off Offline

Quote
user RedizGaming has written
1
2
3
4
5
6
7
addhook('say','a')
function a(id,txt,itemtype)
	if txt=="@remove 32" or "!remove 32" ten -- m4a1
         parse("removeitem '..itemtype)
	msg2(id,"Your M4A1 As Ben Removed!")
     end
end

lmfao there was already a correct answer, no need to look dumb

old Re: [Request] Remove the weapon

ohaz
User Off Offline

Quote
user Bowlinghead has written
1
2
3
4
5
6
7
addhook('say','SayHook')
function SayHook(id,txt)
     if txt=="@remove 32" then -- m4a1
         parse("strip "..id.." 32")
	msg2(id,"Your M4 is stripped!")
     end
end

-- Untestet
To improve this script and add the ability to remove every weapon, you could do it like this:
1
2
3
4
5
6
7
8
9
10
11
addhook('say','SayHook')
function SayHook(id,txt)
     if split(txt, " ")[0]=="@remove" then
       if (#split(txt, " ") > 1) then
         parse("strip "..id.." "..split(txt, " ")[1])
         msg2(id,"Your Weapon is stripped!")
       else
         msg2(id,"Missing param (Weapon ID)")
       end
     end
end

old Re: [Request] Remove the weapon

EP
User Off Offline

Quote
@user ohaz: You forgot the split function there

Isn't it better using string.sub?

1
2
3
4
5
6
7
8
9
10
11
12
13
addhook('say','SayHook')
function SayHook(id,txt)
	if txt:lower():sub(1,7) =="@remove" then
		local wpn = txt:sub(9,10)
		if wpn then
			parse("strip "..id.." "..wpn)
			msg2(id,"Your "..itemtype(wpn,"name").." was stripped!")
			return 1
		else
			msg2(id,"Missing param (Weapon ID)")
		end
	end
end
edited 1×, last 15.09.12 03:00:59 pm

old Re: [Request] Remove the weapon

ohaz
User Off Offline

Quote
user EP has written
@user ohaz: You forgot the split function there
Thought he might be able to google for Lua split functions himself...
Quote
Isn't it better using string.sub?
Not really. string.sub forces you to use IDs that are 2 digits long.

old Re: [Request] Remove the weapon

EP
User Off Offline

Quote
@user omg: It doesn't have to be converted to integer, the parse function reads strings, not numbers, and also when you concatenate strings, the integer (for example 4) will be converted to a string automatically.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview