Author Topic: Time event?  (Read 702 times)

How do i do a time event like burn player that burns you for the amount of time you put in?

  delay    events

     0        onactivate>player>burnplayer [ time goes here (seconds) ]


if you wanna do something else like paint a brick blue for 3 seconds then back to normal

  delay    events

     0        onactivate>self>setcolor> blue

  3000     onactivate>self>setcolor>[color it was before being blue]


in the delay box the time is in miliseconds so 1 sec = 1000 ms   3 secs = 3000 ms     
« Last Edit: February 29, 2012, 06:00:57 PM by Dante77 »

He means with TorqueScript, not with actual events.

Look in to schedules, that's what you need.

Code: [Select]
function BurnPlayer(%Client,%BurnLoops)
{
if(!isObject(%Client))
return;

if(%BurnLoops < 1)
return;

if(!isObject(%Client.Player))
return;

%BurnLoops--;
%Player = %Client.Player;

%Player.AddHealth(-5);
%Player.Burn(1);

Schedule(1000,0,BurnPlayer,%Client,%BurnLoops);
}

Code: [Select]
BurnPlayer(FindClientByName("Name"),5);
I don't really know what you were asking for but I figured it was something along the lines of this, if not please attempt to explain yourself better

It's either on a loop like said above or activated then de-activated by a schedule.

Im not asking for the events or burn script,im asking how do i do the timed event script that activates a function and de-activates it after the time ends.
« Last Edit: March 01, 2012, 08:35:54 PM by David819 »

deactivates a function... like stopping a loop? or making it so the function doesn't work?

stopping loop:
Code: [Select]
function quack()
{
  cancel($quack);
  echo(QUACK);
  $quack = schedule(500, 0, quack);
}

function noquack()
{
  cancel($quack);
}

disabling functions
Code: [Select]
$quack = true;
function quack()
{
  if(!$quack)
    return;
  echo(QUACK);
}

function noquack()
{
  $quack = false;
}

function togquack()
{
  $quack = !$quack;
}