Problem with IF statement. (SOLVED)

Started by Daedelus_helios, Sun 08/03/2009 19:40:33

Previous topic - Next topic

Daedelus_helios

HiI'm really sorry about this, i mean i know its rediculously simple lol but please help:

Ok so i have this:

function hHotspot4_WalkOn()
{
  if(cNick.HasInventory(iJournal)){cNick.ChangeRoom(2, 328, 362);}
  else cNick.Say("I should check this area before i go out there");
  cNick.Walk(500, 300, eBlock, eWalkableAreas);
}

so when he walks on it to leave the room it checks if he has the journal, else he says "" and then walks back.
But even if he has it he walks back and then leaves the room. so is there a way of having the else include two tasks without the walk applying to the if? thanks in advance :)

GarageGothic

It should be:

Code: ags
function hHotspot4_WalkOn() {
  if (cNick.HasInventory(iJournal)) cNick.ChangeRoom(2, 328, 362);
  else {
    cNick.Say("I should check this area before i go out there");
    cNick.Walk(500, 300, eBlock, eWalkableAreas);
   }
}


Because there are no brackets following your "else" statement it only pertains to the Say line, the walk function runs in both cases.

Daedelus_helios

Haha thank you so much, i knew it was some silly little error, i thort the curly brace went on the inside of the ";" lol :) thanks again

SMF spam blocked by CleanTalk