Overkillz Posted June 5, 2014 Share Posted June 5, 2014 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
Max+ Posted June 5, 2014 Share Posted June 5, 2014 what gamemode are you using for this ? Race , ? Link to comment
.:HyPeX:. Posted June 5, 2014 Share Posted June 5, 2014 This: addEventHandler("onClientRender",getLocalPlayer(),sound,loadingtravel) should be this: addEventHandler("onClientRender",root,sound) addEventHandler("onClientRender",root,loadingtravel) Link to comment
Max+ Posted June 5, 2014 Share Posted June 5, 2014 .:HyPeX:. Yes, that is a fix , but he want it , when the map Change i think it's a custom Event , for Race , Link to comment
Overkillz Posted June 5, 2014 Author Share Posted June 5, 2014 I cant hear the music: Debuscript: WARNING: race/race_client.lua:186: Bad'sound/player' pointer @ 'setSoundVolume (1) Link to comment
Max+ Posted June 5, 2014 Share Posted June 5, 2014 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
Overkillz Posted June 5, 2014 Author Share Posted June 5, 2014 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
Max+ Posted June 5, 2014 Share Posted June 5, 2014 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 .mp3 inside it , and Post your , meta.xml file , Link to comment
Overkillz Posted June 6, 2014 Author Share Posted June 6, 2014 Now the problem is, I heard a song like a anoying sound which lag me, I can move and nothing, maybe 0.1 fps and I need to close the game, idk why ... Link to comment
Max+ Posted June 6, 2014 Share Posted June 6, 2014 well , i made the sound 50 % only > and give you lag ? is there any other sound scripts beside this on the server> ? if there is iam sure it's form it , Link to comment
Overkillz Posted June 6, 2014 Author Share Posted June 6, 2014 (edited) 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 June 6, 2014 by Guest Link to comment
Max+ Posted June 6, 2014 Share Posted June 6, 2014 Ok , Try Change to root on the event to resourceRoot And test it , if it's lag , then there must be, other resource causing the lag, Link to comment
Overkillz Posted June 6, 2014 Author Share Posted June 6, 2014 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
Den. Posted June 6, 2014 Share Posted June 6, 2014 (edited) 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 .mp3 is in the folder audio, in your resouce. Also make sure it is correctly added in the meta.xml of your resource. Edited June 6, 2014 by Guest Link to comment
Overkillz Posted June 6, 2014 Author Share Posted June 6, 2014 Thanks so much, it work perfectly, without any bug ^^ Link to comment
Den. Posted June 6, 2014 Share Posted June 6, 2014 Okay, I edited the code and took "local screenWidth, screenHeight = guiGetScreenSize()" out of loadingtravel() because there was no need to get the screen size every render. And anytime . Link to comment
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