Well, it's just the same way as online.php does it, if online.php wouldn't show them on the list, there online bit shouldn't be set. The user id:s of the users online could be stored (they should be in w3t_Online), and then two update queries on the user table:
UPDATE w3t_Users SET U_Online = 0 WHERE U_Online = 1 AND U_Number NOT IN ( list_of_id:s )
UPDATE w3t_Users SET U_Online = 1 WHERE U_Number IN ( list_of_id:s )
But if showflat/showthreaded already reads the online table your idea should work.