Author Topic: Need some help please.  (Read 745 times)

Trying to make this Send a message every certain number of minutes.
Script executes, and Rtb Prefs load, and start/stop commands function. But other than that, it doesn't work. What am I doing wrong?

Code: [Select]
function AnnounceTime_Loop()
{
cancel($AnounceTime::Loop);
if($AnounceTime::AnnounceTime < 1)
{
    $AnounceTime::AnnounceTime = 1;
        }
            $AnounceTime::Loop = schedule($AnounceTime::AnnounceTime * 60000,0,"AnnounceTime");
            AnnounceMsg();
}

function AnnounceMsg()
{
%aamsg = $Pref::Server::AutoAnnounce;
         messageAll('',"\c3 @ %aamsg @");
}


Schedule takes these arguments:

schedule( delay, anchor, function, arg1, arg2 ....)

you have:
delay = $AnounceTime::AnnounceTime * 60000
anchor = 0
function = AnnounceTime

so where is your function named "AnnounceTime" ?

Okay now. Now the problem is, is it sends the message on /startaa and it does not loop.

Code: [Select]
function AnnounceTime_Loop()
{
cancel($AnounceTime::Loop);
if($AnounceTime::AnnounceTime < 1)
{
   $AnounceTime::AnnounceTime = 1;
        }
            $AnounceTime::Loop = schedule($AnounceTime::AnnounceTime * 60000,0,"AnnounceTime");
}

function AnnounceTime()
{
%aamsg = $Pref::Server::AutoAnnounce;
         messageAll('',"\c3" @ %aamsg @ "\c3.");
}


function serverCmdStartAA(%client)

{
if(%client.isSuperAdmin)
{
cancel($AnounceTime::Loop);
$AnounceTime::Loop = schedule($AnounceTime::AnnounceTime * 60000,0,"AnnounceTime");
messageAll('',%client.getPlayerName() @ "\c3 has started the ***.");
}
else
{
messageClient(%client,'',"\c6Only \c0Super Admins\c3 may start the ***.");
}
}

so now brown townyze whats going on.

you type: /startAA
 that calls serverCmdStartAA(%client)

.... then what gets called?


How is that different than what you want to happen.

But what I want it to do, is call the function AnnounceTime again in the specified number of minutes, which it does not do. For the life of me I can't figure out why.

In your schedule, your not calling the function that is supposed to loop, and your not calling the AnnounceTime() function. Change the schedule function callback from "AnnounceTime" to "AnnounceTime_Loop". And add AnnounceTime(); in the AnnounceTime_Loop function.

Thank you guys, it works flawlessly now.