#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.
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.
#Whit3^ Posted February 4, 2013 Author Posted February 4, 2013 So I have to add this feature in the client's side race?
#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)
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.
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.
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!
#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.
Recommended Posts