Mirage Source
SHOWING GOLD IN LABEL - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: SHOWING GOLD IN LABEL (/showthread.php?tid=2581)



SHOWING GOLD IN LABEL - Lochie - 28-02-2009

Obvious title.

Right, well I wrote a public function and called it when ever the value of the the item Gold in my inventory changed.
You can see it below.
[spoiler]
Code:
Public Function GetGold(ByVal Index As Long)
Dim i As Long
    For i = 1 To MAX_INV
        If Item(GetPlayerInvItemNum(Index, i)).Type = ITEM_TYPE_CURRENCY Then
            frmMirage.lblGold.Caption = GetPlayerInvItemValue(Index, i)
        End If
    Next
End Function
[/spoiler]
That is supposed to check the Inventory, if it finds an item of Currency type then it will change the caption of lblGold to the value of said item.

I tried changing it to a Sub instead of a function too. Moved it around and all. Still it doens't change the label.

Again, obviously I have done it wrong.

Anyone help me out?


Re: SHOWING GOLD IN LABEL - Matt - 28-02-2009

Why not just search for your item that you created as gold, send it in a packet when you open your inventory and make it display in the label?


Re: SHOWING GOLD IN LABEL - Lochie - 28-02-2009

That question confused me a little. lol

I think I may just create a new item type for Gold.
I don't really want Gold to be in the Inventory list just displayed in a label. Similar to what you see in most RPGs now.
With a small icon next to it for dropping it.

Like this:
[Image: gold.jpg]

But I was trying to work out how I would do the label first before I go into creating a new Item.


Re: SHOWING GOLD IN LABEL - Robin - 01-03-2009

When are you calling the function?


Re: SHOWING GOLD IN LABEL - Lochie - 01-03-2009

Every time the user picks up and item that is of Currency type.
Every time the user drops an item of Currency type.

In the end I made a timer with a 1 second interval and placed the Call function inside there. And still nothing.
I can't even find an issue with it when I run it through Debug and just Step In To the code.


Re: SHOWING GOLD IN LABEL - Robin - 01-03-2009

Lochie Wrote:Every time the user picks up and item that is of Currency type.
Every time the user drops an item of Currency type.

In the end I made a timer with a 1 second interval and placed the Call function inside there. And still nothing.
I can't even find an issue with it when I run it through Debug and just Step In To the code.

Change 'Index' to 'Myindex'.

Index is used to deal with anyone online, Myindex deals with the client's own data.

Nice code. Should change it to just be stored in a variable in the PlayerRec instead.

[Image: rawr-3.png]


Re: SHOWING GOLD IN LABEL - Lochie - 01-03-2009

Ok, I'll try.


Tried.

Failed. God I suck! lol


Subscript Out of Range

Code:
If Item(GetPlayerInvItemNum(MyIndex, i)).Type = ITEM_TYPE_CURRENCY Then

MyIndex = 0
i = 1


Re: SHOWING GOLD IN LABEL - Robin - 01-03-2009

Lochie Wrote:Ok, I'll try.


Tried.

Failed. God I suck! lol


Subscript Out of Range

Code:
If Item(GetPlayerInvItemNum(MyIndex, i)).Type = ITEM_TYPE_CURRENCY Then

MyIndex = 0
i = 1

Make sure you're not running it in a timer anymore. Call it when picking up or dropping an item only.


Re: SHOWING GOLD IN LABEL - Lochie - 01-03-2009

Right. That didn't work but...

Hahaha!
I thought there was an easier way.

Added:
Code:
frmMirage.lblGold.Caption = GetPlayerInvItemValue(MyIndex, i)

to Sub UpdateInventory like this:
[code]For i = 1 To MAX_INV
If GetPlayerInvItemNum(MyIndex, i) > 0 And GetPlayerInvItemNum(MyIndex, i)


Re: SHOWING GOLD IN LABEL - Robin - 01-03-2009

[quote="Lochie"]Right. That didn't work but...

Hahaha!
I thought there was an easier way.

Added:
Code:
frmMirage.lblGold.Caption = GetPlayerInvItemValue(MyIndex, i)

to Sub UpdateInventory like this:
[code]For i = 1 To MAX_INV
If GetPlayerInvItemNum(MyIndex, i) > 0 And GetPlayerInvItemNum(MyIndex, i)


Re: SHOWING GOLD IN LABEL - Lochie - 01-03-2009

Robin Wrote:Glad you got it working, but your other code worked perfectly well for me, so I'm not sure what went wrong ;D

What went wrong? Me. I am good with theory but not practical.


Re: SHOWING GOLD IN LABEL - Robin - 01-03-2009

Lochie Wrote:
Robin Wrote:Glad you got it working, but your other code worked perfectly well for me, so I'm not sure what went wrong ;D

What went wrong? Me. I am good with theory but not practical.

The fact you got this thing working already has you above most of the forum with programming skill, in my eyes. Add me to MSN. If you get any problems, just send me a message and I can usually help out.


Re: SHOWING GOLD IN LABEL - Lochie - 01-03-2009

I suppose this is the point I do say that I am a 21 year old University student, studing Web Development.
I did VB6 about 3 years ago in college to pass my course which was a BTEC National Diploma for IT Practioners, which involved Software Development. Tongue
I'm a noob with experience. lol


Re: SHOWING GOLD IN LABEL - Robin - 01-03-2009

Lochie Wrote:I suppose this is the point I do say that I am a 21 year old University student, studing Web Development.
I did VB6 about 3 years ago in college to pass my course which was a BTEC National Diploma for IT Practioners, which involved Software Development. Tongue
I'm a noob with experience. lol

Exact same course I'm doing at college at the moment Tongue


Re: SHOWING GOLD IN LABEL - Lochie - 01-03-2009

Tongue Nice.
Well I'll add you to MSN. Don't worry I wont bug you ALL the time. Only when I get stuck and using this forum + google + my many books, can't help me.


Re: SHOWING GOLD IN LABEL - Lochie - 01-03-2009

I never really thought about that actually. VB allows you to add Integers to Labels, I've never really had that problem. The only time I actually use the convert types is when sorting out variables.

Well I added CStr() to it. Just incase. Smile


Re: SHOWING GOLD IN LABEL - Coke - 01-03-2009

Lochie Wrote:I suppose this is the point I do say that I am a 21 year old University student, studing Web Development.
I did VB6 about 3 years ago in college to pass my course which was a BTEC National Diploma for IT Practioners, which involved Software Development. Tongue
I'm a noob with experience. lol

ROFL same course as I did way back when.


Re: SHOWING GOLD IN LABEL - Lochie - 01-03-2009

Fox Wrote:
Lochie Wrote:I suppose this is the point I do say that I am a 21 year old University student, studing Web Development.
I did VB6 about 3 years ago in college to pass my course which was a BTEC National Diploma for IT Practioners, which involved Software Development. Tongue
I'm a noob with experience. lol

ROFL same course as I did way back when.

Yes it is. And if I'm not mistaken, don't you, or used to, live in Hertfordshire, or close? Too many commas there. :roll: