Jump to content

Playsound problem


Recommended Posts

Hi everyone, I will like do a Playsound while is changing of map, (On Travelling)

but IDK why this doesn't work:

local angle = 0 
  
function loadingtravel() 
local screenWidth, screenHeight = guiGetScreenSize() 
angle = angle +7 
dxDrawImage(screenWidth/2-32, screenHeight/2-32, 64, 64, 'img/travelling.png', angle,0,0) 
fadeCamera ( false, 0, 0, 0, 0 ) 
end 
  
function sound ()  
    local sound = playSound("audio/xd.mp3") 
    setSoundVolume(sound, 1)  
end 
addEventHandler("onClientRender",getLocalPlayer(),sound,loadingtravel) 

I hope you can help me ^^

Link to comment
I cant hear the music:

Debuscript:

WARNING: race/race_client.lua:186: Bad'sound/player' pointer @ 'setSoundVolume (1)

volume: A floating point number representing the desired volume level. Range is from 0.0 to 1.0

Link to comment

it doesnt work

local angle = 0

function loadingtravel()

local screenWidth, screenHeight = guiGetScreenSize()

angle = angle +7

dxDrawImage(screenWidth/2-32, screenHeight/2-32, 64, 64, 'img/travelling.png', angle,0,0)

fadeCamera ( false, 0, 0, 0, 0 )

end

function sound2 ()

local sound = playSound("audio/xd.mp3")

setSoundVolume(sound,1.0)

end

addEventHandler("onClientRender",root,sound2)

addEventHandler("onClientRender",root,loadingtravel)

Link to comment
local angle = 0 
local screenWidth, screenHeight = guiGetScreenSize() 
local sound = playSound('audio/xd.mp3') 
angle = angle +7 
addEventHandler('onClientRender', root, 
function () 
dxDrawImage(screenWidth/2-32, screenHeight/2-32, 64, 64, 'img/travelling.png', angle,0,0) 
fadeCamera ( false, 0, 0, 0, 0 ) 
     setSoundVolume(sound, 0.5) 
end 
 ) 

Make Sure , you have audio file with xD.mp3 inside it ,

and Post your , meta.xml file ,

Link to comment

No, just mission acomplice, but it shouldm't work, just on race maps when someone finish the map, but while travelling, I heard a annoying sound which give me lag.

I tried with 1.0 and 0.5 and doesnt work.

Edited by Guest
Link to comment

I cant heard nothing

local angle = 0 
  
function loadingtravel() 
local screenWidth, screenHeight = guiGetScreenSize() 
angle = angle +7 
dxDrawImage(screenWidth/2-32, screenHeight/2-32, 64, 64, 'img/travelling.png', angle,0,0) 
fadeCamera ( false, 0, 0, 0, 0 ) 
end 
  
function sound2 ()  
    local sound = playSound("audio/xd.mp3") 
    setSoundVolume(sound, 1.0) 
end 
addEventHandler("onClientRender",resourceRoot,sound2) 
addEventHandler("onClientRender",resourceRoot,loadingtravel) 

Link to comment

Try using this:

local angle, handled 
local screenWidth, screenHeight = guiGetScreenSize() 
function loadingtravel() 
   
    angle = angle +7 
    dxDrawImage(screenWidth/2-32, screenHeight/2-32, 64, 64, 'img/travelling.png', angle,0,0) 
     
end 
  
addEvent("onClientMapStopping", true) 
addEventHandler("onClientMapStopping", root, 
function() 
     
    if not handled then 
        handled = true 
        angle = 0 
        fadeCamera ( false, 0, 0, 0, 0 ) 
        addEventHandler("onClientRender", root, loadingTavel) 
        local sound = playSound("audio/xd.mp3") 
        setSoundVolume(sound, 1.0) 
    end 
end) 
  
addEvent("onClientMapStarting", true) 
addEventHandler("onClientMapStarting", root, 
function() 
    if handled then 
        fadeCamera(true, 0) 
        removeEventHandler("onClientRender", root, loadingtravel) 
        handled = false 
    end 
end) 

I used race to find the events for the when the map stops and starts. You were also trying to play a sound each time GTA renders a frame, which could be 60 times a second by using playSound with onClientRender.

Make sure xD.mp3 is in the folder audio, in your resouce. Also make sure it is correctly added in the meta.xml of your resource.

Edited by Guest
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...