xRGamingx Posted May 30, 2018 Share Posted May 30, 2018 Hello friends, Because the mute time does not fade ? ? If I give 1 minute mute, the time stays at 60000.. 1 minute = 60000 Milliseconds --Client--- local muteTime = 0 local timerMute = nil local mute = false function drawMuteTime( ) local screenW, screenH = guiGetScreenSize() if muteTime > 0 and mute == true then -----------162 LINE-------- dxDrawText("Muted time: "..muteTime, screenW * 0.0078, screenH * 0.6094, screenW * 0.2727, screenH * 0.6484, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) end end addEventHandler( "onClientRender", root, drawMuteTime ) addEvent( "mute:mutePlayer" ) addEventHandler( "mute:mutePlayer", getRootElement( ), function( time ) mute = true if timerMute then timerMute = nil end timerMute = setTimer( function( ) muteTime = 0 mute = false end, time, 1) muteTime = math.floor(getTimerDetails( timerMute )) end ) addEvent( "mute:unMutePlayer" ) addEventHandler( "mute:unMutePlayer", getRootElement( ), function( ) muteTime = 0 mute = false end ) --------------- ----Server function mute (player, time, rz) local times = getRealTime () local day = times.monthday local mes = times.month local yea = times.year local sec = times.second local min = times.minute local hou = times.hour local el = getPlayerFromName (player) local ad = getPlayerName (source) if el and rz then if time and tonumber(time) ~= nil then if getElementData(el, "Lv") <= getElementData(source, "Lv") then if not isPlayerMuted (el) then setPlayerMuted (el, true) local respeto = getPedStat (el, 64) setPedStat (el, 64, respeto-15) if not isGuestAccount (getPlayerAccount(el)) then executeSQLQuery("INSERT INTO Punish (Date, Element, Admin, Time, Reason) VALUES ('["..hou..":"..min..":"..sec.."("..day.."/"..(mes+1).."/"..yea..")]', '"..getAccountName(getPlayerAccount(el)).."', '"..ad.."', '"..time.." Min', '[Mute]"..rz.."')") end outputChatBox (ad.." Muted to "..player.." "..tonumber(time).." Min by: ("..rz..").", root, 255, 0, 0) setElementData (el, "NGtimeMute", time) setElementData(el,"NGGangMute",true) outputDebugString (ad.." Muted to "..player.." "..tonumber(time).." Min by: ("..rz..").") setTimer (desmutar, time*60*1000, 1, el) triggerClientEvent( el, "mute:mutePlayer", el, time*60*1000 ) else setPlayerMuted (el, false) setElementData(el,"NGGangMute",false) outputChatBox (ad.." Break to "..player, root, 255, 0, 0) outputDebugString (ad.." Break to "..player) setElementData (source, "NGTimeMute", 0) end else --outputChatBox (".", source, 255, 0, 0) end end else".", source, 255, 0,0) end end addEvent ("mute", true) addEventHandler ("mute", root, mute) function desmutar (player) if player and isElement(player) then if isPlayerMuted(player) then setPlayerMuted (player, false) setElementData (player, "NGTiempoMute", 0) triggerClientEvent( player, "mute:unMutePlayer", player ) outputChatBox (getPlayerName(player).."(FinISH del Mute)", root, 0, 255, 0) outputDebugString (getPlayerName(player).." It was desmutado (Finish Mute)") end end end -------------------------------------------------------------------------------- Mute Evade Fix addEventHandler ("onPlayerQuit", root, function () if not isGuestAccount(getPlayerAccount(source)) then if isPlayerMuted (source) then setAccountData (getPlayerAccount(source), "NGMuteEvade", getElementData(source, "NGtimeMute")) else setAccountData (getPlayerAccount(source), "NGMuteEvade", 0) end end end) addEventHandler ("onPlayerLogin", root, function () local ismute = getAccountData (getPlayerAccount(source), "NGMuteEvade") if ismute then if tonumber(ismute) >= 1 then setPlayerMuted(source, true) setElementData (source, "NGtimeMute", ismute) setTimer (desmutar, ismute*60*1000, 1, source) triggerClientEvent( el, "mute:mutePlayer", el, ismute*60*1000 ) outputChatBox ("[Console] Muted to "..getPlayerName(source).." "..ismute.." Min by: (Evade the Last Mute).", root, 255, 0, 0) end end end) Link to comment
DNL291 Posted May 30, 2018 Share Posted May 30, 2018 Because you're using getTimerDetails once and outside the drawMuteTime function. Link to comment
xRGamingx Posted May 30, 2018 Author Share Posted May 30, 2018 23 minutes ago, DNL291 said: Because you're using getTimerDetails once and outside the drawMuteTime function. And how would it be then in this case? Link to comment
DNL291 Posted May 30, 2018 Share Posted May 30, 2018 (edited) 8 minutes ago, xRGamingx said: And how would it be then in this case? local screenW, screenH = guiGetScreenSize() function drawMuteTime( ) if not timerMute then return end local getMuteTimerDetails = math.floor(getTimerDetails( timerMute )) -- here if getMuteTimerDetails > 0 and mute == true then -----------162 LINE-------- dxDrawText("Muted time: "..tostring(getMuteTimerDetails), screenW * 0.0078, screenH * 0.6094, screenW * 0.2727, screenH * 0.6484, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) end end addEventHandler( "onClientRender", root, drawMuteTime ) Edited May 30, 2018 by DNL291 Link to comment
xRGamingx Posted May 30, 2018 Author Share Posted May 30, 2018 error > local getMuteTimerDetails = math.floor(getTimerDetails( timerMute )) -- here Link to comment
DNL291 Posted May 30, 2018 Share Posted May 30, 2018 Remove "onClientRender" event from the code, edit the event "mute:mutePlayer" and add there addEventHandler (" onClientRender ", root, drawMuteTime) at the end of the function. Also, use removeEventHandler to remove the text when the time runs out. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now