Need help with :pmadmins command for BAE 2.0

I have an question,

Recently I saw an post on the DevForum called “Basic Admin Essentials complete guide”, in there I scrolled down and saw an dropdown with “Sending PMs through a custom command” (The Ultimate Basic Admin Essentials Guide - Community Tutorials - Developer Forum | Roblox) and there I saw that you can create an command that will not allow players to reply to it, but I dont understand how to do that. This is what is stated there and here are the scripts that are in there:

“Sending BAE PMs to multiple players is possible using the Commands table that is automatically passed into Basic Admin Plugins. Let’s take a look at how to get that function, and how to use it to send PMs.”

“For my example, I’m going to make a command to send a PM to all the admins in the game. I know that this is obsolete as you can just do “:pm admins”, though for proof of concept let’s figure out how to make this command.”

“This is slightly more complex because we want the PMs to act as real Basic Admin PMs that can be replied to. If you don’t want your PMs to be able to be replied to, you can simply fire the RemoteEvent as we do in step 1 but exclude the “ID” argument.”

“1. The existing PM command in the MainModule is not suitable for our needs here, so let’s create our own. We’re going to add the following code directly below the function that starts around Line 900 called “Funcs.PM”.

function Funcs.CustomPM(Args)
	local playerSending = Args[1]
	local players = Args[2]
	local message = Args[3]
		
	if playerSending and players and message then
		for _,v in players do
			local sending = true
			local filtered, filterResult = cleanUserData(message, playerSending, v)
			
			if filtered and filterResult then
				local newId = generateID()
				sysTable.outboundMessages[newId] = v
				remoteEvent:FireClient(v, "PM", playerSending.Name, filterResult, nil, newId)
			end
		end
	end
end

“Your MainModule will now have this function directly underneath the real PM function:”

“ 2. Near the bottom of the MainModule in the commands table, add the following code underneath the Commands table:”

local customFuncs = {
	{"custompm", sysTable.Prefix, Funcs.CustomPM, #sysTable.Permissions, { "custompm", "", "" }},
}

“The reason we’re putting this in a separate table is because we don’t want this command to be able to be ran through the command bar, though it should be able to be used by other scripts. You should now see your custom PM function at the bottom of the commands table:”

“ 3. Finally, let’s add our new customFuncs table to our list of arguments when requiring the Plugin script. With this done, we can then use the custom PM function in a plugin.”

Now all we have to do in our plugin is use that function. See the code below for a basic “PM admins” plugin

--[[
	
	 ____                                   
	/\  _`\                    __           
	\ \ \L\ \     __      ____/\_\    ___   
	 \ \  _ <'  /'__`\   /',__\/\ \  /'___\ 
	  \ \ \L\ \/\ \L\.\_/\__, `\ \ \/\ \__/ 
	   \ \____/\ \__/.\_\/\____/\ \_\ \____\
	    \/___/  \/__/\/_/\/___/  \/_/\/____/
	                                        
	            
	Admin Essentials v2
	Plugin Documentation
	*coming soon^tm
	
	If you have any questions regarding Plugins, contact TheFurryFish.
	
--]]

local Plugin = function(...)
	local Data = {...}
	
	-- Included Functions and Info --
	local remoteEvent = Data[1][1]
	local remoteFunction = Data[1][2]
	local returnPermissions = Data[1][3]
	local Commands = Data[1][4]
	local Prefix = Data[1][5]
	local actionPrefix = Data[1][6]
	local returnPlayers = Data[1][7]
	local cleanData = Data[1][8] -- cleanData(Sender,Receiver,Data)
	-- Practical example, for a gui specifically for a player, from another player
	-- cleanData(Sender,Receiver,"hi") -- You need receiver because it's being sent to everyone
	-- Or for a broadcast (something everyone sees, from one person, to nobody specific)
	-- cleanData(Sender,nil,"hi") -- Receiver is nil because it is a broadcast
	
	-- Plugin Configuration --
	local pluginName = 'pmadmins'
	local pluginPrefix = Prefix
	local pluginLevel = 1
	local pluginUsage = "" -- leave blank if the command has no arguments
	local pluginDescription = "Sends a PM to all admins."
	
	-- Example Plugin Function --
	local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
		local playerRunningCommand = Args[1]
		
		-- get custom PM command
		local customCommands = Data[1][10]
		local pmCommand
		for _,info in customCommands do
			if info[1] == "custompm" then
				pmCommand = info[3]
				break
			end
		end
		
		-- filter admins
		local admins = {}
		for _,v in game.Players:GetPlayers() do
			if returnPermissions(v) >= 2 then -- check if they have the "Administrator" perm level
				table.insert(admins, v)
			end
		end
		
		-- try to send pm to players
		return pmCommand({ playerRunningCommand, admins, table.concat(Args, " ", 3) })
	end
	
	-- Return Everything to the MainModule --
	local descToReturn
	if pluginUsage ~= "" then
		descToReturn = pluginPrefix..pluginName..' '..pluginUsage..'\n'..pluginDescription
	else
		descToReturn = pluginPrefix..pluginName..'\n'..pluginDescription
	end
	
	return pluginName,pluginFunction,pluginLevel,pluginPrefix,{pluginName,pluginUsage,pluginDescription}
end

return Plugin

“Members who receive the PM can now reply to it like a real PM, which is much better than other solutions that members have suggested previously. As stated before, if you want people not to be able to reply to PMs, you can just fire the PM remote to create a “fake PM” with the ID parameter left out.”

So, my question is, how do I make it so all admins / receivers will not be able to reply to it? They say “you can fire the PM remote to create a fake PM with the ID parameter left out. | How do I do that?

You can do pm admins [text]. This is built into Basic Admin.

I think they want the feature to be that they can’t reply to it. Like it is in the update logs that is built into BAE.

I want to make an command that all admins will receive an PM and that they can not reply to it.

Yeah, exactly.

(20 chars)

Okay, I figured this out and this is the code to get the “You can not reply to this message.” PM.

Here is the code from step 1 but then without ID parameter.

function Funcs.CustomPM(Args)
	local playerSending = Args[1]
	local players = Args[2]
	local message = Args[3]

	if playerSending and players and message then
		for _, v in players do
			local sending = true
			local filtered, filterResult = cleanUserData(message, playerSending, v)

			if filtered and filterResult then
				remoteEvent:FireClient(v, "PM", playerSending.Name, filterResult)
			end
		end
	end
end

The thing that is removed now is the sysTable.outboundMessages[newId] = v code and the local newId = generateID() code.

Changelog is built into the mainModule since the mainModule has some code functions to make no-reply pms. I’m not entirely sure but with a plugin, you could do:

remoteEvent:FireClient(v, "PM", playerSending.Name, filterResult,false)
1 Like

Right, seeing as this has not yet been solved lets point you in the right direction.


So, if we take example from the main-module , we can see in its changelog command it uses the following script:

elseif Command == "changelog" then
		essentialsEvent:FireClient(Player,'PM',"Changelog",sysTable.Changelog,true)

What we want to focus on is the ending where it says true. The true at the end adds another value to it, like the ‘refresh’ and ‘search button’ on the ‘lists’ feature. So, if we want to achieve this (in a plugin) then we can use the following code:

	
	-- Example Plugin Function --
	local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
		local Player = Args[1]
		if Args[3] then
			local Victims = returnPlayers(Player, Args[3]) if not Victims then return end
			local combinedVictims = ''
			for a,b in pairs(Victims) do
				if combinedVictims == '' then
					combinedVictims = b.Name
				else
					combinedVictims = combinedVictims..', '..b.Name
				end
			end
			
			local configureTheTextData = "How about make it so when the command is used, it displays the text that was stated aftre the username!"
			
			for a,b in next,Victims do
				remoteEvent:FireClient(Player,'PM',"No-Reply PM",configureTheTextData,true)
			end
		end
	end
	

(as you can see, I have been lazy and not added the ‘notif’ feature in but feel free to.)

And, it infact works for me.
image

If this helped and solved you’re problem, mark it as solution!

(Sorry for the typo, haha!)


Also, to send it to admins execute the following command like so:

(we will say my prefix is ‘:’ and command is ‘noreply’.)

:noreply **admins** (string)

And, to execute the command on a certain team:

(our team name will be called ‘trainees’)

:noreply %trainees (string)

Feel free to add the notification and string feature yourself, and hope this helps!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.