iPanda Posted February 19, 2014 Posted February 19, 2014 Hello everyone, I have a problem with the sound of my ped (slothbot). Total, 6 bots available sounds (randomly determined). Bots cry 1 time every 8 seconds. My mistake: boats scream all 6 sounds at once, every second. Help. local number = math.random(1,6) local sound = playSound3D("sounds/cry"..number..".wav",pedX,pedY,pedZ,false) setSoundMaxDistance(sound, 20)
Dealman Posted February 19, 2014 Posted February 19, 2014 Not too sure, might be something else in your code causing it - though I doubt it. You could try to convert the integer to a string, like this; local number = math.random(1,6) local sound = playSound3D("sounds/cry"..tostring(number)..".wav",pedX,pedY,pedZ,false) setSoundMaxDistance(sound, 20) If that fails, are there any warnings and/or errors? Edit: As for it running every second is most definitely caused by something else in your code. Make sure you post ALL of the relevant code - or we can't help you. If you're using timers, make sure they're not looping unless you want them to.
iPanda Posted February 20, 2014 Author Posted February 20, 2014 Not too sure, might be something else in your code causing it - though I doubt it. You could try to convert the integer to a string, like this; local number = math.random(1,6) local sound = playSound3D("sounds/cry"..tostring(number)..".wav",pedX,pedY,pedZ,false) setSoundMaxDistance(sound, 20) If that fails, are there any warnings and/or errors? Edit: As for it running every second is most definitely caused by something else in your code. Make sure you post ALL of the relevant code - or we can't help you. If you're using timers, make sure they're not looping unless you want them to. Your suggestion does not work. More precisely zombies constantly cry 6 times without stopping. Here is the complete code: function botCry() local number = math.random(1,6) local sound = playSound3D("sounds/cry"..tostring(number)..".wav",pedX,pedY,pedZ,false) setSoundMaxDistance(sound, 20) end addEventHandler("onBotSpawned",getRootElement(),botCry)
MTA Team 0xCiBeR Posted February 20, 2014 MTA Team Posted February 20, 2014 Again, you're not posting all the code. Where is pedX,pedY & pedZ defined? Remeber that that will make every bot that spawns cry. If you have several bot spawing it will make the effect you describe. Please post all the code, including how you create the bot. Regards, CiBeR.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now