How do you tell if the server console used a command created with concommand.Add?

This works but is it safe? Is it possible for other players to somehow make ply NULL when a command is sent?

if not ply:IsValid() or ply:IsSuperAdmin() then



It’s safe. The engine lets people send commands before they are valid, but Garry’s Mod checks for this before Lua concommands are ran.

No, the player object should always exist when a player executes a command. There was an old exploit a few years back where you could run a command the same frame you disconnected and you could trick the server but no such exploit is in the wild nowadays.

FYI the player object will NOT be valid if you enter the console command into the server console ( If you are using srcds )

We should really have some sort of check for that though. It doesn’t make sense for most situations but for something like this and a few others I can think of it would be helpful.

That is the check? Seems like the only sensible behaviour to me.