Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SHOWING GOLD IN LABEL
#1
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?
Reply
#2
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?
Reply
#3
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.
Reply
#4
When are you calling the function?
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#5
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.
Reply
#6
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]
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#7
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
Reply
#8
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.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#9
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)
Reply
#10
[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)
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#11
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.
Reply
#12
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.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#13
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
Reply
#14
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
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#15
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.
Reply
#16
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
Reply
#17
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.
Reply
#18
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:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)