Jump to content

Pause Sound


BabY

Recommended Posts

yeah, set up a timer which will do isPlayerInVehicle check for every player every 50ms and you're good to go.

seriously, if it is for race mode then:

server:

addEventHandler("onPlayerPickUpRacePickup", getRootElement(), 
function(pID, pType, vID) 
  if pType == "vehiclechange" and vID == 425 then 
    triggerClientEvent(source, "serverSetsSoundPaused", getRootElement(), true)   
  end 
end) 

client:

addEvent("serverSetsSoundPaused", true) 
addEventHandler("serverSetsSoundPaused", getRootElement(),  
function(paused) 
  setSoundPaused(someSoundThatYouHavePlaying, paused) 
end) 

if not for race, onPlayerVehicleEnter event can be used.

Link to comment

Not Working, But Thanks

I Will Make a Marker Then Try to Make it :|

My Script :

if source == Marker3 then --Third Marker 
      markerHitSound() 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 ) 
      setElementRotation (vehicle , 0, 0, 0 ) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 700, 1, vehicle, false ) 
      addEvent("serverSetsSoundPaused", true) 
addEventHandler("serverSetsSoundPaused", getRootElement(),  
function(paused) 
  setSoundPaused(sound1, paused) 
end) 
end 

Link to comment

1. I Want to Make the Sound Stop While Entering a Marker (Not just for Pausing the Sound)

2. Full ACL :

function startclient () 
  outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
  outputChatBox ( " " , 0 , 0 , 0 , true ) 
  outputChatBox ( "#ff0000Happy #0000f0New #00ff002011 #ff00ffYear" , 0 , 0 , 0 , true ) 
  outputChatBox ( " ",0,0,0,true) 
  outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
  setSkyGradient ( 50 , 255 , 0 , 65 , 100 , 0 ) 
  setWaterColor ( 50 , 60 , 70 ) 
  setTime ( 1 , 0 ) 
  setWaveHeight ( 0.5 ) 
  setBlurLevel ( 5 ) 
  setWeather ( 99 ) 
  Marker1 = createMarker ( 4182.88671875, -2876.1853027344, 1062.5003662109, "corona", 7, 0, 0, 255, 200) 
  Marker2 = createMarker ( 4703.38525390, -2239.5251464844, 1609.0306396484, "corona", 10, 255, 55, 55, 200) 
  Marker3 = createMarker ( 4157.51855468, -2296.5871582031, 1111.4150390625, "corona", 9, 50, 50, 255, 100) 
  addEventHandler("onClientMarkerHit", Marker1, warp) 
  addEventHandler("onClientMarkerHit", Marker2, warp) 
  addEventHandler("onClientMarkerHit", Marker3, warp) 
end 
  
function warp(player) 
  if player == getLocalPlayer() and isPedInVehicle(player) then 
    if source == Marker1 then  -- First Marker 
      markerHitSound() 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4154.0571289063, -2392.6955566406, 1608.3810302734 ) 
      setElementRotation (vehicle , 0,0,310.5) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 300, 1, vehicle, false ) 
      setWeather ( 99 ) 
      setTime ( 00 , 0 ) 
      setBlurLevel ( 0 ) 
    elseif source == Marker2 then  -- Second Marker   
      markerHitSound() 
      local sound1 = playSound("data/mario.mp3", true) 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 ) 
      setElementRotation (vehicle , 0, 0, 0 ) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 700, 1, vehicle, false ) 
      setTime ( 00, 0 ) 
      setBlurLevel (20 ) 
      setGameSpeed ( 1.3 ) 
      setWeather ( 99 )        
   
  
function randomVehColors()  --LOOOOOL ... FINALLY I MADE THIS SCRIPT !!!! xDDDD 
  for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
    local color = {} 
    color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126 
    color[2] = math.random(0,126) 
    color[3] = math.random(0,126) 
    color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors 
    setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle 
  end 
end 
  
function loll() -- Mario World 
  setSkyGradient(math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255)) 
  setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
  
function lights() 
  for i,v in pairs (getElementsByType ("vehicle")) do 
    setVehicleHeadLightColor(v, math.random(0,255), math.random(0,255), math.random(0,255)) 
  end 
end 
      setTimer(lights, 850, 0)  
      setTimer(loll, 850, 0) 
      setTimer(randomVehColors, 850, 0) 
end 
if source == Marker3 then --Third Marker 
      markerHitSound() 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 ) 
      setElementRotation (vehicle , 0, 0, 0 ) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 700, 1, vehicle, false ) 
      addEvent("serverSetsSoundPaused", true) 
addEventHandler("serverSetsSoundPaused", getRootElement(),  
function(paused) 
      local soundPause = setSoundPaused(sound1, paused) 
end) 
end 
end 
end 
  
function markerHitSound() 
  local sound2 = playSound("data/warp.mp3") -- Sound Is Working !!! 
end 
  
addEventHandler("onClientResourceStart", resourceRoot, startclient) 

Link to comment
1. I Want to Make the Sound Stop While Entering a Marker (Not just for Pausing the Sound)

FFS, first you said you want sound PAUSED on HUNTER PICKUP, now you want it to stop on marker? wtf?

sound1 = false -- sound will be in this "global" variable 
  
function startclient () 
  outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
  outputChatBox ( " " , 0 , 0 , 0 , true ) 
  outputChatBox ( "#ff0000Happy #0000f0New #00ff002011 #ff00ffYear" , 0 , 0 , 0 , true ) 
  outputChatBox ( " ",0,0,0,true) 
  outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
  setSkyGradient ( 50 , 255 , 0 , 65 , 100 , 0 ) 
  setWaterColor ( 50 , 60 , 70 ) 
  setTime ( 1 , 0 ) 
  setWaveHeight ( 0.5 ) 
  setBlurLevel ( 5 ) 
  setWeather ( 99 ) 
  Marker1 = createMarker ( 4182.88671875, -2876.1853027344, 1062.5003662109, "corona", 7, 0, 0, 255, 200) 
  Marker2 = createMarker ( 4703.38525390, -2239.5251464844, 1609.0306396484, "corona", 10, 255, 55, 55, 200) 
  Marker3 = createMarker ( 4157.51855468, -2296.5871582031, 1111.4150390625, "corona", 9, 50, 50, 255, 100) 
  addEventHandler("onClientMarkerHit", Marker1, warp) 
  addEventHandler("onClientMarkerHit", Marker2, warp) 
  addEventHandler("onClientMarkerHit", Marker3, warp) 
end 
  
function warp(player) 
  if player == getLocalPlayer() and isPedInVehicle(player) then 
    if source == Marker1 then  -- First Marker 
      markerHitSound() 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4154.0571289063, -2392.6955566406, 1608.3810302734 ) 
      setElementRotation (vehicle , 0,0,310.5) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 300, 1, vehicle, false ) 
      setWeather ( 99 ) 
      setTime ( 00 , 0 ) 
      setBlurLevel ( 0 ) 
    elseif source == Marker2 then  -- Second Marker   
      markerHitSound() 
      sound1 = playSound("data/mario.mp3", true) -- creates a sound and place it in global variable sound1  
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 ) 
      setElementRotation (vehicle , 0, 0, 0 ) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 700, 1, vehicle, false ) 
      setTime ( 00, 0 ) 
      setBlurLevel (20 ) 
      setGameSpeed ( 1.3 ) 
      setWeather ( 99 )       
      setTimer(lights, 850, 0) 
      setTimer(loll, 850, 0) 
      setTimer(randomVehColors, 850, 0) 
    elseif source == Marker3 then --Third Marker 
      markerHitSound() 
      if sound1 then stopSound(sound1) end -- stops sound1 on Marker3 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 ) 
      setElementRotation (vehicle , 0, 0, 0 ) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 700, 1, vehicle, false ) 
    end 
  end   
end 
  
function randomVehColors()  --LOOOOOL ... FINALLY I MADE THIS SCRIPT !!!! xDDDD 
  for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
    local color = {} 
    color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126 
    color[2] = math.random(0,126) 
    color[3] = math.random(0,126) 
    color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors 
    setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle 
  end 
end 
  
function loll() -- Mario World 
  setSkyGradient(math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255)) 
  setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
  
function lights() 
  for i,v in pairs (getElementsByType ("vehicle")) do 
    setVehicleHeadLightColor(v, math.random(0,255), math.random(0,255), math.random(0,255)) 
  end 
end 
  
function markerHitSound() 
  local sound2 = playSound("data/warp.mp3") -- Sound Is Working !!! 
end 
  
addEventHandler("onClientResourceStart", resourceRoot, startclient) 
  
addEvent("serverSetsSoundPaused", true) 
addEventHandler("serverSetsSoundPaused", getRootElement(), 
function(paused) 
  setSoundPaused(sound1, paused) 
end) 

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