Jump to content

Sound For Cops. Need help.


Panda

Recommended Posts

Hello everyone, Sorry for disturbing you, but I made a new script when a crim enter to a col A sound will play, but it play for the whole server,i want it to be play only for cops. This is my script,

function PlayMusic(element,sound) 
    if element  and getElementType(element) == "player" then 
        local team = getPlayerTeam(element) 
        if team and not (copTeams[getTeamName(team)]) then -- the player who entered jail area isn't a cop                   
                triggerClientEvent("playMyMusic", getRootElement(), copTeams)              
end 
end 
end 
addEventHandler("onColShapeLeave", prisonCol, PlayMusic) 

As you can see when a crim hits the col the sound will play, but when the cop hits the col nothing will happen, the problem is that i want to lock the sound to copTeams only. I really need help, thanks for reading. Cheers.

Link to comment
  
  
function PlayMusic(element,sound) 
    if element  and getElementType(element) == "player" then 
        local team = getPlayerTeam(element) 
        if team --[[and not (copTeams[getTeamName(team)])]] then -- the player who entered jail area isn't a cop                  
                triggerClientEvent("playMyMusic", getRootElement(), copTeams)             
end 
end 
end 
addEventHandler("onColShapeLeave", prisonCol, PlayMusic) 
  

Link to comment

try this

function PlayMusic(element,sound) 
    if element  and getElementType(element) == "player" then 
        local team = getPlayerTeam(element) 
        if team  then 
local cops = getPlayersInTeam(team)      
                triggerClientEvent(cops,"playMyMusic", element, copTeams)             
end 
end 
end 
addEventHandler("onColShapeLeave", prisonCol, PlayMusic) 

or

function PlayMusic(element,sound) 
    if element  and getElementType(element) == "player" then 
        local team = getPlayerTeam(element) 
        if team and team == "cops"  then 
     
                triggerClientEvent(element,"playMyMusic", element, copTeams)             
end 
end 
end 
addEventHandler("onColShapeLeave", prisonCol, PlayMusic) 

Link to comment

nope still..

function PlayMusic(element,sound) 
    if element  and getElementType(element) == "player" then 
        local team = getPlayerTeam(element) 
        if team and not (copTeams[getTeamName(team)])]] then -- the player who entered jail area isn't a cop                 
                triggerClientEvent("playMyMusic", getRootElement(), copTeams)             
end 
end 
end 
addEventHandler("onColShapeLeave", prisonCol, PlayMusic) 

It should be like this one .. When the cops hit the marker nothing will play but when a crim hits the marker it will play, the problem is the sound plays for all the server, everyone can hear it, i just want to lock the sound to cops..

Help please, thanks.

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