• Player Mute on Scoreboard + "PlayerSay" Issues
    4 replies, posted
Hey, I'm trying to make a mute button on my scoreboard and whilst the icon for it appears, clicking it leads to no results, this is my current code: local isMuted local mute = panel:Add("DImageButton")       mute:SetSize(16,16)       mute:SetPos( scoreboard:GetWide() - 100, h / 2 - 8 )       mute.DoClick = function()         if v:IsMuted() then           v:SetMuted(false)           isMuted = false           chat.AddText('UNMUTED')         else           v:SetMuted(true)           isMuted = true           chat.AddText('MUTED')         end       end       function panel:Think()         if isMuted then           mute:SetImage( "icon32/muted.png" )         elseif !isMuted then           mute:SetImage( "icon32/unmuted.png" )         end       end Also unrelated and just a general question... I currently have name commands "!name x y currentdarkrpname" which sets the players name to the x, y value and their current name, however when it tries to get their name it gets a random players on the server (only tested this with me and a friend, and it tends to pick up the opposite persons name) could this be because it's inside a "PlayerSay" hook and not a "OnPlayerChat" hook? Getting darkrp name like so: local darkRPName = ply:Nick(); Sorry if these are stupid questions, still trying to learn glua.
Where are you getting the variable v from in your panel? Hard to tell you without seeing the full scope of your code.
Here's more code. Was meaning to update the original post with more.. but forgot as I was in a rush earlier. if !CLIENT then   return end local scoreboard local isMuted local function CreateScoreboard()   scoreboard = vgui.Create("DFrame")   scoreboard:SetSize(ScrW() - 400, ScrH() - 200)   scoreboard:Center()   scoreboard:SetTitle("")   scoreboard:SetDraggable(false)   scoreboard:MakePopup()   scoreboard:ShowCloseButton(false)   scoreboard:SetKeyboardInputEnabled(false)   scoreboard.Paint = function(self, w, h)     surface.SetDrawColor(25, 34, 43,255)     surface.DrawRect(0, 0, 15, scoreboard:GetTall())     surface.DrawRect(0, 0, scoreboard:GetWide(), 125)     surface.DrawRect(0, ScrH() - 215, scoreboard:GetWide(), 15)     surface.DrawRect(ScrW() - 415, 0, 15, scoreboard:GetTall())     surface.SetDrawColor(25, 34, 43,230)     surface.DrawRect(15, 125, scoreboard:GetWide() - 15, scoreboard:GetTall() - 125)   end   local scrollpanel = scoreboard:Add("DScrollPanel")   scrollpanel:SetPos(15, 125)   scrollpanel:SetSize(scoreboard:GetWide() - 20 + 6, scoreboard:GetTall() - 140)   scoreboard.Update = function()     scrollpanel:Clear()     for k, v in pairs(player.GetAll()) do       local panel = scrollpanel:Add("DPanel")       panel:SetSize(scrollpanel:GetWide() - 16, 36)       panel:SetPos(0, k * 37 - 37)       panel.Paint = function(self, w, h)       if not v:IsValid() then         scoreboard:Update()         return       end       local mute = panel:Add("DImageButton")       mute:SetSize(16,16)       mute:SetPos( scoreboard:GetWide() - 100, h / 2 - 8 )       mute.DoClick = function()         if v:IsMuted() then           v:SetMuted(false)           isMuted = false           chat.AddText('UNMUTED')         else           v:SetMuted(true)           isMuted = true           chat.AddText('MUTED')         end       end       function panel:Think()         if isMuted then           mute:SetImage( "icon32/muted.png" )         elseif !isMuted then           mute:SetImage( "icon32/unmuted.png" )         end       end     end   end end   scoreboard:Update() end hook.Add("ScoreboardShow", "DarkRP.custom.scoreboard.show", function()     if not (scoreboard == nil) then         scoreboard:Update()         scoreboard:SetVisible(true)     else         CreateScoreboard()     end end) hook.Add("ScoreboardHide", "DarkRP.custom.scoreboard.hide", function()     if (scoreboard) then         scoreboard:SetVisible(false)     end end)
local MuteButt = vgui.Create( "DButton", panel) MuteButt:SetText( "" ) MuteButt.DoClick = function() v:SetMuted( !v:IsMuted() ) end MuteButt.Paint = function( self, w, h) draw.RoundedBox( 0, 0, 0, w, h, Color(255,255,255,255) ) end local muteIMG = vgui.Create( "DImage", MuteButt ) muteIMG.img = "icon32/unmuted.png" muteIMG:SetPos( MuteButt:GetPos() ) muteIMG:SetSize( MuteButt:GetSize() ) muteIMG:SetImage( "icons32/unmuted.png" ) muteIMG.Think = function( self, w, h ) if !IsValid(v) then return end if v:IsMuted() then self.img = "icon32/muted.png" else self.img = "icon32/unmuted.png" end self:SetImage( self.img ) end Hope this clears things up!
Nope, unfortunately that doesn't work. Thanks for trying though (No logs in console so cant see the reason... nothing happens when clicked)
Sorry, you need to Log In to post a reply to this thread.