Jump to content

when player get mute


Recommended Posts

Posted (edited)
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 put it in the clinet?

Edited by Guest
Posted

See what you do by just posting a finished, more or less working script?

People make more topics and expect to get a working script again.

You should ask yourself if you wanna help people or just show off with your "skills".

Posted

Try this ,

---ClientSide

function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      tx, ty, tz = getElementPosition( localPlayer ) 
         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( localPlayer, 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 
                              
                                dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                                 
                         end 
                    end 
               end 
    
    end 
                 
                 
 addEvent ( 'Show', true ) 
 addEventHandler ('Show', root, 
 function ( ) 
  addEventHandler("onClientRender",root,testing) 
 end 
) 
  
 addEvent ( 'Remove', true ) 
 addEventHandler ('Remove', root, 
 function ( ) 
  removeEventHandler ("onClientRender",root,testing) 
 end 
) 

---ServerSide

addEventHandler("onPlayerUnmute",root, 
function ( ) 
    triggerClientEvent ( source, 'Remove', source ) 
  end 
) 
  
addEventHandler("onPlayerMute",root, 
function ( ) 
    triggerClientEvent ( source, 'Show', source ) 
  end 
) 
Posted
Try this ,

---ClientSide

function testing() 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      tx, ty, tz = getElementPosition( localPlayer ) 
         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( localPlayer, 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 
                              
                                dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                                 
                         end 
                    end 
               end 
    
    end 
                 
                 
 addEvent ( 'Show', true ) 
 addEventHandler ('Show', root, 
 function ( ) 
  addEventHandler("onClientRender",root,testing) 
 end 
) 
  
 addEvent ( 'Remove', true ) 
 addEventHandler ('Remove', root, 
 function ( ) 
  removeEventHandler ("onClientRender",root,testing) 
 end 
) 

---ServerSide

addEventHandler("onPlayerUnmute",root, 
function ( ) 
    triggerClientEvent ( source, 'Remove', source ) 
  end 
) 
  
addEventHandler("onPlayerMute",root, 
function ( ) 
    triggerClientEvent ( source, 'Show', source ) 
  end 
) 

not working. i started the resores and i give mute to any player then its not working

Posted

Like I said before, I tested it in my server. For some kind of reason, it's not setting the data with 'setElementData' on the player. It does by event 'onPlayerMute', but it doesn't do it by event 'onPlayerUnmute'. Still, the code 'setElementData' does return 'true', which means it was set. I checked it with a command handler, but it doesn't change at all. I would guess it's a bug in event 'onPlayerUnmute', but I'm not sure. I will try something different now.

Posted

Server-Side:

function muteHandler() 
    local mutedPlayers = {} 
    for placeNumber, playerData in ipairs(getElementsByType("player")) do 
        if (isPlayerMuted(playerData) == true) then 
            table.insert(mutedPlayers, playerData) 
        end 
    end 
    triggerClientEvent("onServerSendMutedPlayers", getRootElement(), mutedPlayers) 
end 
  
addEventHandler("onPlayerMute", getRootElement(), muteHandler) 
addEventHandler("onPlayerUnmute", getRootElement(), muteHandler) 

"

Client-Side:

mutedPlayers = {} 
  
function receiveMutedPlayers(gMutedPlayers) 
    mutedPlayers = gMutedPlayers 
end 
  
addEvent("onServerSendMutedPlayers", true) 
addEventHandler("onServerSendMutedPlayers", getRootElement(), receiveMutedPlayers) 
  
function testing() 
    local px, py, pz, tx, ty, tz, dist 
    px, py, pz = getCameraMatrix( ) 
    for placeNumber, playerData in ipairs(mutedPlayers) do 
        tx, ty, tz = getElementPosition( playerData ) 
        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( playerData, 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 
                    dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                end 
            end 
        end 
    end 
end 
  
addEventHandler("onClientRender",root,testing) 

Only thing I could think of to 'solve' it.

EDIT: I did some tests, and as soon as you put event 'onPlayerMute' in the same resource as where event 'onPlayerUnmute' is, then it doesn't set the element data anymore. So I will report it.

Posted
Server-Side:
function muteHandler() 
    local mutedPlayers = {} 
    for placeNumber, playerData in ipairs(getElementsByType("player")) do 
        if (isPlayerMuted(playerData) == true) then 
            table.insert(mutedPlayers, playerData) 
        end 
    end 
    triggerClientEvent("onServerSendMutedPlayers", getRootElement(), mutedPlayers) 
end 
  
addEventHandler("onPlayerMute", getRootElement(), muteHandler) 
addEventHandler("onPlayerUnmute", getRootElement(), muteHandler) 

"

Client-Side:

mutedPlayers = {} 
  
function receiveMutedPlayers(gMutedPlayers) 
    mutedPlayers = gMutedPlayers 
end 
  
addEvent("onServerSendMutedPlayers", true) 
addEventHandler("onServerSendMutedPlayers", getRootElement(), receiveMutedPlayers) 
  
function testing() 
    local px, py, pz, tx, ty, tz, dist 
    px, py, pz = getCameraMatrix( ) 
    for placeNumber, playerData in ipairs(mutedPlayers) do 
        tx, ty, tz = getElementPosition( playerData ) 
        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( playerData, 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 
                    dxDrawText( "Muted", x, y, x, y, tocolor(r, g, b), scale + ( 15 - dist ) * 0.02, "bankgothic" ) 
                end 
            end 
        end 
    end 
end 
  
addEventHandler("onClientRender",root,testing) 

Only thing I could think of to 'solve' it.

EDIT: I did some tests, and as soon as you put event 'onPlayerMute' in the same resource as where event 'onPlayerUnmute' is, then it doesn't set the element data anymore. So I will report it.

thx verry much i would like to thank u verry verry much 100% work

:fadein::fadein::fadein::fadein::fadein::fadein::fadein::fadein::fadein::fadein::fadein::fadein::fadein:

thank you

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