Jump to content

Cry Slothbot


iPanda

Recommended Posts

Posted

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) 

Posted

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.

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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

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.

DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp

 

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