Take Item Only Once From Hotspot [SOLVED]

Started by Thanyx, Sat 24/06/2017 11:38:05

Previous topic - Next topic

Thanyx

Hello,

I am sorry, for this trivial script question, but I am really lost.

I have a hotspot (Locker) and if player interacts with the Locker, he will acquire an item (Pills).

My question is:
How do I code that if the player ever clicked on the hotspot, he will not be able to take pills twice.
Because I tried to code classic "DoOnceOnly" script so if player HasInventory(iPill), then he will say "I already took them".

The problem is, that if player ever gets rid of the Pills, suddenly, player is able to take the Pills from the Locker again.

Any ideas?



Cassiebsg

Well, then I would say you used the DoOnceOnly wrongly.

Try this:
Code: ags

if (Game.DoOnceOnly("Taking pills from locker"))
{
    player.AddInventory(iPill); // This action will only be done once
}
else player.Say("There's nothing else interesting in the locker."); // Every other time the player interacts with the locker he will say this.
There are those who believe that life here began out there...

Thanyx

I am just stupid and used DoOnceOnly really wrongly.

It is so obvious now :) Thank you very much for your help Cassiebsg!


SMF spam blocked by CleanTalk