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
How to empty inventory.
W4rpCore Offline
Junior Member

Posts: 6
Threads: 2
Joined: Mar 2013
Reputation: 0
#1
How to empty inventory.

I have been searching for a command that can empty your inventory.

My custom story starts with the main character being in a dream, and i want to empty the inventory of the player after he leaves the dream.

I havent found this anywhere on the forums and google is useless too.

How?
03-10-2013, 06:52 PM
Find
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#2
RE: How to empty inventory.

you have to call this method for every item you have in the inventory:

void RemoveItem(string& asName);

We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
03-10-2013, 07:03 PM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#3
RE: How to empty inventory.

Don't forget to look on the wiki. This page has all the engine scripts for Amnesia: http://wiki.frictionalgames.com/hpl2/amn..._functions

In Ruins [WIP]
03-10-2013, 07:09 PM
Find
W4rpCore Offline
Junior Member

Posts: 6
Threads: 2
Joined: Mar 2013
Reputation: 0
#4
RE: How to empty inventory.

(03-10-2013, 07:03 PM)stonecutter Wrote: you have to call this method for every item you have in the inventory:

void RemoveItem(string& asName);

Isn't there a way to reset everything?

also if I try to remove a lantern, but the player doesnt have one, does it give an error or something? or should i check if the player has one first?
(This post was last modified: 03-10-2013, 07:09 PM by W4rpCore.)
03-10-2013, 07:09 PM
Find
ExpectedIdentifier Offline
Member

Posts: 234
Threads: 10
Joined: Sep 2012
Reputation: 11
#5
RE: How to empty inventory.

(03-10-2013, 07:09 PM)W4rpCore Wrote:
(03-10-2013, 07:03 PM)stonecutter Wrote: you have to call this method for every item you have in the inventory:

void RemoveItem(string& asName);

Isn't there a way to reset everything?

also if I try to remove a lantern, but the player doesnt have one, does it give an error or something? or should i check if the player has one first?

You won't get an error I don't think. Also for things such as tinderboxes/laudanum, just count up how many you have on the entire map and remove that many, that way the inventory will be empty no matter how many the player picks up.
03-10-2013, 07:20 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#6
RE: How to empty inventory.

(03-10-2013, 07:09 PM)W4rpCore Wrote:
(03-10-2013, 07:03 PM)stonecutter Wrote: you have to call this method for every item you have in the inventory:

void RemoveItem(string& asName);

Isn't there a way to reset everything?

also if I try to remove a lantern, but the player doesnt have one, does it give an error or something? or should i check if the player has one first?


It doesn't give any error. No, there isn't a way to reset everything.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
03-10-2013, 07:20 PM
Find
stonecutter Offline
Member

Posts: 140
Threads: 17
Joined: Feb 2011
Reputation: 4
#7
RE: How to empty inventory.

there is a way to check it :

try something like that :
String[] itemList = ("itemName1", "itemName2", "itemName3");

String[] itemList = ("itemName1", "itemName2", "itemName3");

for(int i = 0; i<= itemList.length; i++){
    if(hasItem(itemList[i]) == true){
               removeItem(itemList[i];
    }
}

please consider this is java code, sooo you have to find out how you have to write it in the script file ...

We Shall Arise - Death / Grind from Bavaria
Musicvideo : http://goo.gl/HzxvLK
Facebook : http://goo.gl/9YfYCV
Free Album : http://goo.gl/sEBW2X
03-10-2013, 07:26 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#8
RE: How to empty inventory.

Use an if statement.
Like this.
PHP Code: (Select All)
if(condition)
{
    
// things to do if condition is TRUE
}
else
{
    
// things to do if condition is FALSE

EDIT: For the lantern thing.
For everything, use
PHP Code: (Select All)
void RemoveItem(stringasName); 
On every item.

@No Author
Get the script?
PHP Code: (Select All)
void StartEffectFlash(float afFadeInfloat afWhitefloat afFadeOut);
 
Fades the screen to white.

afFadeIn time in seconds until screen is white
afWhite 
determines to which percentage the screen fades to white (1.0 completely white)
afFadeOut time in seconds until screen is back to normal again 

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 03-11-2013, 03:45 PM by PutraenusAlivius.)
03-11-2013, 03:42 PM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#9
RE: How to empty inventory.

(03-11-2013, 03:42 PM)JustAnotherPlayer Wrote: Use an if statement.
Like this.
PHP Code: (Select All)
if(condition)
{
    
// things to do if condition is TRUE
}
else
{
    
// things to do if condition is FALSE

EDIT: For the lantern thing.
For everything, use
PHP Code: (Select All)
void RemoveItem(stringasName); 
On every item.

@No Author
Get the script?
PHP Code: (Select All)
void StartEffectFlash(float afFadeInfloat afWhitefloat afFadeOut);
 
Fades the screen to white.

afFadeIn time in seconds until screen is white
afWhite 
determines to which percentage the screen fades to white (1.0 completely white)
afFadeOut time in seconds until screen is back to normal again 

Dude, I haven't replied to this thread yet.

[Image: the-cabin-in-the-woods-masked-people.jpg]
03-11-2013, 03:53 PM
Find
W4rpCore Offline
Junior Member

Posts: 6
Threads: 2
Joined: Mar 2013
Reputation: 0
#10
RE: How to empty inventory.

Thanks.

also is there a way to start the game with a black screen and then fade to normal.
do i just use a very quick FadeOut in the beginning?

I am trying to make it so that when the game starts, its all black, says some dialog and then it shows the room the player is in.
03-11-2013, 03:58 PM
Find




Users browsing this thread: 1 Guest(s)