Forum

> > CS2D > Scripts > Sound Around Player
Forums overviewCS2D overview Scripts overviewLog in to reply

English Sound Around Player

4 replies
To the start Previous 1 Next To the start

old Sound Around Player

Ghost-Rider
BANNED Off Offline

Quote
Play sound around player?
hi i wanna make a script for my server
when i sit onto polie car and i write command into chat(!siren)
the sound will be played around a player.

old Re: Sound Around Player

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
21
22
23
24
25
siren={}
for i=1,32 do siren[i]=0 end
function distance(x1,y1,x2,y2)
     return math.floor(math.sqrt(math.pow(x1-x2,2)+math.pow(y1-y2,2)))
end

addhook("say","OnSay")
function OnSay(id,txt)
	if txt=="!siren" then
		if siren[id]==1 then siren[id]=0 else siren[id]=1 end
	end
end

addhook("second","EverySecond")
function EverySecond()
	for _,id in pairs(player(0,"tableliving")) do
		if siren[id]==1 then
			for _,ID in pairs(player(0,"tableliving")) do
				if distance(player(id,"x"),player(id,"y"),player(ID,"x"),player(ID,"y"))<=500 then
					parse('sv_sound2 '..ID..' "env/alarm.wav"')
				end
			end
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview