Jump to content

Mutep


Recommended Posts

hello guys, I'm using the mute panel script of @Dutchman101, it's good I like it, thanks to him

but I get a little problem, I didn't know how to solve it, I made a logs to see the players who get muted, is worked, but I can't add the ( reason ) into the logs, I don't know why

Client-Side

local sx, sy = guiGetScreenSize()

addEvent ("requestMutePanel", true)
function openMutePanel()
	if isElement(mp) then return end
	showCursor(true)
	guiSetInputMode("no_binds")
	mp = guiCreateWindow(sx/2-139, sy/2-265, 278, 530, "Mute Panel", false)
	guiWindowSetSizable(mp, false)
	guiSetAlpha(mp, 0.90)

	mp_grid = guiCreateGridList(9, 79, 259, 271, false, mp)
	local playersCol = guiGridListAddColumn(mp_grid, "Players:", 0.9)

	--Fill gridlist with online players:
	if playersCol then
		for _,p in ipairs(getElementsByType("player")) do
			if p ~= localPlayer then
				local row = guiGridListAddRow (mp_grid)
				guiGridListSetItemText (mp_grid, row, playersCol, getPlayerName(p), false, false)
				guiGridListSetItemData (mp_grid, row, 1, p)
			end
		end
	end
	mp_search = guiCreateEdit(9, 47, 259, 27, "", false, mp)
	mp_searchlbl = guiCreateLabel(91, 29, 97, 18, "Search by name:", false, mp)
	guiSetFont(mp_searchlbl, "default-bold-small")
	mp_reasonlbl = guiCreateLabel(29, 355, 234, 15, "Reason (Please do not abuse your mp):", false, mp) ----------------------------------------------
	guiSetFont(mp_reasonlbl, "default-bold-small")
	guiLabelSetColor(mp_reasonlbl, 254, 0, 0)
	mp_reasonmemo = guiCreateMemo(9, 375, 258, 67, "", false, mp)
	mute = guiCreateButton(11, 449, 257, 32, "Mute", false, mp)
	guiSetProperty(mute, "NormalTextColour", "FFFD9500")
	closemp = guiCreateButton(11, 488, 257, 32, "Close Window", false, mp)
end
addEventHandler ("requestMutePanel", localPlayer, openMutePanel)

function onMPGUIClick(btn, state)
	if btn == "left" and state == "up" then
		if source == closemp then
			guiSetInputMode("allow_binds")
			if isElement(mp) then destroyElement(mp) end
			showCursor(false)
		elseif source == mute then
			local reason = guiGetText(mp_reasonmemo) -----------------------------------------
			if not reason or reason == "" or reason:len() < 3 then
				outputChatBox ("* Mute Panel: Reason needs to be at least 4 characters long", 255, 30, 30) ---------------------------------
			else
				local r, c = guiGridListGetSelectedItem (mp_grid)
				if not r or r == -1 or not c or c == -1 then
					return outputChatBox ("* Mute Panel: Select a player from the list", 255, 30, 30)
				end
				local playerData = guiGridListGetItemData (mp_grid, r, c)
				if not playerData or not isElement(playerData) then
					return outputChatBox ("* Mute Panel: This player no longer exists", 255, 30, 30)
				end
				triggerServerEvent ("onMutePanelMute", localPlayer, playerData, reason)
			end
		end
	end
end
addEventHandler ("onClientGUIClick", root, onMPGUIClick)

function searchBarFunction()
	if source == mp_search then
		local searchText = guiGetText(mp_search)
		if searchText == "" then
			guiGridListClear(mp_grid)
			for _,p in ipairs(getElementsByType("player")) do
				if p ~= localPlayer then
					local row = guiGridListAddRow (mp_grid)
					guiGridListSetItemText (mp_grid, row, 1, getPlayerName(p), false, false)
					guiGridListSetItemData (mp_grid, row, 1, p)
				end
			end
		else
			guiGridListClear(mp_grid)
			for _,plr in ipairs(getElementsByType("player")) do
				local name = getPlayerName(plr)
				-- remove hex first:
				for i=1,3 do
					if name:find("#%x%x%x%x%x%x") then
						name = name:gsub("#%x%x%x%x%x%x", "")
					else
						break
					end
				end
				if getPlayerName(plr):lower():find(searchText:lower()) or name:lower():find(searchText:lower()) then
					local row = guiGridListAddRow(mp_grid)
					guiGridListSetItemText(mp_grid, row, 1, getPlayerName(plr), false, false)
					guiGridListSetItemData (mp_grid, row, 1, plr)
				end
			end
		end
	end
end
addEventHandler ("onClientGUIChanged", root, searchBarFunction)

Server-Side

-- Always change this to player account names you want to be a MuteMod

local authorizedMuters = {
	[".............."] = true,
	[".............."] = true
}

local aclGroupName = "mutepanel"

-- ## End of Settings ##

-- # Main Code # Edit with caution #
function scriptInitialize()
	-- Check/create ACL group
	local aclGroup = aclGetGroup (aclGroupName)
	if not aclGroup or aclGroup == nil then
		if not aclGroupName or type(aclGroupName) ~= "string" then return outputDebugString ("Error creating ACL group for mute panel, check configuration", 0) end
		local aclg = aclCreateGroup (aclGroupName)
		local acl = aclCreate (aclGroupName)
		aclGroup = aclg
		if acl then
			aclSetRight (acl, "command.mute", true)
			aclGroupAddACL (aclg, acl)
		else
			return outputDebugString ("Error creating ACL group for mute panel, check configuration", 0)
		end
	end

	-- Clean group of old usernames
	local list = aclGroupListObjects(aclGroup)
	if list and #list ~= 0 then
		for _,object in ipairs (list) do
			local prefix = gettok(object, 1, ".")
			if prefix == "user" then
				local user = gettok(object, 2, ".")
				if user and not authorizedMuters[user] then
					if aclGroupRemoveObject (aclGroup, object) then
						outputDebugString ("* Mute Panel: User account '"..user.."' has been removed from the ACL as it has been removed from the script", 0)
					end
				end
			end
		end
	end

	if authorizedMuters then
		for k in pairs (authorizedMuters) do
			if getAccount(k) then
				if not isObjectInACLGroup ("user."..k, aclGroup) then
					if aclGroupAddObject (aclGroup, "user."..k) then
						outputDebugString ("* Mute Panel: Added user account '"..k.."' to ACL", 0)
					end
				end
			else
				outputDebugString ("* Mute Panel: Failed to add user account '"..k.."' as it is not registered", 0)
			end
		end
	end
end
addEventHandler ("onResourceStart", resourceRoot, scriptInitialize)

function mutePanel(player)
	local account = getPlayerAccount(player)
	if account and not isGuestAccount(account) and authorizedMuters[getAccountName(account)] then
		setElementData (player, "AnonAdmin", true)
		triggerClientEvent (player, "requestMutePanel", player)
	end
end
addCommandHandler ("mp", mutePanel)

---------------------------------------------

function time()
	local time = getRealTime();
	return "["..(time.monthday).."-"..(time.month+1).."-"..(time.year+1900).."|"..time.hour..":"..time.minute.."]";
end

function log(text)
	local f = fileOpen("logs.txt");
	if not f then
		f = fileCreate("logs.txt");
	end
	fileSetPos(f, fileGetSize(f));
	fileWrite(f, time().." "..text:gsub("#%x%x%x%x%x%x", "").."\r\r");
	fileFlush(f);
	fileClose(f);
end

---------------------------------------------

addEvent ("onMutePanelMute", true)
function requestMute(victim, reason)
	if not client or source ~= client then return end

	if not victim or not isElement(victim) then
		return outputChatBox ("* Mute Panel: Selected player no longer exists", client, 255, 30, 30)
	end

	if isPlayerMuted(victim) then
		return outputChatBox ("* Mute Panel: Selected player is already muted", client, 255, 30, 30)
	end

	triggerEvent ("aPlayer", client, victim, "mute", reason, 300)
	log("'"..getPlayerName(source).."' muted '"..getPlayerName(victim).."' ("..reason..")"); -----------------------------------------
end
addEventHandler ("onMutePanelMute", root, requestMute)

the log is in line 103 server-side

can I get any help please, I'm sorry for posting all the script, it's already open in the community resources

Edited by TorNix~|nR
Link to comment
  • 2 weeks later...

Guys, please I need help, I just want to show the ..reason.. on the logs, it shows only ..reason.. not the real reason

it's not a problem on the script, I added the logs

On 29/07/2018 at 18:26, TorNix~|nR said:

hello guys, I'm using the mute panel script of @Dutchman101, it's good I like it, thanks to him

but I get a little problem, I didn't know how to solve it, I made a logs to see the players who get muted, is worked, but I can't add the ( reason ) into the logs, I don't know why

Client-Side


local sx, sy = guiGetScreenSize()

addEvent ("requestMutePanel", true)
function openMutePanel()
	if isElement(mp) then return end
	showCursor(true)
	guiSetInputMode("no_binds")
	mp = guiCreateWindow(sx/2-139, sy/2-265, 278, 530, "Mute Panel", false)
	guiWindowSetSizable(mp, false)
	guiSetAlpha(mp, 0.90)

	mp_grid = guiCreateGridList(9, 79, 259, 271, false, mp)
	local playersCol = guiGridListAddColumn(mp_grid, "Players:", 0.9)

	--Fill gridlist with online players:
	if playersCol then
		for _,p in ipairs(getElementsByType("player")) do
			if p ~= localPlayer then
				local row = guiGridListAddRow (mp_grid)
				guiGridListSetItemText (mp_grid, row, playersCol, getPlayerName(p), false, false)
				guiGridListSetItemData (mp_grid, row, 1, p)
			end
		end
	end
	mp_search = guiCreateEdit(9, 47, 259, 27, "", false, mp)
	mp_searchlbl = guiCreateLabel(91, 29, 97, 18, "Search by name:", false, mp)
	guiSetFont(mp_searchlbl, "default-bold-small")
	mp_reasonlbl = guiCreateLabel(29, 355, 234, 15, "Reason (Please do not abuse your mp):", false, mp) ----------------------------------------------
	guiSetFont(mp_reasonlbl, "default-bold-small")
	guiLabelSetColor(mp_reasonlbl, 254, 0, 0)
	mp_reasonmemo = guiCreateMemo(9, 375, 258, 67, "", false, mp)
	mute = guiCreateButton(11, 449, 257, 32, "Mute", false, mp)
	guiSetProperty(mute, "NormalTextColour", "FFFD9500")
	closemp = guiCreateButton(11, 488, 257, 32, "Close Window", false, mp)
end
addEventHandler ("requestMutePanel", localPlayer, openMutePanel)

function onMPGUIClick(btn, state)
	if btn == "left" and state == "up" then
		if source == closemp then
			guiSetInputMode("allow_binds")
			if isElement(mp) then destroyElement(mp) end
			showCursor(false)
		elseif source == mute then
			local reason = guiGetText(mp_reasonmemo) -----------------------------------------
			if not reason or reason == "" or reason:len() < 3 then
				outputChatBox ("* Mute Panel: Reason needs to be at least 4 characters long", 255, 30, 30) ---------------------------------
			else
				local r, c = guiGridListGetSelectedItem (mp_grid)
				if not r or r == -1 or not c or c == -1 then
					return outputChatBox ("* Mute Panel: Select a player from the list", 255, 30, 30)
				end
				local playerData = guiGridListGetItemData (mp_grid, r, c)
				if not playerData or not isElement(playerData) then
					return outputChatBox ("* Mute Panel: This player no longer exists", 255, 30, 30)
				end
				triggerServerEvent ("onMutePanelMute", localPlayer, playerData, reason)
			end
		end
	end
end
addEventHandler ("onClientGUIClick", root, onMPGUIClick)

function searchBarFunction()
	if source == mp_search then
		local searchText = guiGetText(mp_search)
		if searchText == "" then
			guiGridListClear(mp_grid)
			for _,p in ipairs(getElementsByType("player")) do
				if p ~= localPlayer then
					local row = guiGridListAddRow (mp_grid)
					guiGridListSetItemText (mp_grid, row, 1, getPlayerName(p), false, false)
					guiGridListSetItemData (mp_grid, row, 1, p)
				end
			end
		else
			guiGridListClear(mp_grid)
			for _,plr in ipairs(getElementsByType("player")) do
				local name = getPlayerName(plr)
				-- remove hex first:
				for i=1,3 do
					if name:find("#%x%x%x%x%x%x") then
						name = name:gsub("#%x%x%x%x%x%x", "")
					else
						break
					end
				end
				if getPlayerName(plr):lower():find(searchText:lower()) or name:lower():find(searchText:lower()) then
					local row = guiGridListAddRow(mp_grid)
					guiGridListSetItemText(mp_grid, row, 1, getPlayerName(plr), false, false)
					guiGridListSetItemData (mp_grid, row, 1, plr)
				end
			end
		end
	end
end
addEventHandler ("onClientGUIChanged", root, searchBarFunction)

Server-Side


-- Always change this to player account names you want to be a MuteMod

local authorizedMuters = {
	[".............."] = true,
	[".............."] = true
}

local aclGroupName = "mutepanel"

-- ## End of Settings ##

-- # Main Code # Edit with caution #
function scriptInitialize()
	-- Check/create ACL group
	local aclGroup = aclGetGroup (aclGroupName)
	if not aclGroup or aclGroup == nil then
		if not aclGroupName or type(aclGroupName) ~= "string" then return outputDebugString ("Error creating ACL group for mute panel, check configuration", 0) end
		local aclg = aclCreateGroup (aclGroupName)
		local acl = aclCreate (aclGroupName)
		aclGroup = aclg
		if acl then
			aclSetRight (acl, "command.mute", true)
			aclGroupAddACL (aclg, acl)
		else
			return outputDebugString ("Error creating ACL group for mute panel, check configuration", 0)
		end
	end

	-- Clean group of old usernames
	local list = aclGroupListObjects(aclGroup)
	if list and #list ~= 0 then
		for _,object in ipairs (list) do
			local prefix = gettok(object, 1, ".")
			if prefix == "user" then
				local user = gettok(object, 2, ".")
				if user and not authorizedMuters[user] then
					if aclGroupRemoveObject (aclGroup, object) then
						outputDebugString ("* Mute Panel: User account '"..user.."' has been removed from the ACL as it has been removed from the script", 0)
					end
				end
			end
		end
	end

	if authorizedMuters then
		for k in pairs (authorizedMuters) do
			if getAccount(k) then
				if not isObjectInACLGroup ("user."..k, aclGroup) then
					if aclGroupAddObject (aclGroup, "user."..k) then
						outputDebugString ("* Mute Panel: Added user account '"..k.."' to ACL", 0)
					end
				end
			else
				outputDebugString ("* Mute Panel: Failed to add user account '"..k.."' as it is not registered", 0)
			end
		end
	end
end
addEventHandler ("onResourceStart", resourceRoot, scriptInitialize)

function mutePanel(player)
	local account = getPlayerAccount(player)
	if account and not isGuestAccount(account) and authorizedMuters[getAccountName(account)] then
		setElementData (player, "AnonAdmin", true)
		triggerClientEvent (player, "requestMutePanel", player)
	end
end
addCommandHandler ("mp", mutePanel)

---------------------------------------------

function time()
	local time = getRealTime();
	return "["..(time.monthday).."-"..(time.month+1).."-"..(time.year+1900).."|"..time.hour..":"..time.minute.."]";
end

function log(text)
	local f = fileOpen("logs.txt");
	if not f then
		f = fileCreate("logs.txt");
	end
	fileSetPos(f, fileGetSize(f));
	fileWrite(f, time().." "..text:gsub("#%x%x%x%x%x%x", "").."\r\r");
	fileFlush(f);
	fileClose(f);
end

---------------------------------------------

addEvent ("onMutePanelMute", true)
function requestMute(victim, reason)
	if not client or source ~= client then return end

	if not victim or not isElement(victim) then
		return outputChatBox ("* Mute Panel: Selected player no longer exists", client, 255, 30, 30)
	end

	if isPlayerMuted(victim) then
		return outputChatBox ("* Mute Panel: Selected player is already muted", client, 255, 30, 30)
	end

	triggerEvent ("aPlayer", client, victim, "mute", reason, 300)
	log("'"..getPlayerName(source).."' muted '"..getPlayerName(victim).."' ("..reason..")"); -----------------------------------------
end
addEventHandler ("onMutePanelMute", root, requestMute)

the log is in line 103 server-side

can I get any help please, I'm sorry for posting all the script, it's already open in the community resources

 

Link to comment

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