Nifflr Posted August 19, 2012 Author Share Posted August 19, 2012 Hi there, so I'm new to editing the source code and I'm trying to teach myself – but I've ran into a bit of difficulty and perhaps someone could be of assistance. My problem seems rather simple but I'm stuck.What is the command to get the amount of a specific item that a player has?For example I want to know how many of item 2 (a currency) the player has and save it as a variable.Thanks for reading. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Joyce Posted August 19, 2012 Share Posted August 19, 2012 Well, first off you'd need to figure out which slot the currency is in, after which you can use the **.value** variable to retrieve the value of items stacked in that slot.If this doesn't help I'll write something up, but I figured I'd give you a hint you can fiddle with before flat-out writing the code in response. Link to comment Share on other sites More sharing options...
Nifflr Posted August 19, 2012 Author Share Posted August 19, 2012 Thanks for the help – but I really have no idea how to figure out which slot the currency is in. Sorry for being so hopeless. Link to comment Share on other sites More sharing options...
Joyce Posted August 19, 2012 Share Posted August 19, 2012 ```Public Function GetPlayerItemAmount(Byval Index as Long, Byval ItemNum as Long) as Long dim TempSlot as long ' Check for subscript out of range. If Index <= 0 or Index > MAX_PLAYERS then exit sub If ItemNum <= 0 or ItemNum > MAX_ITEMS then exit sub tempslot = FindItem(Index, ItemNum) if tempslot <> 0 then GetPlayerItemAmount = GetPlayerInvItemValue(Index, Tempslot) end ifEnd Function```I wrote that real quick from the top of my head. May not work, but don't have VB6 to check right now. Link to comment Share on other sites More sharing options...
Nifflr Posted August 19, 2012 Author Share Posted August 19, 2012 Okay, I'm looking at this but I really don't understand it. How do I specify that I want the value of item number two? Would I change```tempslot = FindItem(Index, ItemNum)```to```tempslot = FindItem(Index, 2)```And how would I save this value and refer to it elsewhere? Link to comment Share on other sites More sharing options...
Joyce Posted August 19, 2012 Share Posted August 19, 2012 No no, copy the entire function and call it like:``` ItemVariableHere = GetPlayerItemAmount(Index, 2)```I wrote a function, so you can just call that piece of code over and over using one line. :] Link to comment Share on other sites More sharing options...
Nifflr Posted August 19, 2012 Author Share Posted August 19, 2012 Okay, so where would I put that function that you wrote? Would it perhaps be placed in Game Logic – or would it need to go in the same module that I'm using:```ItemVariableHere = GetPlayerItemAmount(Index, 2)```I'm sorry, I really have very little idea what I'm doing. I'm quite new to doing source edits. Link to comment Share on other sites More sharing options...
Joyce Posted August 19, 2012 Share Posted August 19, 2012 Depends on what you're trying to do. All my function does, is simply create a new command for you to use(To put it very simple). If you copy it in modPlayer at the bottom, you can call it from everywhere in your source and use it whereever you need it. Link to comment Share on other sites More sharing options...
Nifflr Posted August 19, 2012 Author Share Posted August 19, 2012 Hmm, when I use```ItemVariableHere = GetPlayerItemAmount(Index, 2)```It highlights index and tells me that the variable is not defined. Link to comment Share on other sites More sharing options...
Joyce Posted August 19, 2012 Share Posted August 19, 2012 Where are you using this? Some subs and whatnot have different variable names. :] Link to comment Share on other sites More sharing options...
Nifflr Posted August 19, 2012 Author Share Posted August 19, 2012 In Client ModDirectDraw7 BltInventory. Link to comment Share on other sites More sharing options...
Joyce Posted August 19, 2012 Share Posted August 19, 2012 *scratches head* Why in BltInventory? That's a whole other story.. I was assuming it was server side. Are you trying to edit the text rendered onto it, or the image based on values? Link to comment Share on other sites More sharing options...
Nifflr Posted August 19, 2012 Author Share Posted August 19, 2012 Uh… possibly because I have no idea what I'm doing.Let me elaborate on what I'm trying to do. I want a currency system with three types of coins: knuts, sickles and galleons. Each are worth different amounts: 1, 17, and 493 respectively. But on the GUI where it displays the amount of gold you have I want to display the players wealth all in knuts so it is easy to see just how much money they have.I tried to accomplish this by changing this:```' Check if it's gold, and update the label If GetPlayerInvItemNum(MyIndex, i) = 1 Then '1 = gold ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)frmMain.lblGold.Caption = Format$(Amount, "#,###,###,###") & "g"```to this:``` ' Get number of sickles and galleonsSickles = GetPlayerItemAmount(Index, 2) * 17Galleons = GetPlayerItemAmount(Index, 3) * 493 ' Check if it's gold, and update the label If GetPlayerInvItemNum(MyIndex, i) = 1 Then '1 = gold ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) frmMain.lblGold.Caption = Format$(Amount + Sickles + Galleons, "#,###,###,###") & "knuts"``` Link to comment Share on other sites More sharing options...
Joyce Posted August 19, 2012 Share Posted August 19, 2012 There should be a function(Or some code anyway, I mean Amount is defined somewhere) to get amounts client-side already, and it's MyIndex for the player's index on the client. :] I can't really check or write it at the moment, it's 1am and I'm nowhere near my copy of VB6 :[ Link to comment Share on other sites More sharing options...
Nifflr Posted August 19, 2012 Author Share Posted August 19, 2012 Okay, well thank you so much for all the help you have given me. I'll see if maybe I can figure the rest out on my own. Or else hope for someone who has VB6 to come along.Edit: Oh! I think I got it. ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)```' Get number of sickles and galleonsSickles = GetPlayerInvItemValue(MyIndex, 2) * 17Galleons = GetPlayerInvItemValue(MyIndex, 3) * 493' Check if it's gold, and update the labelIf GetPlayerInvItemNum(MyIndex, i) = 1 Then '1 = gold ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)frmMain.lblGold.Caption = Format$(Amount + Sickles + Galleons, "#,###,###,###") & "knuts"```Again, thanks for your help, Gumball. I do feel like I've learned something. Link to comment Share on other sites More sharing options...
Joyce Posted August 20, 2012 Share Posted August 20, 2012 No problem, it's what we're here for. :3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now