This has been needed for a long time in games where spec hunting is a big problem, and should probably be turned on/off by the dev (and possibly mods for events).
Basically, you should be able to have Ignore - Spectator, which prevents someone from spectating you. If server is built from scratch, it should even be possible to prevent spectators from seeing you, or your weapons, at all!
Feel free to substitute for better sounding commands:
?ignorespeclist - list of names you're ignoring (should probably include * as a name if it is there)
?permitspeclist - list of names you're allowing (should probably include * as a name by default)
?ignorespec (name1), (name2), etc - adds them to ignore list
?ignorespec *
?permitspec (name1), (name2), etc - removes them from ignore list
?permitspec *
If you want even more flexibility,
?ignorespectrack ?permitspectrack etc which allows them to see you but not spec you. But maybe you should just only have 1 option for simplicity, and allow zone dev to select what type of spec ignore exactly. Changable by mods for events would be a bonus.
Also, if you encode similar commands in C#, you can do cool stuff like making a team visible to spec whenever all of them lose a crown.
player.allowSpectators(boolean)
player.allowSpectatorsByDefault(boolean) - so that he or she can permit friends to spec.