Forum

> > CS2D > Scripts > Lua Sound needed
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Sound needed

6 replies
To the start Previous 1 Next To the start

old Lua Sound needed

itsoxymoron
User Off Offline

Quote
• Hey guys, I need a lua, when you pick up an item (dont know, maybe ID 2,73,etc), this make a sound. too easy.

I tried but I cant , so, thx.

old Re: Lua Sound needed

Kel9290
User Off Offline

Quote
1
2
3
4
5
6
7
8
YOUR_ITEM_ID = 50 -- item id

addhook("collect","cc")
function cc(id,iid,type)
	if type = YOUR_ITEM_ID then
		parse("sv_sound fun/thats_the_way.wav")
	end
end

old Re: Lua Sound needed

Apache uwu
User Off Offline

Quote
Probably should change that to sv_sound2, so no one else will hear the pickup sound.

1
parse("sv_sound2 "..id.." fun/thats_the_way.wav")
edited 2×, last 17.09.11 06:29:26 am

old Re: Lua Sound needed

Apache uwu
User Off Offline

Quote
I believe it's walkover, not collect. Collect means picking up primary ammo/sec.

1
2
3
4
5
6
7
8
9
10
item_snd={}
item_snd[50]="fun/thats_the_way.wav"

addhook("walkover","_walkover")

function _walkover(id,iid,type,ain,a,mode)
	if item_snd[tonumber(type)]~=nil then
		parse("sv_sound2 "..id.." "..item_snd[tonumber(type)])
	end
end

Now if you want to add any new sounds you can just use this syntax.

1
item_snd[item_id]="sound file"

old Re: Lua Sound needed

itsoxymoron
User Off Offline

Quote
user Apache uwu has written
I believe it's walkover, not collect. Collect means picking up primary ammo/sec.

1
2
3
4
5
6
7
8
9
10
item_snd={}
item_snd[50]="fun/thats_the_way.wav"

addhook("walkover","_walkover")

function _walkover(id,iid,type,ain,a,mode)
	if item_snd[tonumber(type)]~=nil then
		parse("sv_sound2 "..id.." "..item_snd[tonumber(type)])
	end
end

Now if you want to add any new sounds you can just use this syntax.

1
item_snd[item_id]="sound file"


Good, Thx, but i have a problem, make a sound every time when you step on the item, it possible to have a delay. or dont do it again?

EDIT

Fixed!: I change the
1
("walkover","_walkover")


for
1
("collect","cc")


Thank you so much!
edited 1×, last 19.09.11 04:25:13 am

old Re: Lua Sound needed

Apache uwu
User Off Offline

Quote
Well potentially the sound file should be fairly short (0.1-1 sec), anything longer it would be annoying for the client to pick up a weapon.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview