Jump to content

Play Sound


R.y.c.k

Recommended Posts

do not know where I have an error? When it receives hunter should play a song that everybody should hear.

client

local player = nil 
  
function thePlayerReachedHunter() 
    if (player) then 
        dxDrawText("The player ".. tostring(getPlayerName(player)) .." got police car",155.0,549.0,669.0,591.0,tocolor(255,255,255,255,true),1.0,"default-bold","left","top",false,false,false) 
    end 
end 
  
addEvent("disableGhostMode",true) 
addEventHandler("disableGhostMode",root, 
function (thePlayer) 
    player = thePlayer 
    outputChatBox ( "#FFE303The ghostmode will be disabled in 5 seconds ",255,255,255 ,true ) 
    addEventHandler ( "onClientRender", root, thePlayerReachedHunter ) 
    setTimer(function () removeEventHandler ( "onClientRender", root, thePlayerReachedHunter ) end, 5000, 1) 
    setTimer(function () 
        for k,v in ipairs(getElementsByType("vehicle")) do 
            setElementCollidableWith(v, v, true) 
        end 
    end, 5000, 1) 
end) 
  
  
  
function sound (ReachedHunter,PlayerReachedHunter)  
    local sound = playSound("turbo.mp3") sounds folder 
    setSoundVolume(sound, 0.5)  
end 
  
addEventHandler("thePlayerReachedHunter", getLocalPlayer(), sound)  

server

function someoneReachedHunter(number, sort, model) 
    if (sort == "vehiclechange" and model == 821) then 
        triggerClientEvent("playSound",getRootElement(),source) 
    end 
end 
addEvent("onPlayerPickUpRacePickup",true) 
addEventHandler("thePlayerReachedHunter",getRootElement(),playSound) 
  
addEvent("onPlayerPickUpRacePickup",true) 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),someoneReachedHunter) 

Edited by Guest
Link to comment
Guest Guest4401
addEvent("onPlayerPickUpRacePickup",true) 
addEventHandler("onPlayerPickUpRacePickup",root, 
    function(id,ptype,model) 
        if ptype == "vehiclechange" and model == 425 then 
            triggerClientEvent("cPlaySound",root) 
        end 
    end 
) 

addEvent("cPlaySound",true) 
addEventHandler("cPlaySound",root, 
    function() 
        setSoundVolume( 
            playSound("hunter.mp3"), 
            0.5 
        ) 
    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...