Jump to content

Cry Slothbot


iPanda

Recommended Posts

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) 

Link to comment

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.

Link to comment
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) 

Link to comment
  • MTA Team

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.

Link to comment

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...