Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Show Gold Value


Kaymak
 Share

Recommended Posts

Hello Eclipse Community, 

again i got a slight problem where you can help me out.

I want to show the Current Gold in the Players Inventory on the screen.

I manage it to make it with following code:

```
Inventory = 1
amount = GetPlayerInvItemValue(MyIndex, Inventory)
RenderText Font_Default, amount, X + 100, Y + Height - 1, White

```
I have 35 Gold in my Inventory, and it shows correclty on the game screen. But when i move the Gold in the Inventory it does show 0 because it is not on the first InventorySlot anymore.

So how do i make it that the code looks for the gold in the whole inventory and not only in the slot (my gold is the Item Data1)

Thanks for your help!
Link to comment
Share on other sites

You basically call GetPlayerInvItemNum for every invslot and check if it equals to the Gold's item number (The slot you choose while editing the gold in the item editor). For this example, let's consider that there are 35 inventory slots and that 1 is the Gold's item number.

```
for i = 1 to 35
if getplayerinvitemnum(myindex, i) = 1 then ' We found the gold
amount = getplayerinvitemvalue(myindex, i)
exit for
end if
next

```
After you get the amount, render it out. In case amount equals 0, this means that there is no gold. You could check for this and not render any text or render "You have no gold" or something.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...