Here is the code, you just need to modify the above example a bit:
if($user_id==0 and $action=='vtopic' and $forum==YOUR_FORUM_ID){
$title=$l_accessDenied;
$errorMSG='Only registered users are allowed to view this forum.<br />';
//Loading header & warning page
echo load_header();
echo ParseTpl(makeUp('main_warning'));
//Loading footer
$endtime=get_microtime();
$totaltime=sprintf ("%01.3f", ($endtime-$starttime));
if(isset($includeFooter)) include($includeFooter); else echo ParseTpl(makeUp('main_footer'));
exit;
}