Currently I have been working on an AK-47 SWEP, and there seems to be something wrong with the reload sounds. This is my first actual SWEP, so I'm not quite sure what to do to make these sounds work. I beileve that it has something to do with the ak47.txt file, and I already got the main sound file working which is the "shooting" sound, but I can't get the reloading. I will post the script/weapons/ak47.txt file that came with the model. I should also mention that I hexed this model into Gmod, so it did not come with an Lua.
"AK47.Draw"
{
"channel" "CHAN_WEAPON"
"volume" "1.0"
"CompatibilityAttenuation" "0.52"
"pitch" "PITCH_NORM"
"wave" "weapons/AYKAYFORTY/Draw.wav"
}
"AK47.Bolt"
{
"channel" "CHAN_WEAPON"
"volume" "1.0"
"CompatibilityAttenuation" "0.52"
"pitch" "PITCH_NORM"
"wave" "weapons/AYKAYFORTY/Bolt.wav"
}
"AK47.MagTap"
{
"channel" "CHAN_WEAPON"
"volume" "1.0"
"CompatibilityAttenuation" "0.52"
"pitch" "PITCH_NORM"
"wave" "weapons/AYKAYFORTY/MagTap.wav"
}
"AK47.MagOut"
{
"channel" "CHAN_WEAPON"
"volume" "1.0"
"CompatibilityAttenuation" "0.52"
"pitch" "PITCH_NORM"
"wave" "weapons/AYKAYFORTY/Magout.wav"
}
"AK47.MagIn"
{
"channel" "CHAN_WEAPON"
"volume" "1.0"
"CompatibilityAttenuation" "0.52"
"pitch" "PITCH_NORM"
"wave" "weapons/AYKAYFORTY/Magin.wav"
}
These do match the sound files names, so I know thats not the problem.
Any help is accepted.
[url=http://wiki.garrysmod.com/?title=Explosion_SWep]This will explain the basics of coding a SWep.[/url]
[lua]local Time = CurTime()
function SWEP:Reload()
if ( self.Weapon:Ammo1() <= 0 ) then return end
if ( self.Weapon:Clip1() >= self.Primary.ClipSize ) then return end
if (CurTime() < Time + 0.5) then return end --Replace here
Time = CurTime()
--And between these
timer.Simple(0.1,function() self.Weapon:EmitSound("weapons/AYKAYFORTY/Magout.wav") end)
timer.Simple(0.2,function() self.Weapon:EmitSound("weapons/AYKAYFORTY/Bolt.wav") end)
timer.Simple(0.3,function() self.Weapon:EmitSound("weapons/AYKAYFORTY/MagTap.wav") end)
timer.Simple(0.4,function() self.Weapon:EmitSound("weapons/AYKAYFORTY/Magout.wav") end)
timer.Simple(0.5,function() self.Weapon:EmitSound("weapons/AYKAYFORTY/Magin.wav") end)
--And between these
self.Owner:SetAnimation(PLAYER_RELOAD)
self.Weapon:DefaultReload(ACT_VM_RELOAD)
end [/lua]
[b]Replace following:[/b]
if (CurTime() < Time + 0.5) then return end
Replace the "0.5" with the time your weapon needs to fully reload (in seconds)
timer.Simple(0.1,function() ... end)
Replace "0.1" ("0.2"...) with the time (in seconds) delay the sound should play
This SHOULD work
I can't exactly find out where to put that code, can you show an example?
Thanks.
[url]http://wiki.garrysmod.com/?title=Explosion_SWep[/url]
Read this, it contains every info you need about making your swep
Simply goes into shared lua as function SWEP:Reload()
EDIT: Oops that was already stated in the 2nd post lol
Great solution, helped me a lot with problems I was having with reload sounds. Thanks!
I have exactly the same problem, the reloading sounds arent working for me either.
Take a look please.
[url]http://www.facepunch.com/showthread.php?t=919729[/url]
[url=http://www.garrysmod.org/downloads/?a=view&id=95485][img]http://www.garrysmod.org/img/?t=dll&id=95485[/img][/url]
Thats a swep that i just did. It has reload sounds, although they are compiled into one big one, which requires a little bit of audio editing.
My swep reloading is MUCH more basic than TheGreatVax's version, although both work just fine. With my version, the audio may be a tiny bit out of sync (although that depends on how well you edited it) and there are much less things that can go wrong, but TheGreatVax's version would be in perfect sync, although depending on your experience (even though he gave a huge instructions list thingy) you may screw something up.
You can make reload sounds work WITHOUT lua coding . Go to garrysmod folder then to scripts folder and create a folder named "sounds" (without qutoes), in "sounds" folder create folder called "weapons" and paste your .txt file there . it should work now, at least it worked for me
[QUOTE=Azaz3l;21227828]You can make reload sounds work WITHOUT lua coding . Go to garrysmod folder then to scripts folder and create a folder named "sounds" (without qutoes), paste your .txt file there then restart gmod if you have it running. It must work now atleast worked for me[/QUOTE]
That doesn't work, because there is nothing in the lua file that suggests looking at the .txt file.
And Lua doesn't use those sorts of things in the text file unless specified.
Do you have any idea about what you're talking about/are you talking about CS:S?
Sweps NEED Lua to be coded? duh?
[QUOTE=Flubadoo;21227859]That doesn't work, because there is nothing in the lua file that suggests looking at the .txt file.
And Lua doesn't use those sorts of things in the text file unless specified.
Do you have any idea about what you're talking about/are you talking about CS:S?
Sweps NEED Lua to be coded? duh?[/QUOTE]
Actualy the weapon model uses scripts, it indicates what sound to play , and by lua coding I meant that you don't need to put "EmitSound" in SWEP:Reload() function to make reload sounds work
Edit : When you launch gmod it auto checks scripts folder and mounts .txt files (look game_sounds_manifest.txt)
[QUOTE=Azaz3l;21227957]Actualy the weapon model uses scripts, it indicates what sound to play , and by lua coding I meant that you don't need to put "EmitSound" in SWEP:Reload() function to make reload sounds work
Edit : When you launch gmod it auto checks scripts folder and mounts .txt files (look game_sounds_manifest.txt)[/QUOTE]
Too bad you're talking about CS:S
[QUOTE=Flubadoo;21229755]Too bad you're talking about CS:S[/QUOTE]
Try it yourself if you don't belive me
Too bad it didnt work. If it did, everyone would be using it.
Sorry, you need to Log In to post a reply to this thread.