Author Topic: Timed stuff and list all players?  (Read 607 times)

If i want something to happen every 5 minutes, or every 10 or every whatever, Is there a script for it?

I need it for a mod im working on.
and i wanna make a slash cmd that will make it list all the player names, and other chanageable stuff im working on.

Here's an example to schedule something:
Code: [Select]
function startDoingSomething(%delay)
{
if($doingSomething)
return;
doSomething(%delay * 60000); // call the function to do something (starting a loop)
$doingSomething = 1;
}

function stopDoingSomething()
{
if(!$doingSomething)
return;
cancel($somethingSchedule); // cancel the scheduled function call
$doingSomething = 0;
}

function doSomething(%delay)
{
// Do something...
$somethingSchedule = schedule(%delay, 0, "doSomething", %delay); // call this function again after the delay
}
Then you'd use startDoingSomething(delay_in_minutes);

to list the players in chat, you'd use a script like this:
Code: [Select]
function serverCmdListPlayers(%client)
{
for(%i=0;%i<ClientGroup.getCount();%i++)
{
%cl = ClientGroup.getObject(%i);
messageClient(%client, '', '%1 (%2)', %cl.name, %cl.score);
}
}
I've made it write their scores alongside so you can see how you'd add more information to it.
« Last Edit: October 14, 2008, 05:59:13 PM by Randy »

Is the Delays in Milliseconds?

When using schedule it is, however in the function I made I multiplied the input by 60,000 (1 minute in MS).