Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help [SOLVED] Checking for multiple items
Pshyched Offline
Member

Posts: 130
Threads: 21
Joined: Nov 2012
Reputation: 5
#1
[SOLVED] Checking for multiple items

I am trying to code a way to check for multiple items. The obvious way is not working so Im hoping someone may know a way to check for multiple items before finishing it.

Is there an If / Then / Else function within the HPL2 engine script anyway, if so it would make things easier..

I basically want them to try the key, if the player has not got the other keys in their inventory then it just pops up a message saying "I should grab those keys before I leave" and then does nothing else. Once the player has the keys, it does the normal action that I already coded.

Spoiler below!
    void LeavingHouse(string &in asItem, string &in asEntity)
    {
        if(HasItem("BarricadeLockKey")==true)
        and
        if(HasItem("CarterIslandEntranceKey")==true)
        
        {
            SetLevelDoorLocked("HouseDoor", false);
            PlaySoundAtEntity("", "unlock_door", "HouseDoor", 0, false);
            CompleteQuest("LeaveHouse","LeaveHouse");
        }
    }

(This post was last modified: 04-25-2014, 05:52 PM by Pshyched.)
04-25-2014, 04:35 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Checking for multiple items

There is an "else" keyword you can use. It's very simple.

PHP Code: (Select All)
void LeavingHouse(string &in asItemstring &in asEntity)
{
    if(
HasItem("BarricadeLockKey") == true
    
&& HasItem("CarterIslandEntranceKey") == true)
    {
        
SetLevelDoorLocked("HouseDoor"false);
        
PlaySoundAtEntity("""unlock_door""HouseDoor"0false);
        
CompleteQuest("LeaveHouse","LeaveHouse");
    }
    else 
SetMessage("MessageCategory""GrabKeys"3);


It's pretty much just like that. Add the proper message category and entry in your .lang file. You can make else into a block if you want to use more than 1 line.

(This post was last modified: 04-25-2014, 05:15 PM by Mudbill.)
04-25-2014, 05:13 PM
Find
Pshyched Offline
Member

Posts: 130
Threads: 21
Joined: Nov 2012
Reputation: 5
#3
RE: Checking for multiple items

You've been a great help to me these past few days, Thank you Mudbill!

EDIT:

I tried this, it works fine. But then it never let's me use the House Key on the door again. It just says you cannot use this item in this way!

Second Edit:

Fixed it, I just made it so the CallBack does not destroy after being used once.
(This post was last modified: 04-25-2014, 05:52 PM by Pshyched.)
04-25-2014, 05:39 PM
Find




Users browsing this thread: 1 Guest(s)