If you're actually using the timer to start when they donate and run for 30 days you're putting yourself at risk for restarts and other fun stuff. Its safer to have the script remember the time as a unix_time that can be constantly polled against with the timer.
Try this instead (this is semi-pseudocode, so you might have to look up some functions, and I haven't tested any of this). I'm still retired from scripting by the way
Code:
// in global variable section before declaring the default state
integer unix_time;
integer unix_time_last_donated;
integer last_nagged;
integer days_between_nags = 1;
float timer_interval = 900; // fifteen minutes should be enough (not sure if this is an int)
// After the llGiveMoney function
// Conditions: money must come from object owner
unix_time_last_donated = llGetUnixTime();
llSetTimerEvent(timer_interval);
// also trap day/date/time of donation to use in your text response
// New function, stick it ahead of state declaration
integer days_since()
{
unix_time = llGetUnixTime();
// this checks how many days have passed. Don't forget parenthesis!
float days = (unix_time - unix_time_last_donated) / (60*60*24);
return (integer)days;
}
// Add an on_rez event in case of restarts and other carelessness
on_rez()
{
// only start timer if owner has previously donated
if (unix_time_last_donated != 0) {
llSetTimerEvent(timer_interval);
}
}
// in touch event
// condition: owner has touched
integer days = days_since();
llWhisper("You last donated to SLU "+(string)days+" days ago";
if (days > 30) {
llWhisper("Isn't it time you donated again?");
}
// timer event
// don't do anything if owner hasn't donated yet
if (unix_time_last_donated > 0) {
integer days = days_since();
integer unix_time = llGetUnixTime();
if (days > 30) {
if ((last_nagged == 0) || (last_nagged > (60*60*24*days_between_nags)) {
last_nagged = llGetUnixTime();
// IM owner a donation reminder
} // ... if ((last_naged == 0...
} // ... if (days > 30...
} // ... if (unix_time_last_donated... You can also opt to save unix_time_last_donated to the description field and read it in the on_rez event to let the reminder object remember after a script reset after clearing. You'll probably want to save it as unix_time_last_donated/(60*60*24) in that case so if the owner mouses over it they can see how many days have passed with a hover instead of having to click on it. You'll undo the division when you read it back in on on_rez