Jump to content

[HELP] My playSound is play repeatly


BenceDev

Recommended Posts

Hi, my playSound is played twice and repeatly, but i want to play once and i dont know why this happening.

 

This is my client side script:


local ten = "altitudes/10.wav"
local twenty = "altitudes/20.wav"
local thirty = "altitudes/30.wav"
local fourty = "altitudes/40.wav"
local fifty = "altitudes/50.wav"
local onehund = "altitudes/100.wav"
local twohund = "altitudes/200.wav"
local threhund = "altitudes/300.wav"
local fourhund = "altitudes/400.wav"
local fivehund = "altitudes/500.wav"
local onethounsand = "altitudes/1000.wav"
local onethounsandandfiveh = "altitudes/1500.wav"
local twothoundsandandfiveh = "altitudes/2500.wav"

local targetAltitude = 10


function altitudeSound()
    local sound = playSound("altitudes/1000.mp3", false)
    local x, y, z = getElementPosition(getLocalPlayer())
    local groundY = getGroundPosition(x, y, z)
    local altitude = z - groundY
    
    if (isSoundFinished == true) then
        outputChatBox('Song Finished', 255, 255, 0)
    end
end
addEventHandler("onClientRender", root, altitudeSound)

Thanks for all help!

and this is the original client side script:


local ten = "altitudes/10.wav"
local twenty = "altitudes/20.wav"
local thirty = "altitudes/30.wav"
local fourty = "altitudes/40.wav"
local fifty = "altitudes/50.wav"
local onehund = "altitudes/100.wav"
local twohund = "altitudes/200.wav"
local threhund = "altitudes/300.wav"
local fourhund = "altitudes/400.wav"
local fivehund = "altitudes/500.wav"
local onethounsand = "altitudes/1000.wav"
local onethounsandandfiveh = "altitudes/1500.wav"
local twothoundsandandfiveh = "altitudes/2500.wav"

local targetAltitude = 10


function altitudeSound()
    local sound = playSound("altitudes/1000.wav")
    local x, y, z = getElementPosition(getLocalPlayer())
    local groundY = getGroundPosition(x, y, z)
    local altitude = y - groundY
    
    if altitude >= targetAltitude then
        playSound(sound)
    end
end
addEventHandler("onClientRender", root, altitudeSound)

 

Edited by SphinxDev
Link to comment

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