Author Topic: Schedule Problem  (Read 3833 times)

So, while making some add-on stuff, I wanted it to update the add-on on the server with a more recent version, and tried making a function called updateAddon taking %addon variable, but encountered some problems with the schedule.

Code: [Select]
function updateAddon(%addon)
{
exec("Add-Ons/"@%addon@"/server.cs");
messageAll('',"\c3UpdateAddon\c6: Add-On\c5 "@%addon@" \c6was executed, reexecuting in 15 seconds.");
schedule(15000,0,'eval','updateAddon',%addon);
}

Help would be appreciated, Tickle.

You shouldn't use single quotes generally, stick with double quotes. Single quotes are for networked strings.

Secondly, you shouldn't be scheduling a call to eval - and the parameters for that are wrong.

You shouldn't use single quotes generally, stick with double quotes. Single quotes are for networked strings.

Secondly, you shouldn't be scheduling a call to eval - and the parameters for that are wrong.
Okay, I've been told you can't call a function but only a package but I'll try:
Code: [Select]
schedule(15000,0,"updateAddon",%addon);

Doubletoast,

Also, one of my tests, the schedule actually didn't come up with an error, but the delay was kinda 33 milliseconds.

Okay, I've been told you can't call a function but only a package but I'll try:
Code: [Select]
schedule(15000,0,"updateAddon",%addon);

This is correct and will work, it must be something else you're doing.

I don't know why, but when I execute it in-game, I crash.
Complete code (server.cs):
Code: [Select]
//Update
function updateAddon(%addon)
{
exec("Add-Ons/"@%addon@"/server.cs");
messageAll('',"\c3UpdateAddon\c6: Add-On \c5 "@%addon@" \c6was executed, reexecuting in 15 seconds.");
schedule(15000,0,"updateAddon",%addon);
}
updateAddon(Mahro_IRC);

Also, it's some add-on which adds server commands to do IRC-like things in-game. It also modifies the default chat behavior.
« Last Edit: November 28, 2009, 09:08:02 AM by Tickle »

Because upon executing, it tries to update itself which triggers another execution which triggers another update which triggers another execution ... and it gets stuck in a loop.

Because upon executing, it tries to update itself which triggers another execution which triggers another update which triggers another execution ... and it gets stuck in a loop.
So, I'd have to do it like, in two diffirent add-ons?

SpeedEdit: I'm going to make Script_UpdateAddon which adds /startupdating Group_Name server command.

So, kinda strange, it works, doesn't crash, but it doesn't re-execute it, so there must be something wrong with the schedule.
Source code (Mahro_UpdateAddon/server.cs):
Code: [Select]
function servercmdstartupdating(%client,%addon)
{
exec("Add-Ons/"@%addon@"/server.cs");
messageAll('',"\c3UpdateAddon\c6: Add-On \c5"@%addon@" \c6was executed, reexecuting in 15 seconds.");
schedule(15000,0,"updateAddon",%addon);
}
When typing /startupdating Mahro_IRC it gives me the message, but never executes again.

Because it's still scheduled to call "updateAddon" ...

Are you even thinking at all?

Because it's still scheduled to call "updateAddon" ...

Are you even thinking at all?
Whoops, sorry, that was kinda idiotic, I'll come back soon.

Reporting back, all works, thanks Ephialtes, really appreciate your help.
Nearly said that I was going to lock, many people don't like locked help topics.

Secondly, you shouldn't be scheduling a call to eval.
Why not? Why is:
Code: [Select]
function trivialTask() {
   $someCounter--;
}
schedule(1000, 0, trivialTask);
better than:
Code: [Select]
schedule(1000, 0, eval, "$someCounter--;");

And this probably doesn't apply, but:
http://www.torquepowered.com/community/forums/viewthread/76274

Really? You bumped this thread to argue irrelevant semantics?

The example you've given is entirely different to what was being discussed in this thread. What I've said in here is specific to the problem.

Why is:
Code: [Select]
function trivialTask() {
   $someCounter--;
}
schedule(1000, 0, trivialTask);
better than:
Code: [Select]
schedule(1000, 0, eval, "$someCounter--;");
No, this is an honest question as what you said contradicts my understanding.