Author Topic: Overflow  (Read 536 times)

How would I make sure that a function is not executed more than 1 time per 3 seconds?
Like an anti spam filter?

Code: [Select]
function asdf()
{
if(getSimTime()-$lasttime < a number)
{
$lasttime = getSimTime();
do stuff here
}
else
{
error stuff here
}
}

if ( $Sim::Time - $YourTimeStorageVariable < 1 / 3 )
{
    return;
}

$YourTimeStorageVariable = $Sim::Time;

...










Code: [Select]
function asdf()
{
if(getSimTime()-$lasttime < a number)
{
$lasttime = getSimTime();
do stuff here
}
else
{
error stuff here
}
}

wow gtfo



« Last Edit: August 29, 2012, 11:20:52 AM by Port »

To me it says 10 am, not 5 pm.
Wow, you must be in a drastically different timezone.

also

Code: [Select]
function asdf()
{
if(getSimTime()-$lasttime < a number)
{
$lasttime = getSimTime();
do stuff here
}
else
{
error stuff here
}
}

  • this will run the code if it was executed within the last xxx, not if it wasn't
  • once Blockland has been running for 16 minutes, this will start to get more and more broken as time passes
« Last Edit: August 29, 2012, 11:23:29 AM by Port »

  • this will run the code if it was executed within the last xxx, not if it wasn't
Yes I know

  • once Blockland has been running for 16 minutes, this will start to get more and more broken as time passes
Not if you use a spaaacial script that I made, if OP wants it just pm me.

Not if you use a spaaacial script that I made, if OP wants it just pm me.

or you could just

if ( $Sim::Time - $YourTimeStorageVariable < 1 / 3 )
{
    return;
}

$YourTimeStorageVariable = $Sim::Time;

...


It was just a simple example I made. If you wanna get all picky about the details then yours would be preferred.