Thanks for your feedback Bielie, but i made this script a long time ago and people were asking if I could give them the script. All the things you said I do know (now), but I can't be bothered editing.
I don't think it is neccesairy to write to scriptdir, aslong as you're using $read(ini) with the same dir. Correct me if i'm wrong.
You guys were right about the message part. I changed it ($active to $appactive), works now