| Mirage Source http://www.miragesource.net/forums/ |
|
| SHOWING GOLD IN LABEL http://www.miragesource.net/forums/viewtopic.php?f=201&t=5138 |
Page 1 of 11 |
| Author: | Lochie [ Sat Feb 28, 2009 11:13 pm ] |
| Post subject: | SHOWING GOLD IN LABEL |
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: (click to show)
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? |
|
| Author: | Matt [ Sat Feb 28, 2009 11:25 pm ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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? |
|
| Author: | Lochie [ Sat Feb 28, 2009 11:34 pm ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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: ![]() But I was trying to work out how I would do the label first before I go into creating a new Item. |
|
| Author: | Robin [ Sun Mar 01, 2009 12:03 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
When are you calling the function? |
|
| Author: | Lochie [ Sun Mar 01, 2009 12:22 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. |
|
| Author: | Robin [ Sun Mar 01, 2009 12:31 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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.
|
|
| Author: | Lochie [ Sun Mar 01, 2009 12:37 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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 |
|
| Author: | Robin [ Sun Mar 01, 2009 12:40 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. |
|
| Author: | Lochie [ Sun Mar 01, 2009 12:45 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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) <= MAX_ITEMS Then If Item(GetPlayerInvItemNum(MyIndex, i)).Type = ITEM_TYPE_CURRENCY Then frmMirage.lstInv.AddItem i & ": " & Trim$(Item(GetPlayerInvItemNum(MyIndex, i)).Name) & " (" & GetPlayerInvItemValue(MyIndex, i) & ")" frmMirage.lblGold.Caption = GetPlayerInvItemValue(MyIndex, i) '<<<<<< ADDS GOLD TO LABEL!!!!! Else ' Check if this item is being worn If GetPlayerEquipmentSlot(MyIndex, Weapon) = i Or GetPlayerEquipmentSlot(MyIndex, Armor) = i Or GetPlayerEquipmentSlot(MyIndex, Helmet) = i Or GetPlayerEquipmentSlot(MyIndex, Shield) = i Then frmMirage.lstInv.AddItem i & ": " & Trim$(Item(GetPlayerInvItemNum(MyIndex, i)).Name) & " (worn)" Else frmMirage.lstInv.AddItem i & ": " & Trim$(Item(GetPlayerInvItemNum(MyIndex, i)).Name) End If End If Else frmMirage.lstInv.AddItem "<free inventory slot>" End If Next And it works. That was another waste of time trying to over complicate things. I think that is what Matt told me to do actually. Just I didn't understand. Obviously that will cause trouble when using multiple currency items. Which is why I was going to make a new item type: ITEM_TYPE_GOLD but atleast it works. |
|
| Author: | Robin [ Sun Mar 01, 2009 12:48 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
Lochie wrote: 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) <= MAX_ITEMS Then If Item(GetPlayerInvItemNum(MyIndex, i)).Type = ITEM_TYPE_CURRENCY Then frmMirage.lstInv.AddItem i & ": " & Trim$(Item(GetPlayerInvItemNum(MyIndex, i)).Name) & " (" & GetPlayerInvItemValue(MyIndex, i) & ")" frmMirage.lblGold.Caption = GetPlayerInvItemValue(MyIndex, i) '<<<<<< ADDS GOLD TO LABEL!!!!! Else ' Check if this item is being worn If GetPlayerEquipmentSlot(MyIndex, Weapon) = i Or GetPlayerEquipmentSlot(MyIndex, Armor) = i Or GetPlayerEquipmentSlot(MyIndex, Helmet) = i Or GetPlayerEquipmentSlot(MyIndex, Shield) = i Then frmMirage.lstInv.AddItem i & ": " & Trim$(Item(GetPlayerInvItemNum(MyIndex, i)).Name) & " (worn)" Else frmMirage.lstInv.AddItem i & ": " & Trim$(Item(GetPlayerInvItemNum(MyIndex, i)).Name) End If End If Else frmMirage.lstInv.AddItem "<free inventory slot>" End If Next And it works. That was another waste of time trying to over complicate things. I think that is what Matt told me to do actually. Just I didn't understand. Obviously that will cause trouble when using multiple currency items. Which is why I was going to make a new item type: ITEM_TYPE_GOLD but atleast it works. Matt said you should have gold as a set item and have it sent to the client in a packet when the inventory is opened. Glad you got it working, but your other code worked perfectly well for me, so I'm not sure what went wrong ;D |
|
| Author: | Lochie [ Sun Mar 01, 2009 12:50 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. |
|
| Author: | Robin [ Sun Mar 01, 2009 12:53 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. |
|
| Author: | Lochie [ Sun Mar 01, 2009 12:56 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. I'm a noob with experience. lol |
|
| Author: | Robin [ Sun Mar 01, 2009 12:59 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. I'm a noob with experience. lol Exact same course I'm doing at college at the moment |
|
| Author: | Lochie [ Sun Mar 01, 2009 1:03 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. |
|
| Author: | Lea [ Sun Mar 01, 2009 3:27 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
I'm surprised that worked You're setting the label's caption to an integer value, not a string. VB probably took care of that for you, but you might want to call the type conversion yourself just in case. |
|
| Author: | Lochie [ Sun Mar 01, 2009 3:32 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. |
|
| Author: | Coke [ Sun Mar 01, 2009 7:31 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. I'm a noob with experience. lol ROFL same course as I did way back when. |
|
| Author: | Lochie [ Sun Mar 01, 2009 8:07 am ] |
| Post subject: | Re: SHOWING GOLD IN LABEL |
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. 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. |
|
| Page 1 of 11 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|