Jump to content

Not Work This


#Whit3^

Recommended Posts

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 .. :roll:

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
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
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 .. :roll:

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

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
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) 

You didn't add what I said, and it won't work with only that code.

Link to comment
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
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...