Author Topic: Schedules.  (Read 1648 times)

Is it possible to start a schedule and then end it?

for example:

Code: [Select]
function Wee::OnEnterTrigger(%this, %trigger, %obj){
schedule(5000, 0, "BlahDeBlah", %client);
}

function Wee::OnLeaveTrigger(%this, %trigger, %obj){
//Summin to stop schedule
}

Theres probs a tun of things wrong in that but i just quickly wrote that as an example.

Code: [Select]
function Wee::OnEnterTrigger(%this, %trigger, %obj){
$sch[%obj] = schedule(5000, 0, "BlahDeBlah", %client);
}

function Wee::OnLeaveTrigger(%this, %trigger, %obj){
cancel($sch[%obj]);
}

That'll create a new schedule for every object which enters the trigger. It could be used like this:

Code: [Select]
function Wee::OnEnterTrigger(%this, %trigger, %obj){
$sch[%obj] = %obj.schedule(5000, 0, "kill", 1);
commandtoclient(%obj.client,'centerprint',"Watch out! You die in 5 seconds!",2,2,5000);
}

function Wee::OnLeaveTrigger(%this, %trigger, %obj){
cancel($sch[%obj]);
commandtoclient(%obj.client,'centerprint',"Bah, whatever. You win...",2,2,250);
}

(Unsure whether that code actually works, I think it does...)
« Last Edit: May 27, 2007, 09:36:20 AM by Space Guy »

Randy's Answered it for me:

Quote from: Randy
You must store it as a variable when created:

Code: [Select]
$Schedule = Schedule(10000, 0, "whatever");
Then to cancel:

Code: [Select]
cancel($Schedule);

The trigger datablock has a method that's called every x seconds for every object in the trigger.
Read the tutorial about it here: http://www.codesampler.com/torque.htm.

How many MS = 1 second?


Milli = 1/1000:

1000 millimetres = 1 metre

1000 milliseconds = 1 second