Jump to content

[H.E.L.P]playSound repeating endlessly


#RooTs

Recommended Posts

Posted
sorry, more I did not understand
local hb_Image = "files/2/hb.png" 

where's dxDrawImage? :o:o

Storing the path in a variable instead.

dxDrawImage(x*960+x2, y*470+y2, 306, 232, hb_Image, 0,0,0, tocolor(255, 255, 255 , 255)) 

would be the same as

dxDrawImage(x*960+x2, y*470+y2, 306, 232, "files/2/hb2.png", 0,0,0, tocolor(255, 255, 255 , 255)) 

Posted

@ALw7sH, I tested your code that is simpler, and when he gets precionado he repeats the sound.

the same with the function to lock the car doors

if ( enablelock ) and ( isVehicleLocked( theVehicle ) ) 

when the car is with the door locked he repeats the sound

I did not know is that complicated :?:?:?

Posted

@Dealman, Your example is very complicated. I know how to work with variables, more, where add, the

dxDrawImage(....... 

which line?

Posted (edited)
local sx,sy = guiGetScreenSize() 
local px,py = 1280,720 
local x,y =  (sx/px), (sy/py) 
local handbrake = false 
  
local x2, y2, x3, y3 = 0, 0, 0, 0 
local playing = false -- set to false 
function speed() 
local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
    if ( theVehicle ) then 
        if ( getControlState ( "handbrake" )  ) then 
            dxDrawImage(x*960+x2, y*470+y2, 306, 232, "files/2/hb2.png", 0,0,0, tocolor(255, 255, 255 , 255)) 
            if ( handbrake == false ) then 
                handbrake = playSound("files/handbrake.wav") 
                handbrake = true 
            end 
        else 
            dxDrawImage(x*960+x2, y*470+y2, 306, 232, "files/2/hb.png", 0,0,0, tocolor(255, 255, 255 , 255)) 
        end 
    end 
end 
addEventHandler ( "onClientRender", root, speed ) 
  
addEventHandler("onClientSoundStopped",root, 
function() 
    if source == handbrake then 
    handbrake = false 
    end 
end 
) 

Edited by Guest
Posted
Do you mean that you want the sound start every time he press break?

If yes then why you are using onClientRender

I do not know another way to do this :?

Posted

You tried this?

function checkHand( key, keyState) 
local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
    if ( theVehicle ) then 
      --outputChatBox("you press space brake") 
      playSound("files/handbrake.wav") 
    end 
end 
bindKey ( "handbrake", "down", checkHand ) 

Posted
You tried this?
function checkHand( key, keyState) 
local theVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) 
    if ( theVehicle ) then 
      --outputChatBox("you press space brake") 
      playSound("files/handbrake.wav") 
    end 
end 
bindKey ( "handbrake", "down", checkHand ) 

Worked, thanks.

more passenger pressure, and makes the sound.

how to check if I'm passenger and not make the sound?, what is the function?

Posted
bindKey("handbrake", "down", 
function() 
    local theVehicle = getPedOccupiedVehicle(localPlayer) 
    if theVehicle and getVehicleController(theVehicle) == localPlayer then 
        --outputChatBox("you press space brake") 
        playSound("files/handbrake.wav") 
    end 
end) 

Posted

@TAPL, perfect. my problem now is no longer the case bindkey. because when I turn on the light he has to make a sound

if ( enablelight ) and ( getVehicleOverrideLights ( theVehicle ) ~= 2 ) then 
dxDrawImage.. 
playSound("files/lightswitch.mp3") 
else 
dxDrawImage 
end 
  

OBS: the lighthouse is connected by freeroam panel.

what function to use for this type of bindkey?

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