Jump to content

Bass Error 2 in load media :(


Recommended Posts

local themes =  
{ 
    "sounds/RADAR.mp3",  
    "sounds/RADAR2.mp3", 
    "sounds/RADAR3.mp3", 
} 

local sound = {}

function Ruiner2000theme() 
    local allVehicles = getElementsByType("vehicle") 
    for index, veh in ipairs (allVehicles) do 
        local model = getElementModel(veh) 
        if model == 494 then 
            if getVehicleEngineState(veh) then 
                if isElement(sound[veh]) then 
                    triggerServerEvent ( "fullyloaded", resourceRoot)
                else
                    local x, y, z = getElementPosition(veh)
                    sound[veh] = playSound3D( math.random( 1,#themes ), x, y, z, true)
                    attachElements(sound[veh], veh)
					setSoundMaxDistance(sound[veh], 1000)
                end 
            else
                if isElement(sound[veh]) then
                    destroyElement(sound[veh])
                end
            end
        end 
    end 
end 
addEventHandler("onClientPreRender", root, Ruiner2000theme) 

I have tried to make a script that when I get on the Ruiner 2000 it plays songs randomly, it works if I put the song as "RADAR.mp3", but it doesn't work if I put the mathrandom table, I have added the songs correctly in the meta and I don't know why it does not work :( 

Link to post
1 hour ago, Andres99907 said:

songs correctly in the meta and I don't know why it does not work

This code is executed every frame. I can see that you add some validation checks.

 

But check the execution rate of the following code, if it is too high it will be a much bigger than not playing sounds:

1 hour ago, Andres99907 said:

isElement(sound[veh]) then triggerServerEvent ( "fullyloaded", resourceRoot) else

 

As for the not playing sound, you forgot to index the table:

themes[math.random(#themes )]

 

  • Like 1
Link to post
1 hour ago, IIYAMA said:

This code is executed every frame. I can see that you add some validation checks.

 

But check the execution rate of the following code, if it is too high it will be a much bigger than not playing sounds:

 

As for the not playing sound, you forgot to index the table:


themes[math.random(#themes )]

 

:3  Thk you bro, it worked

  • Like 1
Link to post

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