Jump to content

when player get mute


Recommended Posts

Use the following functions:

-- Event: onPlayerMute, onPlayetUnmute 
-- to check if the player is muted on the client side: 
setElementData 
getElementData 
-- for drawing: 
getElementPosition 
getWorldFromScreenPosition 
dxDrawText 
-- event: onClientPreRender 

Edited by Guest
Link to comment

-- CLIENT SIDE

  
function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 32.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) 
               local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) 
               local r,g,b = getPlayerNametagColor(localPlayer) 
               scale = 0.65 
               if x then 
                  if getElementData(localPlayer,"playermuted") == 1 then 
                     dxDrawText( "Muted", x, y, x, y, tocolor(rr, gg, bb), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
               end 
            end 
         end 
      end 
   end 
end 
addEventHandler("onClientRender",root,testing) 

-- SERVER SIDE

function isMuted() 
   if isPlayerMuted(source) then 
      setElementData(source,"playermuted",1) 
   else 
      setElementData(source,"playermuted",0) 
   end 
end 
setTimer(isMuted,500,0,source) 
addEventHandler("onPlayerJoin",root,isMuted) 

-- META

  

this should work

Link to comment
-- CLIENT SIDE
  
function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 32.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) 
               local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) 
               local r,g,b = getPlayerNametagColor(localPlayer) 
               scale = 0.65 
               if x then 
                  if getElementData(localPlayer,"playermuted") == 1 then 
                     dxDrawText( "Muted", x, y, x, y, tocolor(rr, gg, bb), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
               end 
            end 
         end 
      end 
   end 
end 
addEventHandler("onClientRender",root,testing) 

-- SERVER SIDE

function isMuted() 
   if isPlayerMuted(source) then 
      setElementData(source,"playermuted",1) 
   else 
      setElementData(source,"playermuted",0) 
   end 
end 
setTimer(isMuted,500,0,source) 
addEventHandler("onPlayerJoin",root,isMuted) 

-- META

  

this should work

great gop but when i test it not working ?

Link to comment
function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 32.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) 
               local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) 
               local r,g,b = getPlayerNametagColor(localPlayer) 
               scale = 0.65 
               if x then 
                  if getElementData(localPlayer,"playermuted") == 1 then 
                     dxDrawText( "Muted", x, y, x, y, tocolor(rr, gg, bb), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
               end 
            end 
         end 
      end 
   end 
end 
addEventHandler("onClientRender",root,testing) 

on line 15. can i change the color?

and if there any problem please tell me

Link to comment

server

function isMuted() 
      setElementData(source,"playermuted",1) 
end 
addEventHandler("onPlayerMute",root,isMuted) 
  
function isNotMuted() 
setElementData(source,"playermuted",0) 
end 
addEventHandler("onPlayerUnmute",root,isNotMuted) 

client

function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 32.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) 
               local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) 
               local r,g,b = getPlayerNametagColor(localPlayer) 
               scale = 0.65 
                     if x then 
                          if getElementData(localPlayer,"playermuted") == 1 then 
                                dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                  end 
                    end 
               end 
          end 
     end 
end 
addEventHandler("onClientRender",root,testing) 

Link to comment
server
function isMuted() 
      setElementData(source,"playermuted",1) 
end 
addEventHandler("onPlayerMute",root,isMuted) 
  
function isNotMuted() 
setElementData(source,"playermuted",0) 
end 
addEventHandler("onPlayerUnmute",root,isNotMuted) 

client

function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 32.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) 
               local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) 
               local r,g,b = getPlayerNametagColor(localPlayer) 
               scale = 0.65 
                     if x then 
                          if getElementData(localPlayer,"playermuted") == 1 then 
                                dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                  end 
                    end 
               end 
          end 
     end 
end 
addEventHandler("onClientRender",root,testing) 

testing

Link to comment
server
function isMuted() 
      setElementData(source,"playermuted",1) 
end 
addEventHandler("onPlayerMute",root,isMuted) 
  
function isNotMuted() 
setElementData(source,"playermuted",0) 
end 
addEventHandler("onPlayerUnmute",root,isNotMuted) 

client

function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 32.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) 
               local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) 
               local r,g,b = getPlayerNametagColor(localPlayer) 
               scale = 0.65 
                     if x then 
                          if getElementData(localPlayer,"playermuted") == 1 then 
                                dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                  end 
                    end 
               end 
          end 
     end 
end 
addEventHandler("onClientRender",root,testing) 

sorry but still not working

Link to comment

---ClientSide

function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 32.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) 
               local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) 
               local r,g,b = getPlayerNametagColor(localPlayer) 
               scale = 0.65 
                     if x then 
                          if getElementData(v,"playermuted") == 1 then 
                                dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                                elseif getElementData(v,"playermuted") == 0 then 
                                setTimer(function() removeEventHandler ("onClientRender",root,testing) end, 1000, 1) 
                         end 
                    end 
               end 
          end 
     end 
  end 
addEventHandler("onClientRender",root,testing) 
Link to comment
---ClientSide

function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 32.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) 
               local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) 
               local r,g,b = getPlayerNametagColor(localPlayer) 
               scale = 0.65 
                     if x then 
                          if getElementData(v,"playermuted") == 1 then 
                                dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                                elseif getElementData(v,"playermuted") == 0 then 
                                setTimer(function() removeEventHandler ("onClientRender",root,testing) end, 1000, 1) 
                         end 
                    end 
               end 
          end 
     end 
  end 
addEventHandler("onClientRender",root,testing) 

still not working. i give unmute and it still not removed the i give mut 1 min and wait 1 min same not removed

Link to comment

Tested it in my server. Everything is fine, but it seems that this is not setting the data, but it does return 'true':

function isNotMuted() 
lol = setElementData(source,"playermuted",0) 
outputChatBox(tostring(lol)) 
end 
addEventHandler("onPlayerUnmute",root,isNotMuted) 

I guess a... bug? o.O

Link to comment
Tested it in my server. Everything is fine, but it seems that this is not setting the data, but it does return 'true':
function isNotMuted() 
lol = setElementData(source,"playermuted",0) 
outputChatBox(tostring(lol)) 
end 
addEventHandler("onPlayerUnmute",root,isNotMuted) 

I guess a... bug? o.O

where to add that function on client.lua

function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 32.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.30 ) 
               local x1,y1 = getScreenFromWorldPosition( sx, sy, sz + 0.35 ) 
               local r,g,b = getPlayerNametagColor(localPlayer) 
               scale = 0.65 
                     if x then 
                          if getElementData(v,"playermuted") == 1 then 
                                dxDrawText( "[Muted]", x, y, x, y, tocolor(255, 0, 0), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                                elseif getElementData(v,"playermuted") == 0 then 
                                setTimer(function() removeEventHandler ("onClientRender",root,testing) end, 1000, 1) 
                         end 
                    end 
               end 
          end 
     end 
  end 
addEventHandler("onClientRender",root,testing) 

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