Boszor Posted November 10, 2015 Posted November 10, 2015 Dear Community, Where is my mistake here? Once I enter this command again to stop the sound and another to play. However, it happens nix and I'm also not so the brightest light in the lua topic. Would appreciate help. This is for the Police Maverrick. function speak (player,x,y,z) setWorldSoundEnabled sound = playSound3D ("song.mp3", x, y, z) car = getPedOccupiedVehicle ( player ) attachElements(sound,car) setSoundMaxDistance( sound, 150 ) elseif then if isElement( sound ) then stopSound( sound ) sound = playSound3D ("landing.mp3", x, y, z) setSoundMaxDistance( sound, 150 ) end addEvent ("Ansage", true) addEventHandler ("Ansage", getRootElement(), speak )
AlvarO Posted November 10, 2015 Posted November 10, 2015 Try to setSoundVolume(sound, 0) Anyway, any debug message? MTA:SA SPANISH DEATHMATCH PLAYER
Boszor Posted November 10, 2015 Author Posted November 10, 2015 So is it right? I have really no idea, unfortunately. I let the way else, but then it works but I can not stop him yet function speak (player,x,y,z) setWorldSoundEnabled sound = playSound3D ("song.mp3", x, y, z) car = getPedOccupiedVehicle ( player ) attachElements(sound,car) setSoundMaxDistance( sound, 150 ) else setSoundVolume(sound, 0) end addEvent ("Ansage", true) addEventHandler ("Ansage", getRootElement(), speak )
SpecT Posted November 11, 2015 Posted November 11, 2015 What ? Is that your full code or you just removed some stuff from that function? Here is the fixed code: function speak (player,x,y,z) setWorldSoundEnabled(!MISSING ARGUMENTS!) sound = playSound3D ("song.mp3", x, y, z) car = getPedOccupiedVehicle ( player ) attachElements(sound,car) setSoundMaxDistance( sound, 150 ) if isElement(sound) then stopSound(sound) end sound = playSound3D ("landing.mp3", x, y, z) setSoundMaxDistance( sound, 150 ) end addEvent ("Ansage", true) addEventHandler ("Ansage", getRootElement(), speak ) On line 2 check setWorldSoundEnabled and put the missing arguments in!
Boszor Posted November 11, 2015 Author Posted November 11, 2015 Hi, what do you mean by that argument, I would like that it is no longer audible to the police helicopter Maverrick. , But when I enter the Vehicle ID, then I happened nichts.Wenn / announcement Enter H to start song.mp3 of sound and if I / announcement again to stop the sound Enter H song.mp3 and be executed for it landing.mp3.
SpecT Posted November 11, 2015 Posted November 11, 2015 Hi, what do you mean by that argument, I would like that it is no longer audible to the police helicopter Maverrick. , But when I enter the Vehicle ID, then I happened nichts.Wenn / announcement Enter H to start song.mp3 of sound and if I / announcement again to stop the sound Enter H song.mp3 and be executed for it landing.mp3. I really can't understand what you want to tell me. If it's not working that's normal ... the arguments in setWorldSoundEnabled aren't set. Remove that line or put the right arguments! There is everything explained in the WIKI!
Boszor Posted November 11, 2015 Author Posted November 11, 2015 I have this line removed, however, only works the sound landing.mp3 Police Maverrick disabled Sound
Dealman Posted November 11, 2015 Posted November 11, 2015 Assuming the files exist, both of them should work. The issue however, is that you replace the sound almost immediately. You create a sound, playing the song.mp3 file, then you check if this sound is an element - if true, you stop it. Then you start playing landing.mp3 under the same variable. So basically what you're doing is stopping the sound right after you created it, and then play another one. 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.
Walid Posted November 11, 2015 Posted November 11, 2015 you need to send the song name from server side using "triggerClientEvent". Example Server side triggerClientEvent(client,"Ansage",client ,"song.mp3") -- or triggerClientEvent(client,"Ansage",client ,"loading.mp3") Client side function speak (songName) if not songName then return end if (not isPedInVehicle(localPlayer)) then return end if sound and isElement(sound) then destroyElement(sound) sound = nil -- or stopSound(sound) end local theVehicle = getPedOccupiedVehicle (localPlayer) local x,y,z = getElementPosition(theVehicle) sound = playSound3D (songName, x, y, z) attachElements(sound,theVehicle) setSoundMaxDistance(sound, 95) end addEvent ("Ansage", true) addEventHandler ("Ansage", getRootElement(), speak ) Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
Boszor Posted November 12, 2015 Author Posted November 12, 2015 Did it follow inserted meta.xml <meta> <script src="client.lua" type="client"/> <script src="server.lua" type="server"/> <file src="song.mp3"></file> <file src="landing.mp3"></file> </meta> Client - Side function speak (songName) if not songName then return end if (not isPedInVehicle(localPlayer)) then return end if sound and isElement(sound) then destroyElement(sound) sound = nil -- or stopSound(sound) end local theVehicle = getPedOccupiedVehicle (localPlayer) local x,y,z = getElementPosition(theVehicle) sound = playSound3D (songName, x, y, z) attachElements(sound,theVehicle) setSoundMaxDistance(sound, 100) end addEvent ("Ansage", true) addEventHandler ("Ansage", getRootElement(), speak ) Server - Side triggerClientEvent(client,"Ansage",client ,"song.mp3") -- or triggerClientEvent(client,"Ansage",client ,"landing.mp3") However, the desired success because unfortunately still do not. Also you hear the normal sound of the helicopter. It is still the first landing.mp3 played instead the start.mp3
Tekken Posted November 12, 2015 Posted November 12, 2015 Server Side addCommandHandler("stop1", function(playerSource, cmd) triggerClientEvent(playerSource, "Ansage", playerSource, "song.mp3"); end); addCommandHandler("stop2", function(playerSource, cmd) triggerClientEvent(playerSource, "Ansage", playerSource, "landing.mp3"); end); Resources I made: attachToBones - A newer bone_attach. Simple Level system - Just a simple level system. Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!
Boszor Posted November 12, 2015 Author Posted November 12, 2015 Thanks, but it's still coming only landing.mp3 and you hear the police Maverrick also
Tekken Posted November 12, 2015 Posted November 12, 2015 You need this setWorldSoundEnabled And use this in you'r advantage! Note: The values for group and index can be determined by using the client command showsound in conjunction with setDevelopmentMode Resources I made: attachToBones - A newer bone_attach. Simple Level system - Just a simple level system. Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!
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