How can I create this script?
5 replies



28.11.17 05:37:30 pm
I need to create a script that when you use a certain weapon, when you shoot it plays a sound in the area.

Code:
1
2
3
4
5
6
7
8
9
10
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
[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.
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 @
Mora: was nicer than me)
"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 @


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 @
Mora: was nicer than me)
"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 @

ok



