If you wanted to load tips from a txt file on the server, and allow clients to turn their own auto tips on/off, this might be better:
$AutoTipsDelay = 30; // 30 seconds...
package AutoTip {
function serverCmdTips(%client) {
%client.tips = (%client.tips $= "" ? false : !%client.tips);
%onoff = (%client.tips ? "ON" : "OFF");
messageClient(%client, '', '\c2Auto-Tips has been turned \c3%1\c2.', %onoff);
}
function AutoTipsLoop() {
%tip = $tip[ getRandom(1, $tipCount) ];
for(%i = 0; %i < ClientGroup.getCount(); %i++) {
%client = ClientGroup.getObject(%i);
if( %client.tips $= "" || %client.tips == 1 )
messageClient(%client, '', '\c4TIP: \c0%1', %tip);
}
$AutoTipsLoop = schedule($AutoTipsDelay * 1000, 0, "AutoTipsLoop");
}
function serverCmdToggleAutoTips(%client) {
if( %client.isAdmin || %client.isSuperAdmin ) {
if( isEventPending($AutoTipsLoop) ) {
cancel($AutoTipsLoop);
%onoff = "OFF";
} else {
loadAutoTips();
AutoTipsLoop();
%onoff = "ON";
}
messageAll('', '\c3%1\c2 has turned Auto-Tips \c3%2\c2.', %client.name, %onoff);
}
}
function loadAutoTips() {
deleteVariables("$tip*");
%tipFile = "Add-Ons/tips.txt";
if( !isFile(%tipFile) ) {
error("Unable to find tip file:" SPC %tipFile);
return;
}
%file = new FileObject();
%file.openForRead(%tipFile);
while( !%file.isEOF() ) {
%tip = %file.readLine();
$tip[ $tipCount++ ] = %tip;
}
%file.close(); %file.delete();
}
};
activatePackage(AutoTip);
Clients can type /tips to turn auto tips on/off (for them only).
Admins can type /ToggleAutoTips to globally turn auto tips on/off.
I fixed some stuff. By the way, you have to include a tips.txt file with all the tips you want to load (1 tip per line) in the same directory as the script file this code is in (I assume Add-Ons/). Also, the tips won't start until an admin types /ToggleAutoTips, even after it's loaded.