CheckMeIn Logs | Basic Admin Essentials Plugin

CheckMeIn Logs

Hello developers! I am currently looking forward to making CheckMeIn Logs in Basic Admin Essentials as a plugin command. I’ve found the code from a SimpleAdmin package. I re-wrote the code and made it into a Basic Admin Plugin, the only issue is the data it picks up from event is not adding to the table. I’ve tried only putting table.insert(“test”) at the end and it added it to the table and displayed it in logs. I’m not sure why is it not adding CheckMeIn data. Does anyone have any ideas?

Code below;

--[[
	
	 ____                                   
	/\  _`\                    __           
	\ \ \L\ \     __      ____/\_\    ___   
	 \ \  _ <'  /'__`\   /',__\/\ \  /'___\ 
	  \ \ \L\ \/\ \L\.\_/\__, `\ \ \/\ \__/ 
	   \ \____/\ \__/.\_\/\____/\ \_\ \____\
	    \/___/  \/__/\/_/\/___/  \/_/\/____/
	                                        
	            
	Admin Essentials v2
	SimpleAdmin CMI Logs Rewrite
	
--]]

local Plugin = function(...)
	local Data = {...}

	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] 

	local pluginName = 'cmilogs'
	local pluginPrefix = Prefix
	local pluginLevel = 1
	local pluginUsage = ""
	local pluginDescription = "test"

	local function pluginFunction(Args)
		local PlayerToDisplay = Args[1]
		local Table = {}
		local CheckMeIn = game:GetService('ServerScriptService'):WaitForChild('CMI_Server')
		local API = CheckMeIn:WaitForChild("API")
		API:WaitForChild("Service")
		API:WaitForChild("Web")

		API.Service:WaitForChild("CheckedIn").Event:Connect(function(Employee, Player, Door)
			if Employee == "SCI" or not Employee then
				table.insert(Table,"Self Check-In checked-in "..Player.Name.." in Room "..Door.Configuration.Number.Value.." ("..Door.Configuration.Type.Value..")")
				print("SCI Table Insert Check (Check-In)")
			else
				table.insert(Table,Employee.Name.." checked-in "..Player.Name.." in Room "..Door.Configuration.Number.Value.." ("..Door.Configuration.Type.Value..")")
				print("Manual Table Insert Check (Check-In)")
			end
		end)

		API.Service:WaitForChild("CheckedOut").Event:Connect(function(Employee, Player, Door)
			if Employee == "SCI" or not Employee then
				table.insert(Table,"Self Check-In checked "..Player.Name.." out of Room "..Door.Configuration.Number.Value.." ("..Door.Configuration.Type.Value..")")
				print("SCI Table Insert Check (Check-Out)")
			else
				table.insert(Table,Employee.Name.." checked "..Player.Name.." out of Room "..Door.Configuration.Number.Value.." ("..Door.Configuration.Type.Value..")")
				print("Manual Table Insert Check (Check-Out)")
			end
		end)

		remoteEvent:FireClient(PlayerToDisplay, "List", "CheckMeIn Logs", true, true, Table)
	end


	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

Note: Output doesn’t throw any errors.

3 Likes

Try using print(argument) for your arguments to determine if one of them isn’t receiving the data you are looking for, that is most likely the case.

I already tried that, but the issue is it picks it up it just doesn’t insert it into the table. Not sure why.

Oh, I’m seeing here that you didn’t supply the index value for your items.

You would use table.insert() like this

table.insert(TableHere, #TableHere, Value)

The index value determines where it’s located on the table, you use the hashtag/# to determine where to insert your value.