Qazek Posted April 23, 2013 Author Share Posted April 23, 2013 Yeah I have some problem with function TakeInvItem (server). I am using EO 3.0 Electrified EventsWhat's wrong? I added new variable named "Currency" to item data to have the same items in one slot (like gold). And now for example:1\. I have 3 the same consume item in one slot2\. When I use item the system takes 3 items, not 1 and add HP from one item.Here's my pieces of TakeInvItem and TakeInvSlot:```Function TakeInvItem(ByVal index As Long, ByVal itemnum As Long, ByVal ItemVal As Long) As BooleanDim i As LongDim n As LongTakeInvItem = False' Check for subscript out of rangeIf IsPlaying(index) = False Or itemnum <= 0 Or itemnum > MAX_ITEMS Then Exit FunctionEnd IfFor i = 1 To MAX_INV ' Check to see if the player has the item If GetPlayerInvItemNum(index, i) = itemnum Then If Item(itemnum).Type = ITEM_TYPE_CURRENCY Then ' Is what we are trying to take away more then what they have? If so just set it to zero If ItemVal >= GetPlayerInvItemValue(index, i) Then TakeInvItem = True Else Call SetPlayerInvItemValue(index, i, GetPlayerInvItemValue(index, i) - ItemVal) Call SendInventoryUpdate(index, i) End If Else TakeInvItem = True End If If Item(itemnum).Currency > 0 Then If ItemVal >= GetPlayerInvItemValue(index, i) Then TakeInvItem = True Else Call SetPlayerInvItemNum(index, i, itemnum) Call SetPlayerInvItemValue(index, i, GetPlayerInvItemValue(index, i) - ItemVal) Call SendInventoryUpdate(index, i) End If Else TakeInvItem = True End If If TakeInvItem Then Call SetPlayerInvItemNum(index, i, 0) Call SetPlayerInvItemValue(index, i, 0) ' Send the inventory update Call SendInventoryUpdate(index, i) Exit Function End If End IfNextEnd Function``````Function TakeInvSlot(ByVal index As Long, ByVal invSlot As Long, ByVal ItemVal As Long) As BooleanDim i As LongDim n As LongDim itemnumTakeInvSlot = False' Check for subscript out of rangeIf IsPlaying(index) = False Or invSlot <= 0 Or invSlot > MAX_ITEMS Then Exit FunctionEnd Ifitemnum = GetPlayerInvItemNum(index, invSlot)If Item(itemnum).Type = ITEM_TYPE_CURRENCY Then ' Is what we are trying to take away more then what they have? If so just set it to zero If ItemVal >= GetPlayerInvItemValue(index, invSlot) Then TakeInvSlot = True Else Call SetPlayerInvItemValue(index, invSlot, GetPlayerInvItemValue(index, invSlot) - ItemVal) End IfElse TakeInvSlot = TrueEnd IfIf Item(itemnum).Currency > 0 Then ' Is what we are trying to take away more then what they have? If so just set it to zero If ItemVal >= GetPlayerInvItemValue(index, invSlot) Then TakeInvSlot = True Else Call SetPlayerInvItemValue(index, invSlot, GetPlayerInvItemValue(index, invSlot) - ItemVal) End IfElse TakeInvSlot = TrueEnd IfIf TakeInvSlot Then Call SetPlayerInvItemNum(index, invSlot, 0) Call SetPlayerInvItemValue(index, invSlot, 0) Exit FunctionEnd IfEnd Function``` Link to comment Share on other sites More sharing options...
Qazek Posted April 23, 2013 Author Share Posted April 23, 2013 Ok I changed some lines in TakeInvItem function. Is it free from bugs? XD :```Function TakeInvItem(ByVal index As Long, ByVal itemnum As Long, ByVal ItemVal As Long) As Boolean Dim i As Long Dim n As Long TakeInvItem = False ' Check for subscript out of range If IsPlaying(index) = False Or itemnum <= 0 Or itemnum > MAX_ITEMS Then Exit Function End If For i = 1 To MAX_INV ' Check to see if the player has the item If GetPlayerInvItemNum(index, i) = itemnum Then If Item(itemnum).Type = ITEM_TYPE_CURRENCY Then ' Is what we are trying to take away more then what they have? If so just set it to zero If ItemVal >= GetPlayerInvItemValue(index, i) Then TakeInvItem = True Else Call SetPlayerInvItemValue(index, i, GetPlayerInvItemValue(index, i) - ItemVal) Call SendInventoryUpdate(index, i) End If Else TakeInvItem = True End If If Item(itemnum).Currency > 0 Then If ItemVal = GetPlayerInvItemValue(index, i) Then TakeInvItem = True Else TakeInvItem = False Call SetPlayerInvItemValue(index, i, GetPlayerInvItemValue(index, i) - ItemVal) Call SendInventoryUpdate(index, i) Exit Function End If Else TakeInvItem = True End If If TakeInvItem Then Call SetPlayerInvItemNum(index, i, 0) Call SetPlayerInvItemValue(index, i, 0) ' Send the inventory update Call SendInventoryUpdate(index, i) Exit Function End If End If NextEnd Function``` Link to comment Share on other sites More sharing options...
escfoe2 Posted April 24, 2013 Share Posted April 24, 2013 > Ok I changed some lines in TakeInvItem function. Is it free from bugs? XDAppears to be correct.Did this solve your problem Qazek? Link to comment Share on other sites More sharing options...
Qazek Posted April 25, 2013 Author Share Posted April 25, 2013 Yes, but I'm not sure. For me TakeInvItem function works perfectly ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) Link to comment Share on other sites More sharing options...
escfoe2 Posted April 25, 2013 Share Posted April 25, 2013 > Yes, but I'm not sure. For me TakeInvItem function works perfectly ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)What do you mean by "not sure"? Link to comment Share on other sites More sharing options...
Matt Posted April 25, 2013 Share Posted April 25, 2013 If it works perfectly, then your question is resolved. I'll mark it now. 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