Having code run if player has certain Items

Started by gho777, Thu 10/05/2007 03:24:39

Previous topic - Next topic

gho777

sorry to bother again, but i've been three days trying to solve this.
I want something to happen after the player gets three different items (PLEASE READ ALL BEFORE YOU ANSWER). I tryed first using
if ((player.InventoryQuantity[5] == 1) && (player.InventoryQuantity[6] == 1)) {   
    Display ("something");     
  }
as it's shown in the tutorial, but it didn't work. I figured it was becouse of the "player.InventoryQuantity[5]" part, so I tryed with
if ((player.InventoryQuantity[5] == 1) {   
    Display ("something");     
  }
but it didn't work either
i tried using an int (every time the player picked up an object it would ++, then i'd use if(counter == 2)..etc) but it didn't work either.
I tried using SetglobalInt, but I don't quite understand how it works
HELP!!

Gilbert

#1
Instead of '==0' try 'player.InventoryQuantity[5] > 0' or just 'player.InventoryQuantity[5]'.

It's possible that when the player gets an item he gets more than one of it, so just checking if he has EXACTLY 1 of each item may not work.

Also, make sure that the number that refer to the items are correct, you may also use the o-name method (like iKey.ID) to refer to the items which make codes more readible.

Lastly, where did you put that part of codes actually? It's possible that they're placed somewhere in the script which will never be executed.

gho777

no, that didn't work either
all this i wrote it in a "run script" interaction under "first time player enters room"
any other idea?

Khris

This will only be run once, so you'd have to enter the specific room for the message to be displayed.
You'll want to put the code inside the repeatedly_execute function in the global script.

SMF spam blocked by CleanTalk