this setviewdistance x
Not quite. You don't pass an object to the command, only a number:
setviewdistance x
This sets the maximum distance the player can see on his screen. I'm not sure if it has any effect on the AI. You can put that line in any place that you would normally put script-lines: init fields, "on activation" fields (of triggers/WPs), scripts, etc.
Keep in mind that if the player has resistance, then he can manually adjust the viewdistance himself (by going into his video options), even after you set it with this command.
Check here for the com ref entry:
http://www.ofpec.com/COMREF/index.php?action=details&id=322EDIT
I see this was posted in the MP board, so I assume you want to know how it works in MP. I believe the viewdistance will be the same for all players, but I could be mistaken. There is a script here that automatically negotiates the VD for MP:
http://ofpec.com/editors/resource_view.php?id=473