!report <name> <steam_id> <reason>

If you don’t understand what I’m getting at I can honestly say you’re retarded. It’s some type of system that logs reports of annoying players/ban requests in some file somewhere that I can look at daily and ban/watch those players. Also would be nice if you could log the reporter’s ID so I can ban abusers of it. Tanks

This shouldn’t be hard to do really. In fact, I might do it right now because I’m incredibly bored.

lol if you would I might just find a cookie for u

[editline]04:36PM[/editline]

also, if you would, add any features you see fit, I can’t think of any right now but something like maybe it tells the player they have been reported and there is no point in running away

I’m already doing it because I am also really bored.

Already have the saving // reading feature done, also sending the table to you when requested (So you can read it ingame)

I’ll also make a UI for it, but since I’m waiting for GMod Tower to come online I probably won’t test it.

lolk

[editline]04:42PM[/editline]

I don’t understand anything in that except “I’m already doing it because I am also really bored.”

Basically, I’ll make a basic menu for it which you can open in the game. The server will then read the report files and send them to you, so you can read them in further detail.

Edit: Oh wow, it’s 100 lines already xD

Wait, send them to me as in save them in a server folder or send them to me in a menu that I can open in game?

They save in a server folder, and the server sends them to you when you wish to view them in the menu I made.

Because if it sent them to me in a menu you know it would have to save them until I come back online.

… It saves to the server, so it will be there until you delete them. Your going offline would only mean it would need to send it again.

OrhcpO. Just let him get on with his generocity. No questions asked.

Meow much?

Im not a cat.

rawr much?*

[editline]05:03PM[/editline]

And look at his post time then mine, he posted that while I was typing mine… Notice something wrong with your RAWR theory?

I dont have RAWR theory? [sp]Sorry, Im not one for Jokes.[/sp]

Anyhow, I could use this Flapjack, So thanks for doing it.

You must learn a law, material objects first, thanks second.

[editline]05:11PM[/editline]

No offense flap :X

[editline]05:14PM[/editline]

I have haxed FP and will now blow all ur pooters up omg what the hell just happened.

[editline]05:15PM[/editline]

fucking FP, why cant they just have the editor?

[editline]05:15PM[/editline]

fucking FP, why cant they just have the editor?

[editline]05:15PM[/editline]

fucking FP, why cant they just have the editor?

[editline]05:16PM[/editline]

omg octuple post much?

I’ll be testing this in a minute: This is untested code

Clientside:


ReportedTable = {}
require("datastream")
function RecieveReportList(handler, id, encoded, decoded)
	ReportedTable = decoded
end
datastream.Hook( "SendReportList", RecieveReportList )

function Menu()
	if !LocalPlayer():IsAdmin() or !LocalPlayer():IsSuperAdmin() then return end
	
	frame = vgui.Create("DFrame")
	frame:SetSize(ScrW() / 2 + 200 , ScrH() / 2 + 150)
	frame:SetTitle("Thank ¦FlapJack¦ for this awesome report system")
	frame:Center()
	frame:MakePopup()
	
	listview = vgui.Create("DListView")
	listview:SetParent(frame)
	listview:SetSize(frame:GetWide() - 40 , frame:GetTall() - 25)
	listview:SetPos(5 , 10)
	listview:AddColumn("# reports")
	listview:AddColumn("Name at first report")
	listview:AddColumn("SteamID")
	listview:AddColumn("First report")
	
	for k , v in pairs(ReportedTable) do
		listview:AddRow(#string.Explode("
" , v) - 1 , string.Explode("|" , v[1])[1] , string.Explode("|" , v[1])[2] , v[3])
	end
	
	listview.OnRowSelected = function(panel , line)
		for k , v in pairs(ReportedTable) do
			if string.find(listview:GetLine(line):GetValue(3) , v[1]) then
				frame:Close()
				playerinfo = vgui.Create("DFrame")
				playerinfo:SetTitle("Viewing "..string.Explode("|" , v[1]).."'s reports")
				playerinfo:SetSize(ScrW()/2 , ScrH() / 2)
				playerinfo:Center()
				playerinfo:MakePopup()
				
				reportList = vgui.Create("DListView")
				reportList:SetParent(playerinfo)
				reportList:SetSize(playerinfo:GetWide() - 40 , playerinfo:GetTall() - 100)
				reportList:SetPos(5 , 10)
				reportList:AddColumn("#")
				reportList:AddColumn("Name")
				reportList:AddColumn("SteamID")
				reportList:AddColumn("Report")
				
				plReports = string.Explode("
" , v[3])
				
				for a , b in pairs(plReports) do
					if a > 1 then
						reportList:AddColumn(a , string.Explode("|" , v[1])[1] , string.Explode("|" , v[1])[2] ,b)
					end
				end
				
				BanButton = vgui.Create("DButton")
				BanButton:SetParent(playerinfo)
				BanButton:SetPos(5 , reportList:GetTall() + 5)
				BanButton:SetText("Ban")
				BanButton.DoClick = function()
					playerinfo:Close()
					
					banui = vgui.Create("DFrame")
					banui:SetSize(ScrW() / 3 , ScrH() / 3)
					banui:SetText("Ban player "..string.Explode("|" , v[1])[1])
					banui:Center()
					banui:MakePopup()
					
					lengthenter = vgui.Create("DTextEntry")
					lengthenter:SetParent(banui)
					lengthenter:SetPos(5 , 10)
					lengthenter:SetSize(banui:GetWide() - 60 , 25)
					lengthenter:SetText("Enter ban length")
					
					BanButton2 = vgui.Create("DButton")
					BanButton2:SetSize(banui:GetWide() - 60 , 25)
					BanButton2:SetPos(5 , 40)
					BanButton2:SetText("Swing teh banhammer")
					BanButton2.DoClick = function()
						RunConsoleCommand("ReportBan" , lengthenter:GetInt() , string.Explode("|" , v[1])[2])
						timer.Simple(0.5 , function() banui:Close() end )
					end
				end
			end
		end
	end
end
concommand.Add("Reports_View" , Menu)


Serverside:


require("datastream")
function Report(ply , text ,team)
	if !string.sub(string.lower(text) , 0 , 7) == "!report" then return end // Return it so as it doesn't run
	Reason = "" //Reset the reason from the last time it was run
	
	// Lets check it isn't being spammed
	if not NextToRun then NextToRun = 0 end
	if NextToRun > CurTime() then ply:ChatPrint("You can't report that often!!") return end
	
	//Now let's seperate the chat arguments
	chatArgs = string.Explode(" " , text)
	for a , b in pairs(chatArgs) do // Loop through the chat arguments
		if !string.find(chatArgs[2] , "STEAM") then // If the player didn't include a steamid
			if a > 1 then 
				Reason = Reason..b
			end
		elseif a > 2 then // Make sure it isn't the steamid or name
			Reason = Reason..b
		end
	end
	// Check If this matches to a player
	for k , v in ipairs(player.GetAll()) do // Loop through all players
		if #string.find(string.lower(chatArgs[1]) , string.lower(v:Nick())) == 1 then // We only want one player
			// Now let's see if a player has been reported before
			if file.Exists("ReportedPlayers/"..v:SteamID():gsub(":" , "_")..".txt") then
				oldFile = file.Read("ReportedPlayers/"..v:SteamID():gsub(":" , "_")..".txt")
				file.Write("ReportedPlayers/"..v:SteamID():gsub(":" , "_")..".txt", oldFile.."
"..Reason)
			else
				file.Write("ReportedPlayers/"..v:SteamID():gsub(":" , "_")..".txt", v:Nick().."|"..v:SteamID().."
"..Reason)
			end
		elseif chatArgs[2] == v:SteamID() then
			if file.Exists("ReportedPlayers/"..v:SteamID():gsub(":" , "_")..".txt") then
				oldFile = file.Read("ReportedPlayers/"..v:SteamID():gsub(":" , "_")..".txt")
				file.Write("ReportedPlayers/"..v:SteamID():gsub(":" , "_")..".txt", oldFile.."
"..Reason)
			else
				file.Write("ReportedPlayers/"..v:SteamID():gsub(":" , "_")..".txt", v:Nick().."|"..v:SteamID().."
"..Reason)
			end
		end
	end
	NextToRun = CurTime() + 30 // Only one person can be reported every half minute
end
hook.Add("PlayerSay" , "ReportHook" , Report) // Hook it so as the --[[function]] gets called every time a player talks

function ReadReports(ply , cmd , args)
	ReportedTable = nil
	ReportedTable = {} // Clear the table so as it doesn't lag the server when sending it
	if !ply:IsAdmin() or !ply:IsSuperAdmin() then return end // Check player is admin
	for k , v in pairs(file.Find("ReportedPlayers/*.txt")) do
		table.insert(ReportedTable , string.Explode("
" , file.Read("ReportedPlayers/"..v)) )
	end
	
	datastream.StreamToClients(ply , "SendReportList", ReportedTable) // Send the table
end
concommand.Add("RecieveReports" , ReadReports)

function BanaPlayer(ply , cmd , args)
	if !ply:IsAdmin() or !ply:IsSuperAdmin() then ply:ChatPrint("Fuck off, you arn't allowed to ban people") return end
	steamid = ""
	for k , v in pairs(args) do
		if k > 1 then
			steamid = steamid..v
		end
	end
	RunConsoleCommand("banid" , math.floor(tonumber(args)) , steamid)
end
concommand.Add("ReportBan" , BanaPlayer)

Mine’s a bit simpler :v:
Client:
[lua]require(“datastream”)

function ChatTextReporter( ply, txt, teamc, dead )
ply:ChatPrint( ReportFunc( txt ) or “” )
end

hook.Add( “OnPlayerChat”, “ChatTextReporter”, ChatTextReporter )

function ReportFunc( txt )

local text = string.Explode( ",", string.lower( txt ) )
local cmd = text[1]
local name = text[2]
local steamid = text[3]
local reason = text[4]

if ( cmd != "/report" and cmd != "!report" ) then return end
if ( name == nil or steamid == nil or reason == nil ) then return "Usage: !report &lt;name&gt;, &lt;steamid&gt;, &lt;reason&gt;" end

MsgN( "Reporting..." )
datastream.StreamToServer( "Report", { name, steamid, reason } )
MsgN( "Reported " .. name .. " with STEAM-ID " .. steamid .. ". Reason: " .. reason )

end[/lua]
Server:
[lua]AddCSLuaFile( “autorun/client/reporter.lua” )
require(“datastream”)

function ReportReceive( ply, handler, id, encoded, decoded )

MsgN( "Received report! Reading data..." )
local name = decoded[1]
local steamid = decoded[2]
local reason = decoded[3]
local reporter = ply
local r_nick = reporter:Nick()
local r_steamid = reporter:SteamID()
local time = os.date() //"%D_%T" 

local filename = Format( "reports/report_%s.txt", time )
local content = Format( "Subject name: %s 

Subject STEAM-ID: %s
Reason: %s

Reported by %s, with STEAM-ID %s", name, steamid, reason, r_nick, r_steamid )
file.Write( filename, content )
MsgN( filename … "
" … content )
ply:ChatPrint( “User " … name … " reported succesfully! Admins will look into the report as soon as possible.” )

end

datastream.Hook( “Report”, ReportReceive )
[/lua]
Doesn’t work completely yet. For some reason the files aren’t being saved.

whats the command for teh (or each as the situation may provide) menu

You didn’t define cmd :<

Also, the code I posted has some errors. Don’t use it yet.

Mine is reports_view