Sasu Posted April 11, 2013 Posted April 11, 2013 function fuego(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) if ( not clickedElement ) then return end if state == "down" and clickedElement and getElementType ( clickedElement ) == "vehicle" and getElementType ( clickedElement ) == "player" then local x,y,z = getElementRotation ( localPlayer ) local rx,ry,rz = getElementPosition ( localPlayer ) kame = playSound3D("kame.mp3", rx, ry, rz) setTimer(createProjectile, 3500, 1, localPlayer, 20, rx, ry, rz, 200, clickedElement, x, y, z) if kame then setTimer(stopSound, 7000, 1, kame) end end end addEventHandler("onClientClick", root, fuego) Why this dont work? No errors on debug.
csiguusz Posted April 11, 2013 Posted April 11, 2013 An element can't be a vehicle and a player at the same time. if getElementType ( clickedElement ) == "vehicle" and getElementType ( clickedElement ) == "player" then
Mega9 Posted April 11, 2013 Posted April 11, 2013 You used "and" instead of "or" to check if the clicked element is a vehicle or player. function fuego(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) if (not clickedElement) then return end if state == "down" and getElementType ( clickedElement ) == "vehicle" or "player" then local x, y, z = getElementRotation ( localPlayer ) local rx,ry,rz = getElementPosition ( localPlayer ) kame = playSound3D("kame.mp3", rx, ry, rz) setTimer(createProjectile, 3500, 1, localPlayer, 20, rx, ry, rz, 200, clickedElement, x, y, z ) if kame then setTimer(stopSound, 7000, 1, kame) end end end addEventHandler("onClientClick", root, fuego) EDIT: Ah, haven't seen the new post.
Sasu Posted April 11, 2013 Author Posted April 11, 2013 Another script: function mp3url(cmd, url) if isElement(sound) then destroyElement(sound) end local x,y,z = getElementPosition(localPlayer) sound = playSound3D(url, x, y, z) attachElements(sound, localPlayer) setSoundMaxDistance(sound, 100) end addCommandHandler("url", mp3url) Why others players near me cant listen the music?
itoko Posted April 11, 2013 Posted April 11, 2013 Another script: function mp3url(cmd, url) if isElement(sound) then destroyElement(sound) end local x,y,z = getElementPosition(localPlayer) sound = playSound3D(url, x, y, z) attachElements(sound, localPlayer) setSoundMaxDistance(sound, 100) end addCommandHandler("url", mp3url) Why others players near me cant listen the music? I presume this is in client? so it execute the script only on your pc, you should make the commandHandler in server, and trigger the client function.
Sasu Posted April 11, 2013 Author Posted April 11, 2013 Client: function mp3url(source, url, x, y, z) if isElement(sound) then destroyElement(sound) end sound = playSound3D(url, x, y, z) attachElements(sound, source) setSoundMaxDistance(sound, 100) end addEvent("onPlayerRequestMusic", true) addEventHandler("onPlayerRequestMusic", getRootElement(), mp3url) function parar() if isElement(sound) then destroyElement(sound) end end addEvent("onPlayerRequestStopMusic", true) addEventHandler("onPlayerRequestStopMusic", getRootElement(), parar) Server: function mp3(source, cmd, url) local x,y,z = getElementPosition(source) triggerClientEvent("onPlayerRequestMusic", getRootElement(), source, url, x, y, z) end addCommandHandler("url", mp3) function stop() triggerClientEvent("onPlayerRequestStopMusic", getRootElement()) end addCommandHandler("parar", stop) But nothings happen.
itoko Posted April 11, 2013 Posted April 11, 2013 Hmm, do you execute the command correctly? Don't forget to give the url you are using in playSound3D(url, x, y, z) like /url song.mp3
itoko Posted April 11, 2013 Posted April 11, 2013 Can you give me the link? I tested the script on my server, and it worked fine, even with a radio link
Sasu Posted April 11, 2013 Author Posted April 11, 2013 http://dc335.4shared.com/download/dXzxD ... 486b89abeb Its a spanish song.
itoko Posted April 11, 2013 Posted April 11, 2013 You have to get a proper link, it has to be directly the song file, not a music player or so, like http://yourlink/song.mp3 I found this one for your music: http://srv2.youtump3.com/get.php?video_ ... t-KH3oIIcU
Sasu Posted April 11, 2013 Author Posted April 11, 2013 But before that I change the script works fine but players near me cant listen.
itoko Posted April 11, 2013 Posted April 11, 2013 Client: function mp3url(source, url, x, y, z) if isElement(sound) then destroyElement(sound) end sound = playSound3D(url, x, y, z) attachElements(sound, source) setSoundMaxDistance(sound, 100) end addEvent("onPlayerRequestMusic", true) addEventHandler("onPlayerRequestMusic", getRootElement(), mp3url) function parar() if isElement(sound) then destroyElement(sound) end end addEvent("onPlayerRequestStopMusic", true) addEventHandler("onPlayerRequestStopMusic", getRootElement(), parar) Server: function mp3(source, cmd, url) local x,y,z = getElementPosition(source) triggerClientEvent("onPlayerRequestMusic", getRootElement(), source, url, x, y, z) end addCommandHandler("url", mp3) function stop() triggerClientEvent("onPlayerRequestStopMusic", getRootElement()) end addCommandHandler("parar", stop) But nothings happen. I tested this again with someone else and it works.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now