Forum

> > CS2D > Scripts > sound around player when attack
Forums overviewCS2D overview Scripts overviewLog in to reply

English sound around player when attack

3 replies
To the start Previous 1 Next To the start

old sound around player when attack

serious-sam
User Off Offline

Quote
1
2
3
4
5
6
7
8
addhook("attack","_attack")
 function _attack(id)
 if player(id,'weapon') == 50 then
  parse("sv_sound2 "..id.."  "env/click.wav"")
  elseif player(id,'weapon') == 34 then
    parse("sv_sound2 "..id.."  "env/click.wav"")
  end
  end

i making lua which if player attack/shot then sound will plays around player who attack/shot.
i searched this and i saw some same question but, still i don't get it , please help me

old Re: sound around player when attack

VaiN
User Off Offline

Quote
quick tip:
when you are using parse(), make sure you include spaced before and after the id. Also, you can use a single quote to have double-quotes inside the string. Or escape them like: \"

1
2
3
parse("sv_sound2 " .. id .. ' "env/click.wav"')
or
parse("sv_sound2 " .. id .. " \"env/click.wav\"")
edited 1×, last 15.12.13 07:37:19 am

old Re: sound around player when attack

ReVoltage
User Off Offline

Quote
This is Radius Sound right?
Radius Sound is exists in a Tibia Lua.
While I used that function too, so I have it.
1
2
3
4
5
6
7
8
9
10
function radiussound(sound, x, y, radiusx, radiusy)
	if not (radiusx and radiusy) then radiusx, radiusy = 320, 240 end
	local x1, y1, x2, y2 = x-radiusx, y-radiusy, x+radiusx, y+radiusy
	for _, v in ipairs(player(0, 'table')) do
		if player(v, 'x') >= x1 and player(v, 'x') <= x2 and player(v, 'y') >= y1 and player(v, 'y') <= y2 then
			parse("sv_sound2 " .. v .. " " .. sound)
		end
	end
	return 1
end
And for the example to use it.
1
2
3
radiussound("weapons/c4_explode.wav",x,y)
--X=player(id,"x")
--Y=player(id,"y")
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview