Jump to content

[Help] Voice Chat


Recommended Posts

38 minutes ago, MrLoKi said:

Hello Guys !

How To Mute Voice Player In Loading MTA ??

I want to not hear the player sound when the player enters the server in the download and upload resources section

hello @MrLoKi welcome the forum , I have prepared a piece of code for your question, I hope it will be useful for you, I did not test it, if you have a problem or in a different way, let me know, I will help you

function onClientResourceStart()
  -- get all the players in the server
  local players = getElementsByType("player")
  for i, player in ipairs(players) do
    -- mute the player's voice
    setPlayerVoiceIgnoreFrom(player, root, true)
  end
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onClientResourceStart)

 

Link to comment

This is a server-side function and generally does not work

function Joined()
    local players = getElementsByType("player")
    for i, player in ipairs(players) do
      setPlayerVoiceIgnoreFrom(player, source, true)
    end
end
addEventHandler("onPlayerJoin",getRootElement(),Joined)

 

 

Link to comment
2 hours ago, MrLoKi said:

This is a server-side function and generally does not work

function Joined()
    local players = getElementsByType("player")
    for i, player in ipairs(players) do
      setPlayerVoiceIgnoreFrom(player, source, true)
    end
end
addEventHandler("onPlayerJoin",getRootElement(),Joined)

 

 

function onClientPlayerJoin()
  -- Get the player element that just joined
  local joinedPlayer = source
  
  -- Mute the new player's voice for the local player
  setPlayerVoiceIgnore(joinedPlayer, true)
end
addEventHandler("onClientPlayerJoin", getRootElement(), onClientPlayerJoin)

 

Link to comment
On 06/05/2023 at 17:16, Shady1 said:
function onClientPlayerJoin()
  -- Get the player element that just joined
  local joinedPlayer = source
  
  -- Mute the new player's voice for the local player
  setPlayerVoiceIgnore(joinedPlayer, true)
end
addEventHandler("onClientPlayerJoin", getRootElement(), onClientPlayerJoin)

 

The only way this would work is if download priority was set higher for the resource with this code, otherwise this code won't execute until everything downloads and thus voice will be heard until download completes.

  • Like 1
Link to comment
45 minutes ago, Addlibs said:

The only way this would work is if download priority was set higher for the resource with this code, otherwise this code won't execute until everything downloads and thus voice will be heard until download completes.

Thank you for your comment but I just posted an example code, if the player expects more code support from me, just let me know and I'm ready to give more support to the players.

  • Confused 1
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...