Jump to content

Ped Sound Help


S7waj

Recommended Posts

Posted (edited)
I need codes to make a sound on ped 
when spawn and death ( sound from desktop )
Edited by S7waj
  • S7waj changed the title to Ped Sound Help
Posted (edited)

See the example in wiki 

playSound
Or
playSound3D
addEventHandler("onPedWasted") -- for ped not player

 

Edited by Sisqo0
Posted
2 hours ago, Sisqo0 said:

@S7waj

You want another example as well as in wiki?

I don't know what you mean exactly ?

Like Zombie Moan

Posted
local sound = playSound3D("sounds/song.mp3", 373.14, -125.21, 1001, true) 
local uSound = playSound3D('http://977music.com/itunes/80s.pls', 2498, -1659, 12) 

 

You can either download the sound from the internet and then redirect it with the first code i copied or if you want to stream it from somewhere else you use the second code. I'm no scripter myself so there's not much i can do to help you more on this. Hope i could help you out :)

Posted (edited)
13 minutes ago, Gribixtugaz said:

local sound = playSound3D("sounds/song.mp3", 373.14, -125.21, 1001, true) 

local uSound = playSound3D('http://977music.com/itunes/80s.pls', 2498, -1659, 12) 

 

You can either download the sound from the internet and then redirect it with the first code i copied or if you want to stream it from somewhere else you use the second code. I'm no scripter myself so there's not much i can do to help you more on this. Hope i could help you out :)

man i said i want it on ped not on location ( when ped move sound follow him )

Edited by S7waj
Posted

Ok i understood what you wanted

--Client
function attachsound () 
   local ped = createPed(120,0,0,0) 
   local x,y,z = getElementPosition( ped )
   local sound = playSound3D( "sound", x, y, z, true) 
   attachElements ( sound, ped) 
end

 

Posted
4 hours ago, Sisqo0 said:

Ok i understood what you wanted


--Client
function attachsound () 
   local ped = createPed(120,0,0,0) 
   local x,y,z = getElementPosition( ped )
   local sound = playSound3D( "sound", x, y, z, true) 
   attachElements ( sound, ped) 
end

 

i will trry it

 

Where's the Wrong Here?

addEvent ( "tanks", true )
addEventHandler ( "tanks", root,
function ( ) 
   local x,y,z = getElementPosition( tanks )
   local sound = playSound3D( "tank_spawn.wav", x,y,z, true) 
   attachElements ( sound, tanks) 
end
)

 

 

Posted
4 hours ago, Sisqo0 said:

maybe you didn't define "tanks" or you didn't add sound in meta.xml


 <file src="tank_spawn.wav" />

 

sound is added and sound diden't start

Posted
local xPos,yPos,zPos
local sound

function onWasted()
if isElement(sound) then destroyElement(sound) end
sound = playSound3D( "tank_spawn.wav", xPos,yPos,zPos)
setSoundMaxDistance(sound, 100)
end
addEventHandler("onClientPedWasted", getRootElement(), onWasted)

function onSpawn()
if isElement(sound) then destroyElement(sound) end
sound = playSound3D( "tank_spawn.wav", xPos,yPos,zPos)
setSoundMaxDistance(sound, 100)
end
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), onSpawn )

function position()
if isElement(sound) then
xPos,yPos,zPos = getElementPosition(localPlayer)
end
end
addEventHandler('onClientRender',root,position)

use this and check your audio file extension if it .wav or not

 

 

12 hours ago, S7waj said:

i will trry it

 

Where's the Wrong Here?


addEvent ( "tanks", true )
addEventHandler ( "tanks", root,
function ( ) 
   local x,y,z = getElementPosition( tanks )
   local sound = playSound3D( "tank_spawn.wav", x,y,z, true) 
   attachElements ( sound, tanks) 
end
)

 

 

here you try to get position and attach elements to a nil value 'tanks'

Posted
1 minute ago, MrKAREEM said:

local xPos,yPos,zPos
local sound

function onWasted()
if isElement(sound) then destroyElement(sound) end
sound = playSound3D( "tank_spawn.wav", xPos,yPos,zPos)
setSoundMaxDistance(sound, 100)
end
addEventHandler("onClientPedWasted", getRootElement(), onWasted)

function onSpawn()
if isElement(sound) then destroyElement(sound) end
sound = playSound3D( "tank_spawn.wav", xPos,yPos,zPos)
setSoundMaxDistance(sound, 100)
end
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), onSpawn )

function position()
if isElement(sound) then
xPos,yPos,zPos = getElementPosition(localPlayer)
end
end
addEventHandler('onClientRender',root,position)

use this and check your audio file extension if it .wav or not

 

 

here you try to get position and attach elements to a nil value 'tanks'

ok MrKAREEM I will try it + do you remember me? i'am itsMessi on FFS Gaming

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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