Jump to content

Sound script not working


Xwad

Recommended Posts

local sound 
setTimer(function() 
    if isPedDead(localPlayer) then return end 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if vehicle and getElementModel(vehicle) ~= 476 then 
        local vx,vy,vz = getElementVelocity(vehicle) 
        if vx+vy+vz == 0 then 
            if sound then 
                  setSoundPaused(sound,true) 
            end 
        else 
            if not sound then 
                sound = playSound("sounds/sound.mp3") 
                setSoundVolume(sound, 0.1) 
                        else 
                                setSoundPaused(sound,false) 
            end 
        end 
    elseif sound then 
        setSoundPaused(sound,true) 
    end 
end,1000,0) 
  
function stopSound() 
setSoundPaused(sound, true) 
end 
addEventHandler("onClientPlayerWasted", root, stopSound) 

Link to comment
local sound 
setTimer(function() 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if vehicle and getElementModel(vehicle) ~= 476 then 
        local vx,vy,vz = getElementVelocity(vehicle) 
        if vx+vy+vz == 0 then 
            if sound then 
                  setSoundPaused(sound,true) 
            end 
        else 
            if not sound then 
                sound = playSound("sounds/sound.mp3") 
                setSoundVolume(sound, 0.1) 
            else 
                setSoundPaused(sound,false) 
            end 
        end 
    elseif sound then 
        setSoundPaused(sound,true) 
    end 
end,1000,0) 
  
--anonymous function attached to you 
addEventHandler("onClientPlayerWasted", localPlayer, function() 
    if isElement(sound) then 
        setSoundPaused(sound, true) 
    end 
end) 

Link to comment

shit its bugging again!! I play and after a few minutes the sound dont works anymore and this is the debug script: WARNING: sound/client.lua:9 Bad 'sound/player' pointer @ 'setSoundPaused'(1)

and if i press w then it says

WARNING: sound/client.lua:16 Bad 'sound/player' pointer @ 'setSoundPaused'(1)

pls help!

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