You'll have to package startGame to call a recursive lotto drawing function every 5 minutes using schedules, e.g:
package Lotto
{
function startGame()
{
Parent::onMissionLoaded();
schedule(5 * 1000, 0, drawLotto)
}
};
activatePackage(Lotto);
function drawLotto()
{
//determine winning ticket here
schedule(5 * 1000, 0, drawLotto);
}
As for anything related to Cashmod, you can research how that works yourself.