Sign in to follow this  
Gastonito

Mute

Recommended Posts

So, hey guys.

I've been working on a staff panel lately, its like a panel for trial admins. There is Something that i couldnt do :/ This is the panel :

Quote

1LXMV9C.jpg

I've made all the functions except one, the mute thing, i didnt know how to do it, so can you help me with it ? I could only do the gui thing, here is it : https://pastebin.com/fpPpuryw

I will appreciate it alot if you do the whole thing for me :D

Edited by Gastonito

Share this post


Link to post

Shouldn't it be similar to the Kick one? I can't do code cuz it's 7am and I'm in bed but...

1. You click a player name in a grid in your panel.

2. You use 'getPlayerFromPartialName' to get the player with that nickname. Remember: this is a useful function so you need it's code from the wiki before using it. 

3. Then you do 'setPlayerMuted' on the guy you just found in step 2.

Share this post


Link to post

Usually we won't make the whole script for you, we help with errors, and give instructions. Try to do it yourself, and if you happen to be stuck, ask here.

Share this post


Link to post
2 hours ago, NeXuS™ said:

Usually we won't make the whole script for you, we help with errors, and give instructions. Try to do it yourself, and if you happen to be stuck, ask here.

This is what i could do :

server side :

addEvent( "onPlayerMuteClient", true )

		local function handle_mute( thePlayer, theTime )
			if ( ( thePlayer ) and ( theTime or 0 ) ) then
				theTime = theTime or 480000
				setPlayerMuted( thePlayer, true )
				setTimer( function( thePlayer ) setPlayerMuted( thePlayer, false ) end, theTime, 1, thePlayer )
			end
		end
	-- EVENT HANDLERS
		addEventHandler( "onPlayerMuteClient", root, handle_mute )

Client side :

if source == mywind[18] then 
	nameplayermute = guiGridListGetItemText ( mywind[2], guiGridListGetSelectedItem ( mywind[16] ), 1 )
	jail = guiGridListGetItemText ( mywind[16], guiGridListGetSelectedItem ( mywind[16] ), 1 )
	if jail and nameplayerjail then
	triggerServerEvent( "onPlayerMuteClient", thePlayerBeingMuted, thePlayerBeingMuted, theTime )	
		end

 

Share this post


Link to post

What's not working about it?

Share this post


Link to post
9 hours ago, NeXuS™ said:

What's not working about it?

Which is not working is that as you can see in the SS there are many options of the mute time, 1 mins, 2 mins, 1 hour, etc .. anywas, the script that i've made works only for 480000 which should be 8 mins

Share this post


Link to post

Well guys thanks to @Tomas the script is done, here is it :

Server side :

Quote

KFQMeVP.png

Client Side :

Quote

e3pZM4W.png

But the weird thing that i'm getting this error :

Quote

sEe5kpY.png

Any idea how o fix it please ?

Share this post


Link to post

on clientGUIClick is root not resourceRoot leson 1 also same with onAdminMute same root not resourceRoot

Edited by Dimos7

Share this post


Link to post
15 hours ago, Dimos7 said:

on clientGUIClick is root not resourceRoot leson 1 also same with onAdminMute same root not resourceRoot

resourceRoot works perfectly with onClientGUIClick, the problem here is the code's indentation, it's very messed. If you adjust it, it should work.

Edited by Tomas

Share this post


Link to post

Bump, this is the final thing :

Server :

local mute_time = {}
addEvent("onAdminMute", true)
addEventHandler("onAdminMute", root,
	function (player, time)
		iprint("OK")
		if (not isElement(player)) then return end
		if (mute_time[player] or not time) then
			mute_time[player] = nil
			setPlayerMuted(player, false)
			outputChatBox(getPlayerName(player).. " has been unmuted by "..getPlayerName(client))
			return
		end
	setPlayerMuted(player, true)
	mute_time[player] = getRealTime().timestamp + time
	end
)

setTimer(
	function ()
		for player, time in pairs(mute_time) do
			if (not isElement(player)) then
				mute_time[player] = nil
			else
				if (getRealTime().timestamp >= time) then
					outputChatBox(getPlayerName(player).. " has been unmuted by Console")
					setPlayerMuted(player, false)
					mute_time[player] = nil
				end
			end
		end
	end,
1000, 0)

Client :

addEventHandler("onClientGUIClick", root, 
function()
    if (source == mywind[18]) then
    local time = guiGridListGetSelectedItem(mywind[2])
    local player = guiGridListGetItemText(mywind[16], guiGridListGetSelectedItem(mywind[16], 1))
    if (time and player) then
        player = getPlayerFromName(player)
        if (not isElement(player)) then return end
        time = (time == 0 and 60*1000 or time == 1 and 120*1000 or time == 2 and 180*1000 or time == 3 and 240*1000 or time == 4 and 300*1000 or time == 5 ) 
        triggerServerEvent("onAdminMute", root, player, time)
        return end
    elseif (source == mywind[17]) then
        local player = guiGridListGetItemText(mywind[16], guiGridListGetSelectedItem(mywind[16], 1))
        if (player) then
            player = getPlayerFromName(player)
            if (not isElement(player)) then return end
            triggerServerEvent("onAdminMute", root, player)
        end
    end
end
)

The script isnt showing any error, but the mute thing isnt getting triggered, any help please ? i keep pressing on "Mute" button but Nothing happpens nor i'm getting any errors :/

Edited by Gastonito

Share this post


Link to post
addEventHandler("onClientGUIClick", root, 
function()
    if (source == mywind[18]) then
    local selectedTime = guiGridListGetSelectedItem(mywind[2])
    local selectedPlayer = guiGridListGetItemText(mywind[16], guiGridListGetSelectedItem(mywind[16], 1))
    if (selectedTime and selectedPlayer) then
        theselectedPlayer = getPlayerFromName(selectedPlayer)
        if (not isElement(theselectedPlayer)) then return end
        muteTime = (selectedTime == 0 and 60*1000 or selectedTime == 1 and 120*1000 or selectedTime == 2 and 180*1000 or selectedTime == 3 and 240*1000 or selectedTime == 4 and 300*1000 or selectedTime == 5 ) 
        triggerServerEvent("onAdminMute", root, theselectedPlayer, muteTime)
        return end
    elseif (source == mywind[17]) then
        local selectedPlayer = guiGridListGetItemText(mywind[16], guiGridListGetSelectedItem(mywind[16], 1))
        if (selectedPlayer) then
            theselectedPlayer = getPlayerFromName(selectedPlayer)
            if (not isElement(theselectedPlayer)) then return end
            triggerServerEvent("onAdminMute", root, theselectedPlayer)
        end
    end
end
)

dont put player and again player its confused try it like this its better

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.