Jump to content

when player get mute


Recommended Posts

Posted

hi guyz i want script that let other player see the muted player with tag on his head that write [Muted]

for example

PiHmjae.png

if there is ready recourse please give me i search on google but i didn't fine any thing

Posted (edited)

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
Posted

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

Posted
-- 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 ?

Posted
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

Posted

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) 

Posted
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

Posted
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

Posted

-.- Why don't you try it by yourself? Use command in-game:

/debugscript 3

and give us the errors as soon as you start the resource if any.

Posted
-.- Why don't you try it by yourself? Use command in-game:

/debugscript 3

and give us the errors as soon as you start the resource if any.

when i give 1 player mute. they all the player in server get that [muted] on them heads

Posted
Change this:
if getElementData(localPlayer,"playermuted") == 1 then 

to:

if getElementData(v,"playermuted") == 1 then 

very good and thx

but when i do unmute the write [muted] still on the player head not removed

Posted

---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) 
Posted
Max+, that's useless. When she/he gets muted again it will not run.

he can use a timer to check

isPlayerMuted 

then addEvent Back .

if not isPlayerMuted then 
---remove it again  
Posted
---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

Posted

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

Posted
Max+, that's useless. When she/he gets muted again it will not run.

he can use a timer to check

isPlayerMuted 

then addEvent Back .

if not isPlayerMuted then 
---remove it again  

sorry but when to add that

if not isPlayerMuted then 
---remove it again 

Posted
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) 

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