1) It counts the number of tickets for the currently expiring lottery (if any tickets are purchased and if the lottery is expired)
2) It randomly chooses a number between 0 and the number of tickets.
3) It pulls that entry from the MySQL database of the tickets, and thats the winner.
Code:
// send a private message to the user that they have won the lottery
vbplaza_send_pm(0, $userinfo, $title, $message);
It should send a PM to the user who won as well.
-CMX