#Whit3^ Posted February 4, 2013 Posted February 4, 2013 Hello Basically I want that when the last person dies (race mode) sound is heard at random. I used this to make sure that when you hear those sounds change map but that does not work .. sorry for this english .. local sounds = { "modes/win.mp3", "modes/win2.mp3", "modes/win3.mp3", "modes/win4.mp3", "modes/win5.mp3"} function zaa() playSound ( sounds [ math.random ( 1, #sounds ) ] ) end addEventHandler ( "onClientMapStarting", getRootElement(), zaa)
WASSIm. Posted February 4, 2013 Posted February 4, 2013 local sounds = { [1] = {"modes/win.mp3"}, [2] = {"modes/win2.mp3"}, [3] = {"modes/win3.mp3"}, [4] = {"modes/win4.mp3"}, [5] = {"modes/win5.mp3"}, } function zaa() local sound = unpack(sounds[math.random(1,5)]) local sounda = playSound (sound) setSoundVolume(sounda, 0.5) end addEventHandler ( "onClientMapStarting", getRootElement(), zaa)
Anderl Posted February 4, 2013 Posted February 4, 2013 HelloBasically I want that when the last person dies (race mode) sound is heard at random. I used this to make sure that when you hear those sounds change map but that does not work .. sorry for this english .. local sounds = { "modes/win.mp3", "modes/win2.mp3", "modes/win3.mp3", "modes/win4.mp3", "modes/win5.mp3"} function zaa() playSound ( sounds [ math.random ( 1, #sounds ) ] ) end addEventHandler ( "onClientMapStarting", getRootElement(), zaa) I'm pretty sure you need to add that event, it isn't a global one. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Anderl Posted February 4, 2013 Posted February 4, 2013 You need to add the event "onClientMapStarting", it is an event from race gamemode, not a global one. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
#Whit3^ Posted February 4, 2013 Author Posted February 4, 2013 So I have to add this feature in the client's side race?
Anderl Posted February 4, 2013 Posted February 4, 2013 No, addEvent. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Castillo Posted February 4, 2013 Posted February 4, 2013 Post the meta.xml. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Anderl Posted February 4, 2013 Posted February 4, 2013 i have already tryed Show what you tried. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
#Whit3^ Posted February 4, 2013 Author Posted February 4, 2013 now it work with this sry for all problem local sounds = { [1] = {"modes/win.mp3"}, [2] = {"modes/win2.mp3"}, [3] = {"modes/win3.mp3"}, [4] = {"modes/win4.mp3"}, [5] = {"modes/win5.mp3"}, } function zaa() local sound = unpack(sounds[math.random(1,5)]) local sounda = playSound (sound) setSoundVolume(sounda, 0.5) end addEventHandler ( 'onClientMapStarting', root, zaa)
Castillo Posted February 4, 2013 Posted February 4, 2013 Your first script should work. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Puma Posted February 4, 2013 Posted February 4, 2013 Your first script should work. No. You need to add: addEvent ( "onClientMapStarting", true ) Above: addEventHandler ( 'onClientMapStarting', root, zaa) Every event that isn't a default MTA event must be added using addEvent. "The total IQ of the world is a constant. The more people, the more idiots." - Anonymous.
Anderl Posted February 4, 2013 Posted February 4, 2013 now it work with thissry for all problem local sounds = { [1] = {"modes/win.mp3"}, [2] = {"modes/win2.mp3"}, [3] = {"modes/win3.mp3"}, [4] = {"modes/win4.mp3"}, [5] = {"modes/win5.mp3"}, } function zaa() local sound = unpack(sounds[math.random(1,5)]) local sounda = playSound (sound) setSoundVolume(sounda, 0.5) end addEventHandler ( 'onClientMapStarting', root, zaa) You didn't add what I said, and it won't work with only that code. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Techial Posted February 4, 2013 Posted February 4, 2013 Oh god, I just recognized this script.. I made it for aR// Thanks for stealing it! ____________________________________________________________ http://techial.net/
#Whit3^ Posted February 4, 2013 Author Posted February 4, 2013 sry it's your idea, but do not use it much this script sry Techial Close
Castillo Posted February 4, 2013 Posted February 4, 2013 Your first script should work. No. You need to add: addEvent ( "onClientMapStarting", true ) Above: addEventHandler ( 'onClientMapStarting', root, zaa) Every event that isn't a default MTA event must be added using addEvent. I used this same event handler WITHOUT addEvent for a map info script. Topic locked. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts