IsTimerExpired function not working

Started by Gepard, Mon 03/09/2007 23:47:32

Previous topic - Next topic

Gepard

function repeatedly_execute()
  {
  if (IsTimerExpired(1) == 1) {
output.Text="MESSAGE";
SetGlobalInt(2, 1);
}

  if (IsTimerExpired(2) == 1) {
  PlaySound (1);
  Wait (20);
  Display ("Email!");
  player.AddInventory (imail1);
  SetGlobalInt(10, 3);
}

  if (IsTimerExpired(3) == 1) {
  PlaySound (1);
  Wait (20);
  Display ("Email!");
  player.AddInventory (imail2);
}

  if (IsTimerExpired(4) == 1) {
  PlaySound (1);
  Wait (20);
  Display ("Email!");
  player.AddInventory (imail3);
}

  if (IsTimerExpired(5) == 1) {
    PlaySound (1);
    Wait (20);
    Display ("Email!");
    player.AddInventory (ieles);
}
}

I have this in my script. The game save it without any problems, but than when the timer expires, nothing happens.
Drink up me 'arties! Yo ho!

Gilbert

The problem is, where and when did you start the timers?
You must start the timers with SetTimer() (read the manual for details), otherwise theyu won't expire.

Gepard

Here:

function write_Click(GUIControl *control, MouseButton button) {
  if (mail.Text!="") {
String input=String.Format("%s", mail.Text);

if (input=="scheme") {
  if (GetGlobalInt(16)==0) {
  email.Text="MESSAGE";
  SetTimer (5, 200);
  SetGlobalInt (16, 1);
}
}
...

And I tried almost everything. Setting the timer for just 20, 2, 500, nothing works.
Drink up me 'arties! Yo ho!

Ashen

#3
Does the other stuff (e.g. change email.Text and GI16) with the SetTimer command work? If not, do you change GI16 anywhere else? Try adding a few Display commands to the conditions, to check at what point it stops working.

I don't think you need to use the input String, and even if you'd rather use it, String.Format isn't needed:

Code: ags

String input = mail.Text;


Or if you don't mind typing (or pasting) mail.Text a few more times:
Code: ags

if (mail.Text!="") {
  if (mail.Text=="scheme") {
    if (GetGlobalInt(16)==0) {
      email.Text="MESSAGE";
      SetTimer (5, 200);
      SetGlobalInt (16, 1);
    }
  }
//...

This won't have anything to do with your problem, just pointing it out.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk