Author Topic: Schedules Going Haywire!?  (Read 1273 times)

Whenever I set a schedule above about 20-30 minutes, the schedule goes crazy and loops every millisecond, however, when set below that, it acts normally:
Code: [Select]
function functionhere()
{
    cancel($varhere);
    //stuffhere
    $varhere = schedule(60000*30,0,functionhere);
}

This also happens with several other mods. To get a good example of this, check out the Auto Saver and set the autosave time higher than 30- exact same issue I described.

Any ideas on how to fix this?

Thanks

try using an outside global var or something for the minutes

and then a local variable for speed that multiplies it?

that's all i got

Actually I already have a global variable in place of the schedule amount. Let me try without using variables..

function servercmdcallStuff(%client, %t)
{
^Stuff(%t);
}
function Stuff(%t)
{
^if(%t =< 0)
^{
^^stuffHappens;
^}
^else
^^schedule(1000, 0, "Stuff", %t--);
}

You might want to increase the schedule time loop based on what it's doing, but that's a good base for long schedules.

That's what I already have, plus some stuff I don't want/need in there...


That's what I already have, plus some stuff I don't want/need in there...
Yes, that's what you have and the goddamned fix.

60000*30 actually evaluates to "1.8e+006" because Torque can't deal with big numbers.

60000*30 actually evaluates to "1.8e+006" because Torque can't deal with big numbers.
Which is the same, but apparently doesn't work on schedules?

No it's not the same. As I said - Torque can't deal with big numbers. 1.8e+006 is a big number.

Torque uses strings fairly often, possibly for everything. Add one to a string that starts with a number followed by non-numeric characters, and it ignores everything but the number. Schedule probably demands an integer only, so probably only reads up to the first non-number, even though the rest would be a valid number for a floating point type. So, it probably takes the first 1.8, discarding the rest, and occurs almost instantly.

Test results:

1e8: instant
1e7: instant
1e6: instant
1e5: delayed
1e4: delayed
10000000000000000000: delayed
10000000000000000000+1: instant
...
1000000+1: instant
100000+1: delayed
999999+1:instant
999998+1:delayed
1000000-1:delayed

Conclusion: Schedule can accept arbitrarily long integer constants, but numbers at or above one million that are the results of any sort of math will not work.

Also, storing a very long number in a variable and then using it has no problem, as long as no math is involved. Untested: passed as a function argument, returned from a function.

Also: string functions do not cause long numbers to become short.


So, my conclusion: schedule will not accept a floating point number at or above one million, but will accept a string or unaltered number above one million.

Edit: numbers at or above one million with a decimal will become instantaneous, too.

Code: [Select]
echo(31313311 *3);Returns 93939933

Code: [Select]
$var = 31313311; 
$var2 = 3; 
$var3 = $var * $var2; 
echo($var3); 
Returns 93939936


???

Code: [Select]
$var = 31313311; 
$var2 = 3; 
$var3 = $var * $var2; 
echo($var3); 
Returns 93939936
9.39399+e007


No it's not the same. As I said - Torque can't deal with big numbers. 1.8e+006 is a big number.
Yeah.

That's what I meant.