Run the call_out function earlier than scheduled


That is possible to run the call_out function earlier than scheluded?

Here is a simple example:

int cmd_aura ()
   tp->set("aura", 1);
   callout_id = call_out ("aura_end", 100, this_player());
   return 1;

Here is my call_out function:

int aura_end (object tp) 
   tp->set("aura", 0);
   return 1;

Here is what I want (I know this function (feature) does not exists, but easier to visualize):
exec_call_out_now (callout_id); // the ‘aura_end’ function will run and the call_out is done.


call_out() returns void, so it can’t be assigned to callout_id. Maybe your call_out is different though - you’d have to look to see if you can get the argument “this_player()” from the callout_id. If you can, this becomes a bit easier.

exec_call_out_now (callout_id);

The main problem is, unless your callout_id contains some way to get the argument this_player() that you passed to the call_out(), you’ll have to use call_out_info() and iterate through all the call_out()s until you find the one you want. It won’t be difficult to iterate though - you know the object, and you know the function.
find_call_out(“aura_end”) can be used to easily determine if there is a call_out to “aura_end”.
remove_call_out(“aura_end”); can be used to abort the scheduled call_out(“aura_end”).

Assuming callout_id isn’t returned by call_out(), the steps you’d take are:
find_call_out(“aura_end”); //to see if there is a pending call - if you want.
foreach call_out_info() and test for the proper object and function call to find what this_player() was when you called the call_out().
remove_call_out(“aura_end”); //So the call_out isn’t executed later.
aura_end(whatever this_player() was when you scheduled the call_out – get this from call_out_info() if you can’t get it from callout_id)

Thank you the replay!

Unfortunately, the solution is not good for us, there are ~3000 call_outs every 2 seconds.
We are still wondering how it should be :slight_smile:

call_out actually will return a ID, it has been for a while.

we could add a call_out_exec_now() , but there is a question: I don’t think we want to execute callbacks “in the current LPC call stack” . however maybe we could add something that set the delay to 0 so it will execute on next driver tick, would that work?

however maybe we could add something that set the delay to 0 so it will execute on next driver tick, would that work?

This is exactly what we want!
Thank you!