English How can I create this script?

5 replies
Goto Page
To the start Previous 1 Next To the start
28.11.17 05:37:30 pm
Up
TGT10
User
Offline Off
I need to create a script that when you use a certain weapon, when you shoot it plays a sound in the area. us
IMG:https://i.imgur.com/lG2Qagr.png
28.11.17 07:39:34 pm
Up
Mora_rus
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
typesounds={
[30]="weapons/airstrike.ogg",
[32]="weapons/barbedwire.ogg"
}
addhook("hit","_hit")
function _hit(id,source,weapon,hpdmg,apdmg,rawdmg)
     if typesounds[weapon] then
          parse('sv_soundpos "'..typesounds[weapon]..'" '..player(id,"x")..' '..player(id,"y"))
     end
end

Try this, seems it working for me.
Oh btw, to make this script you need hit hook. ID is player who being hit by SOURCE. So im using
player(id,"y")
to parse this sounds related to his position. WEAPON is weapon of player who hit ID.
Table is made specially to recognize which weapon have which sound to be played when hit.

You can see yourself, add your weapon id in squarebrackets and set a path w/o "sfx" included.
I will finally join the army at 5.07.18 and back after year. bb
03.12.17 06:55:16 am
Up
TGT10
User
Offline Off
thank you!!
IMG:https://i.imgur.com/lG2Qagr.png
04.12.17 10:11:19 am
Up
VaiN
User
Offline Off
Since your topic has such a vague title, I feel compelled to give you the obvious answer.

"How can I create this script?"

If you are asking us this question, instead of yourself, then you're doing it wrong.



And don't forget to ask the documentation too.

(At least @user Mora_rus: was nicer than me)
04.12.17 10:28:36 am
Up
Yates
Reviewer
Offline Off
Edit: Ninja'd
01.01.18 11:21:43 pm
Up
TGT10
User
Offline Off
user VaiN has written:
Since your topic has such a vague title, I feel compelled to give you the obvious answer.

"How can I create this script?"

If you are asking us this question, instead of yourself, then you're doing it wrong.



And don't forget to ask the documentation too.

(At least @user Mora_rus: was nicer than me)


ok
IMG:https://i.imgur.com/lG2Qagr.png
To the start Previous 1 Next To the start