Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO 3.0] TakeInvItem


Qazek
 Share

Recommended Posts

Yeah I have some problem with function TakeInvItem (server). I am using EO 3.0 Electrified Events

What'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 slot

2\. 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 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

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 If

Next

End Function
```

```
Function TakeInvSlot(ByVal index As Long, ByVal invSlot As Long, ByVal ItemVal As Long) As Boolean

Dim i As Long

Dim n As Long

Dim itemnum

TakeInvSlot = False

' Check for subscript out of range

If IsPlaying(index) = False Or invSlot <= 0 Or invSlot > MAX_ITEMS Then

Exit Function

End If

itemnum = 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 If

Else

TakeInvSlot = True

End If

If 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 If

Else

TakeInvSlot = True

End If

If TakeInvSlot Then

Call SetPlayerInvItemNum(index, invSlot, 0)

Call SetPlayerInvItemValue(index, invSlot, 0)

Exit Function

End If

End Function
```
Link to comment
Share on other sites

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

Next

End Function
```
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...