Author Topic: addon where you can set a timer/addon that counts up in a set time and multiple  (Read 1901 times)

do these already exist?


timer to do what?
just a timer that displays somewhere on the screen/in chat for one player

client sided, server sided, made with bricks, just a command?

client sided, server sided, made with bricks, just a command?
Client Sided.

put this code into add-ons/client_timer/client.cs, along with a blank description.txt
Code: [Select]
function timerLoop()
{
cancel($timerSchedule);
NewChatSO.addLine($timerCount++);
$timerSchedule = schedule(1000, 0, timerLoop);
}

package timer
{
function NMH_Type::send(%this)
{
Parent::send(%this);
if(%this.getValue() $= "timer start")
{
$timerCount = 0;
timerLoop();
}
else
if(%this.getValue() $= "timer stop")
cancel($timerSchedule);
}
};
activatePackage(timer);

"timer start" and "timer stop" in chat to start/stop it
it counts in seconds, spamming your chat with a red number once a second
if you want it to act differently, let me know (ie not actually sending the timer start/stop message, changing the colour, different inputs/outputs or whatever)

put this code into add-ons/client_timer/client.cs, along with a blank description.txt
Code: [Select]
function timerLoop()
{
cancel($timerSchedule);
NewChatSO.addLine($timerCount++);
$timerSchedule = schedule(1000, 0, timerLoop);
}

package timer
{
function NMH_Type::send(%this)
{
Parent::send(%this);
if(%this.getValue() $= "timer start")
{
$timerCount = 0;
timerLoop();
}
else
if(%this.getValue() $= "timer stop")
cancel($timerSchedule);
}
};
activatePackage(timer);

"timer start" and "timer stop" in chat to start/stop it
it counts in seconds, spamming your chat with a red number once a second
if you want it to act differently, let me know (ie not actually sending the timer start/stop message, changing the colour, different inputs/outputs or whatever)
can you make it so it has server and client sided capabilities? and so it can repeat itself automatically in a loop? i also want it to just echo a number after a set time.

can you make it so it has server and client sided capabilities?
why

you're being quite vague on what you want it to do
if you're more exact, then I can help you better

Code: [Select]
function timerLoop()
{
cancel($timerSchedule);
commandToServer('messageSent', "5");
$timerSchedule = schedule(10000, 0, timerLoop);
}

package timer
{
function NMH_Type::send(%this)
{
Parent::send(%this);
if(%this.getValue() $= "timer start")
timerLoop();
else
if(%this.getValue() $= "timer stop")
cancel($timerSchedule);
}
};
activatePackage(timer);

that updated code will start/stop on the same chat commands, but will now have you say a number in chat (5)
the timer loops every 10 seconds

not sure what you mean by server+client, while only echoing, so I just went with server+client and ignored the only echoing part

I meant like, so the person joining the server doesnt have to download the addon but can use it anywhere if they have it.

I meant like, so the person joining the server doesnt have to download the addon but can use it anywhere if they have it.
..so a server sided addon that displays the time on a centerprint/bottomprint? no client addon needed?

..so a server sided addon that displays the time on a centerprint/bottomprint? no client addon needed?
Well, sure. More like a server sided timer that counts up in a set amount of seconds but only to a person who has started the command and admins can spy on the timer's count and such.

I don't know exactly how to explain this.

server sided version, now spams admins and the person using it

Code: [Select]
function serverCmdTimer(%client, %msg)
{
if(%msg $= "start")
timerLoop(%client);
else
if(%msg $= "stop")
cancel(%client.timerLoop);
}

function timerLoop(%client)
{
cancel(%client.timerLoop);

for(%i = 0; %i < ClientGroup.getCount(); %i++)
if((%c = ClientGroup.getObject(%i)) == %client || %c.isAdmin)
messageClient(%c, '', "5");

%client.timerLoop = schedule(10000, 0, timerLoop, %client);
}

Thanks. Can you make it do it every 10 seconds or so in a tealish color? That would be perfect.

to make the text teal, change the "5" to "<color:00ffff>5"
you can change that 5 to whatever text/number you want