Jump to content

[HELP] setWorldSoundEnabled not working


Captain07

Recommended Posts

Posted

Hello,

I'm trying to disable default weapon sounds, but it's not working.
I obtained the sounds with development mode + showsound and I turned them off, but ther are still there.
Not even the example on mtawiki works, or other codes that I found.
What's going on?! 

Thanks for reading!

  • Moderators
Posted
11 minutes ago, Captain07 said:

What's going on?! 

Most gun sounds exist out of multiple small sounds. Maybe that is the issue?

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   ?

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
33 minutes ago, Erlkonig said:

Can you show your code please?

Did you try the group ID 3?

function toggle()
    setWorldSoundEnabled(5, false) 
	setWorldSoundEnabled(3, false) 
end
addCommandHandler("toggle", toggle)

 

Posted

It is in client side. I can disable other sounds, but not weapon sounds.

My only guess is that there is another resource that enables them. But I have no idea which, I don't even remember doing anything like this before. Is there a way to find out which resource uses this function, without checking them one by one?

Posted
37 minutes ago, Captain07 said:

It is in client side. I can disable other sounds, but not weapon sounds.

My only guess is that there is another resource that enables them. But I have no idea which, I don't even remember doing anything like this before. Is there a way to find out which resource uses this function, without checking them one by one?

I tested this script, it works. Can you try to test it  the default MTA server?

Posted
22 minutes ago, Erlkonig said:

I tested this script, it works. Can you try to test it  the default MTA server?

Yup, it's working, I stopped everything else. Now I have to find out what is messing around, I guess this is where the fun begins. ?
Thanks everyone!

Posted (edited)
11 minutes ago, Captain07 said:

Yup, it's working, I stopped everything else. 

and that's because you disabled a whole group, you need to find the index. anyway,

I have a code that disables most gunshots, M4/AK is still around here i think since i didn't want to disable the rustler/seasparrow sound...( but M4/AK sounds are not noticeable if it has a custom sound anyway..  unlike Deagle, etcs) what type of sounds do u want to disable? anyway here:

local removedIDs = { 33, 4, 28, 21, 22, 23, 6, 7, 8, 29, 30, 17, 18, 26,
27, 52, 53, 5, 0, 1, 2, 12, 14, 15, 16, 11 }

setWorldSoundEnabled ( 5,  true)
for i, sound in pairs(removedIDs) do
	setWorldSoundEnabled(5, sound, false)
end

Just play with it, see what IDs u wanna remove / add.

It's all weapon sounds btw.

Edited by Bean666

Aftermath

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...