Inventory use problem(SOLVED)

Started by mario62, Fri 01/02/2008 18:08:34

Previous topic - Next topic

mario62

Hi
i downloaded ags yesterday and i need help
my problem:
in ags 3.00 i want my character (cEgo) to use inventory number 4 (or Ticket)  on character (cEgo1) to get in
to the room 3 (airplane)

please help

Code: ags

function cEgo1_UseInv()
{
cEgo.Walk(110,  165,  eBlock);
player.LoseInventory(inventory[4]);
DisplayMessage(17);
DisplayMessage(21);
DisplayMessage(22);
DisplayMessage(23);
player.ChangeRoom(3, 78, 70);
}




OneDollar

It would help if you posted exactly what error/problem you were getting, but I'm guessing that whatever inventory item you use the player will get in. You need a check to find out what inventory item was used, and a way to do this is add an if function to your code...
Code: ags

function cEgo1_UseInv()
{
  if (player.ActiveInventory==iTicket)
  {
    cEgo.Walk(110,  165,  eBlock);
    player.LoseInventory(inventory[4]);
    DisplayMessage(17);
    DisplayMessage(21);
    DisplayMessage(22);
    DisplayMessage(23);
    player.ChangeRoom(3, 78, 70);
  }else{
    cEgo1.Say("I'm sorry, I can't let you in with that");
  }
}


The ActiveInventory property holds the currently used inventory item of the player, so you can use this to check which item they just used. Personally I'd name the other character something other than Ego1, as Ego is a recognised way of referring to the player character. Up to you though.

mario62

thank you
i appreciate your help :)

SMF spam blocked by CleanTalk