#Whit3^ Posted February 4, 2013 Share 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) Link to comment
WASSIm. Posted February 4, 2013 Share 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) Link to comment
Anderl Posted February 4, 2013 Share 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. Link to comment
Anderl Posted February 4, 2013 Share Posted February 4, 2013 You need to add the event "onClientMapStarting", it is an event from race gamemode, not a global one. Link to comment
#Whit3^ Posted February 4, 2013 Author Share Posted February 4, 2013 So I have to add this feature in the client's side race? Link to comment
#Whit3^ Posted February 4, 2013 Author Share Posted February 4, 2013 i have already tryed Link to comment
Anderl Posted February 4, 2013 Share Posted February 4, 2013 i have already tryed Show what you tried. Link to comment
#Whit3^ Posted February 4, 2013 Author Share 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) Link to comment
Castillo Posted February 4, 2013 Share Posted February 4, 2013 Your first script should work. Link to comment
Puma Posted February 4, 2013 Share 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. Link to comment
Anderl Posted February 4, 2013 Share 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. Link to comment
Techial Posted February 4, 2013 Share Posted February 4, 2013 Oh god, I just recognized this script.. I made it for aR// Thanks for stealing it! Link to comment
#Whit3^ Posted February 4, 2013 Author Share Posted February 4, 2013 sry it's your idea, but do not use it much this script sry Techial Close Link to comment
Castillo Posted February 4, 2013 Share 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. Link to comment
Recommended Posts