I’m editing a damagelog system to add all types of new logs. Everything I’ve added so far has been pretty simple: take the hooks for the event and make it append the logs with the relevant information when the event happens. I’ve kind of run into a wall when I try to make something run when a console command is executed. I can’t find any relevant hooks, so I tried to do something like this:
// I didn't append anything just so I could get this to run and properly notify. function allcp(msg) for i, v in pairs(player.GetAll()) do v:ChatPrint(msg) end end local crun = concommand.Run function concommand.Run(ply, cmd, args) if !IsValid(ply) then return crun(ply,cmd,args) end if !cmd then return crun(ply,cmd,args) end if args and args ~= "" then allcp(ply:Name() .. " has executed this command: " .. cmd .. " " .. tostring(args) .. ".") else allcp(ply:Name() .. " has executed this command: " .. cmd .. ".") end return crun(ply, cmd, args) end
This just doesn’t work in general. To see where it breaks, I took out the returns and figured out the problem. Apparently ply is not valid, so it simply returns (I got an error that the method “Name” was a nil value). Oddly enough, this does notify if the command is not run from the console manually, but by a script. For example, this appears in my chat automatically:
AKTS has executed this command: fas2_handrig_applynow
For some context, this is just a function automatically run to adjust the handrigs.
Does anyone have any suggestions as to how to go about doing this? I’m at an impasse at the moment.