Code:
COM_AddCommand("commandhere", function(player) // Adds command.
if player.mo // This is a nice check to make sure it functions correctly.
insert function here
end // Ends the if statement.
end) // Ends the COM_AddCommand statement.
Function list (under Base Functions): https://mb.srb2.org/showthread.php?t=37219
You can also set the function to a player state with player.mo.state=(S_PLAY_STATE), and other criteria as well.
EDIT: Oh, you don't need help anymore. Leaving the link to your new problem here: http://srb2skybase.org/mb/showthread.php?t=2400