Paste Logs | Basic Admin Essentials

INTRODUCTION

Greetings! I am a Programmer and I am currently experimenting with Basic Admin Essentials 2.0 module for my group.

What’s the problem and what do I need?

I want to make paste logs for my group, this command will be used at the interview centre so interviewers can catch cheaters.

How should the command work?

The command is similar to any logs in Basic Admin Essentials 2.0, it would create a new log for every server, it is the same like chatlogs but it will only create and put data if someone pasted into chat and sent it. If someone copy-pasted into chat and sent it in the UI it will look like this Username: what they said here.

Modules and loaders
You may find the loader here
You may find the module here

NOTE: The module won’t appear in toolbox so you have to enter in the command bar game:GetService("InsertService"):LoadAsset(563619835,true).Parent = workspace.

CONTACT ME

The best way to contact me is through Discord, but you can just reply, here’s my user: artyom.#7685

Thank you

If you helped me, thank you! Your help is much appreciated and you might be invited to our development team.

8 Likes

I’m confused. If you are trying to hire someone here, this needs to be moved to recruitment.

1 Like

Nope, that’s not recruitment, but if we will be interested in your help then you might be invited in our development team.

1 Like

It seems as if you’re asking for us to write the whole code for you. Elaborate

1 Like

Nope, I can’t understand how to make it and I need your help, because I have the local script:


UserInputService.InputBegan:Connect(function(InputObject, Processed)
    if InputObject.KeyCode == Enum.KeyCode.LeftControl or InputObject.KeyCode == Enum.KeyCode.RightControl and InputObject.KeyCode == Enum.KeyCode.V then
        print("Someone copied and pasted into chat")
        -- here should be the part about BAE
    end
end)

I am aware about how to make the BAE part.

1 Like

An InputObject’s KeyCode property can’t be two things at once, that makes no sense.

What you can do is determine if they are already holding down control.

UserInputService.InputBegan:Connect(function(input, engine_processed)
    local left_ctrl_key_down = UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)
    local right_ctrl_key_down = UserInputService:IsKeyDown(Enum.KeyCode.RightControl
    if (left_ctrl_key_down or right_ctrl_key_down) and input.KeyCode == Enum.KeyCode.V then
        print("Someone copied and pasted into chat")
        -- here should be the part about BAE
    end
end)

Do note that exploiters can easily bypass this and if it’s possible to change the copy-paste keybinds or add custom ones, this won’t account for that as well. By the way there is parentheses around left_ctrl_key_down or right_ctrl_key_down because and has higher precedence than or.

6 Likes

Is that possible to know what they have actually pasted?

1 Like

(Im assuming your using chat and not some GUI) You could use the .chatted event to get the message they sent.

2 Likes

Alrighty, but should I paste the code into the main module? I don’t think that would work though.

2 Likes

What I would do is when you detect someone used Control V connect a .chatted event to them and wait for the message. You can then use the message parameter to log what the player sent.

2 Likes

You can just bind an action like crouch to CTRL key and when they crouch constantly, you can know that they are copy pasting.

If you want it to be more clear, you can use tick() and UserInputService, check the V key until timeout. If you don’t use this, they can get warned wrongly. Keep in mind GameProcessedEvent needs to be true in order to this method to work.

2 Likes

Will it work if I will just copy the existing function in the main module and edit it?

1 Like

Disagree—players will use it to actually be able to crouch.

You have to press v while the control key is held. If you release the control key you can’t use the shortcut anymore. It is not a matter of “if you release control and don’t press v in a certain amount of time the shortcut stops working”.

1 Like

I think you haven’t really played a game using this method. It’s easy to seperate normal crouching and copy pasting with it.

That’s my bad.

1 Like

You need to get the currently focused text box using UserInputService:GetFocusedTextBox. If you want this solely for the chat box then just get it by

local client = game:GetService("Players").LocalPlayer

local chat_box = client.PlayerGui.Chat:FindFirstChild("ChatBar", true)

local old_text = chat_box.Text

chat_box:GetPropertyChangedSignal("Text"):Connect(function()
    local new_text = chat_box.Text
    
    if #new_text - #old_text > 1 then
        print("Player copy-pasted")
    end
    old_text = new_text
end)

If it’s while the player is in a focused text box then yes this can work. But a crouch feature doesn’t fit all games.

3 Likes

Here’s the function:

	local PlayerCommand = Message:gmatch("%w+")()
	if not PlayerCommand then
		return
	else
		PlayerCommand = PlayerCommand:lower()
	end
	local PlayerPrefix = Message:sub(1,1):lower()
	local PlayerPermission = returnPermission(Player)
	if PlayerPermission <= 0 then
		-- Truncate the message for non-admins
		-- If admins are sending excessively long messages in your game, you have a different problem.
		Message = Message:sub(1,1000)
	end

	local Command = CommandsDictionary[PlayerCommand]
	if Command then
		local CommandName = Command[1]
		local CommandPrefix = Command[2]
		local CommandFunction = Command[3]
		local CommandPermission = Command[4]

		if (PlayerCommand == CommandName) then
			if (PlayerPermission >= CommandPermission) then
				local ActionCommandUsed = (CommandPrefix == sysTable.actionPrefix and PlayerPrefix == CommandPrefix) and Message:sub(2)
				local RegularCommandUsed = ((#CommandPrefix == 0 and PlayerCommand:sub(1,1) == PlayerPrefix) and Message) or ((PlayerPrefix == CommandPrefix) and Message:sub(2))
				local MessageWithoutPrefix = ActionCommandUsed or RegularCommandUsed or nil
				if MessageWithoutPrefix then
					local Arguments = {}
					table.insert(Arguments, Player)
					for Segment in string.gmatch(MessageWithoutPrefix, "%S+") do
						if not Arguments[2] then
							table.insert(Arguments,Segment:lower())
						else
							table.insert(Arguments,Segment)
						end
					end
					local Success,Error = pcall(function()
						CommandFunction(Arguments)
					end)
					if Success == true then
						local cleanedMessage
						local Cleaned,newData = cleanUserData(Message,Player,false)
						if Cleaned and newData then
							cleanedMessage = newData
						elseif not Cleaned then
							cleanedMessage = newData
						end
						if cleanedMessage then
							pluginEvent:Fire("Admin Logs",{Player,newData})
						else
							addLog(sysTable.Logs,{Sender = Player,Bypass = true,Data = '(super safechat) executed "'..tostring(b[1] or "???")..'"',Tag = true})
							return
						end
						addLog(sysTable.Logs,{Sender = Player,Data = cleanedMessage}) -- Store the filter instance once we can use it properly.
					elseif Error ~= nil then
						addLog(sysTable.debugLogs,'"'..Arguments[2]..'"| Error: '..Error)
						essentialsEvent:FireClient(Player,'Message','Function Error','Name: "'..Arguments[2]..'"\n'..Error)
					end
				end
			end
		end
	end

	if Chatted == true then
		local cleanedMessage
		local function Redo()
			local Succ,Msg = pcall(function()
				cleanedMessage = chatService:FilterStringForBroadcast(Message,Player)
			end)
			if not Succ then
				wait(1)
				Redo()
			end
		end

		Redo()

I have no idea how to modify it though.

1 Like

Here’s the second one:

Player.Chatted:connect(function(Message)
		onChatted(Message,Player,true)
	end)

	spawn(function()
		pcall(function()
			for otherPlayer,nameData in next,sysTable.localNames do
				local filteredName
				local Cleaned,newData = cleanUserData(nameData.Data,nameData.Sender,Player)

				if Cleaned then
					filteredName = newData
				end

				if filteredName then
					for c,d in next,playerService:GetPlayers() do
						essentialsEvent:FireClient(Player,'Local Name',otherPlayer,filteredName)
					end
				end
			end
		end)
	end)
1 Like

I still can’t understand how to do it. :confused: It is very confused for me as I never used chatted events.

1 Like

You actually don’t have to use the chatted events (I really need to stop using Dev forum at 4 am)

You could easily use the code @sjr04 has provided and get the copy pasted text using some string manipulation. Then its up to you with what you want to do with it send it to the server and have it be displayed in some GUI somewhere. Im pretty sure Basic Admin essential has a way to add a custom command in. So you could just add in your new custom command that GUI. Best of luck

3 Likes

Lol, thank you! You too! :slight_smile:

1 Like