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

[Eclipse - Event System] TakeItem fix


Ertzel
 Share

Recommended Posts

Right now with any system using JC's event system, the TakeItem does not check if the user has enough of the item to take, it only checks if they have more then 0 of it.

For example, a event requiring 200 of item 1\. A player can have 1 of item 1, 50 of item 1, 200 of item 1, 400 of item 1, ect.. and they will all act the same way and accept it and then take away 200 of item 1\. If the player had less then 200, it will set the number to 0 and not go into negatives.

Also, there is no option in the Conditions branch to check for a certain amount of an item, only for the item itself.

The following tutorial will show how to fix both problems.

- Server Side -

in modEventLogic under ProccessEventCommands replace:```

Case EventType.evChangeItems

If Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 0 Then

If FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1) > 0 Then

Call SetPlayerInvItemValue(i, FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1), Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3)

End If

ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 1 Then

GiveInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3, True

ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 2 Then

TakeInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3

End If

SendInventory i

```
with:```

Case EventType.evChangeItems

If Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 0 Then

If FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1) > 0 Then

Call SetPlayerInvItemValue(i, FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1), Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3)

End If

ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 1 Then

GiveInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3, True

ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 2 Then

Dim itemAmount As Long

itemAmount = HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1)

' Check Amount

If itemAmount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3 Then

TakeInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3

End If

End If

SendInventory i

```

Then replace:```

Case 2

If HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1) > 0 Then

.ListLeftOff(.CurList) = .CurSlot

.CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.CommandList

.CurSlot = 1

Else

.ListLeftOff(.CurList) = .CurSlot

.CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.ElseCommandList

.CurSlot = 1

End If

```
with:```

Case 2

If HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1) >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data2 Then

.ListLeftOff(.CurList) = .CurSlot

.CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.CommandList

.CurSlot = 1

Else

.ListLeftOff(.CurList) = .CurSlot

.CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.ElseCommandList

.CurSlot = 1

End If

```

in SendMapEventData find:```

buffer.WriteLong .chkHasItem

buffer.WriteLong .HasItemIndex

```
Under add:```
buffer.WriteLong .HasItemAmount
```

Find:```

PutVar filename, "Event" & i & "Page" & x, "HasItemIndex", Val(.HasItemIndex)

```
Under add:```
PutVar filename, "Event" & i & "Page" & x, "HasItemAmount", Val(.HasItemAmount)
```

Find:```

.HasItemIndex = Val(GetVar(filename, "Event" & i & "Page" & x, "HasItemIndex"))

```
Under add:```

.HasItemAmount = Val(GetVar(filename, "Event" & i & "Page" & x, "HasItemAmount"))

```

Find:```

.chkHasItem = buffer.ReadLong

.HasItemIndex = buffer.ReadLong

```
Under add:```
.HasItemAmount = buffer.ReadLong
```

Find:```

chkHasItem As Long

HasItemIndex As Long

```
Under add:```
HasItemAmount As Long
```

Thats it for server side. Save/Compile your server.

- Client Side -

Go to frmEditor_Events and beside cmbCondition_HasItem add a new textbox called txtCondition_itemAmount and set it's Text to 0.

Then double click on OptConditions_Index and find:```
cmbCondition_HasItem.Enabled = True
```
Under it add:```
txtCondition_itemAmount.Enabled = True
```

Then find:```
cmbCondition_HasItem.ListIndex = 0
```
Under it add```
txtCondition_itemAmount.Enabled = False

txtCondition_itemAmount.text = "0"
```

Find:```
tmpEvent.Pages(curPageNum).HasItemIndex = cmbHasItem.ListIndex
```
Under it add:```
tmpEvent.Pages(curPageNum).HasItemAmount = txtCondition_itemAmount.text
```

Replace:```

Case 2 'Has Item

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.Condition = 2

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.data1 = frmEditor_Events.cmbCondition_HasItem.ListIndex + 1

```
With:```

Case 2 'Has Item

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.Condition = 2

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.data1 = frmEditor_Events.cmbCondition_HasItem.ListIndex + 1

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.Data2 = Val(frmEditor_Events.txtCondition_itemAmount.text)

```

Replace:```

Case 2

frmEditor_Events.cmbCondition_HasItem.Enabled = True

frmEditor_Events.cmbCondition_HasItem.ListIndex = tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.data1 - 1

```
With:```

Case 2

frmEditor_Events.cmbCondition_HasItem.Enabled = True

frmEditor_Events.txtCondition_itemAmount.Enabled = True

frmEditor_Events.cmbCondition_HasItem.ListIndex = tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.data1 - 1

frmEditor_Events.txtCondition_itemAmount.text = tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.Data2

```

Replace:```

ElseIf frmEditor_Events.optCondition_Index(2).value = True Then

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.Condition = 2

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.data1 = frmEditor_Events.cmbCondition_HasItem.ListIndex + 1

```
With:```

ElseIf frmEditor_Events.optCondition_Index(2).value = True Then

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.Condition = 2

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.data1 = frmEditor_Events.cmbCondition_HasItem.ListIndex + 1

tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(curslot).ConditionalBranch.Data2 = Val(frmEditor_Events.txtCondition_itemAmount.text)

```

Find:```
chkHasItem As Long

HasItemIndex As Long
```
Under it add:```
HasItemAmount As Long
```

Find:```
buffer.WriteLong .chkHasItem

buffer.WriteLong .HasItemIndex
```
Under it add:```
buffer.WriteLong .HasItemAmount
```

Find:```
frmEditor_Events.cmbHasItem.ListIndex = .HasItemIndex
```
Under it add:```
frmEditor_Events.txtCondition_itemAmount.text = .HasItemAmount
```

Find:```
.chkHasItem = buffer.ReadLong

.HasItemIndex = buffer.ReadLong
```
Under it add:```
.HasItemAmount = buffer.ReadLong
```

Replace:```

Case 2

frmEditor_Events.lstCommands.AddItem indent & "@>" & "Conditional Branch: Player Has Item [" & Trim$(Item(tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(i).ConditionalBranch.data1).name) & "]"

```

With:```

Case 2

frmEditor_Events.lstCommands.AddItem indent & "@>" & "Conditional Branch: Player Has Item [" & Trim$(Item(tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(I).ConditionalBranch.data1).name) & "] Amount [" & tmpEvent.Pages(curPageNum).CommandList(curlist).Commands(I).ConditionalBranch.Data2 & "]"

```

Then save/compile your client!

Your Conditional Branch should look something like this now (in-game)

>! ![](http://i50.tinypic.com/1533bd5.png)

Now you can use the Condition Branche's to check for an item and a certain amount of it and the TakeItem will only take the amount of its avaiable.

Example of a quest looking for a certain 2500 gold and taking it if it passes and sending a message if not…

>! ![](http://i49.tinypic.com/nbayq.png)

The TakeItem code still has it's own check for the right amount incase you don't use the Conditional Branch in your event also.
Link to comment
Share on other sites

  • 3 weeks later...
ummm… what? This lets you take an amount of a stackable item, not take away more then one item in one code. This has been used by me and a decent amount of other people (as well as in EM) and no one else has reported any problems with it.
Link to comment
Share on other sites

Can anyone else confirm if they are having problems with this? When I coded it, it was done in a default version of 2.3 so I don't see how it's not working for you. Also no one else has yet to confirm any bugs with it so if anyone else has had problems please post them so I know because I can't debug something that has no bugs when I run it.
Link to comment
Share on other sites

Alright, so I apologise. Turns out I had 1 mistake. I put 1 line of your code, above another line of code, when you said to put it under. Order matters. Again my aplogies mate, works fine ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)

You should add this for items that are not curreny. It only works for currency/stackable items. You should add it so it dosent just need stackables
Link to comment
Share on other sites

To make it so you can take more of an item with unstackable items, these changes should work….

**Note, this is untested so there may be some small errors in it, if there are please post them and I'll look into a fix**

Click to see the code**:**

>! - Server Side -
>! replace:```
>! Case EventType.evChangeItems
>! If Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 0 Then
>! If FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1) > 0 Then
>! Call SetPlayerInvItemValue(i, FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1), Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3)
>! End If
>! ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 1 Then
>! GiveInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3, True
>! ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 2 Then
>! Dim itemAmount As Long
>! itemAmount = HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1)
>! ' Check Amount
>! If itemAmount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3 Then
>! TakeInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3
>! End If
>! End If
>! SendInventory i
>! ```
With:```
>! Case EventType.evChangeItems
>! If Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 0 Then
>! If FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1) > 0 Then
>! Call SetPlayerInvItemValue(i, FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1), Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3)
>! End If
>! ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 1 Then
>! GiveInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3, True
>! ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 2 Then
>! Dim itemAmount As Long
>!
>! ' Check if item is stackable/currency
>! If Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1).Type = ITEM_TYPE_CURRENCY Or Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1).Stackable > 0 Then
>! For z = 1 To MAX_INV ' Loop through inventory checking for the item and making a count of it
>! If GetPlayerInvItemNum(index, z) = itemnum Then
>! itemAmount = itemAmount + 1
>! End If
>! Next
>!
>! If itemAmount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3 Then
>! For z = 1 To itemAmount ' Loop back through inventory taking the item as many times as needed
>! TakeInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, 1
>! Next
>! End If
>! Else
>! itemAmount = HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1)
>!
>! ' Check Amount
>! If itemAmount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3 Then
>! TakeInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3
>! End If
>! End If
>! End If
>! SendInventory i
>! ```
>! Then replace:```
>! Case 2
>! If HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1) >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data2 Then
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.CommandList
>! .CurSlot = 1
>! Else
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.ElseCommandList
>! .CurSlot = 1
>! End If
>! ```
With:
>! ```
>! Case 2
>! If Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1).Type = ITEM_TYPE_CURRENCY Or Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1).Stackable > 0 Then
>! Dim curCount As Byte
>! For z = 1 To MAX_INV
>! If GetPlayerInvItemNum(index, z) = itemnum Then
>! curCount = curCount + 1
>! End If
>! Next
>!
>! If curCount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data2 Then
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.CommandList
>! .CurSlot = 1
>! Else
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.ElseCommandList
>! .CurSlot = 1
>! End If
>! Else
>! If HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1) >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data2 Then
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.CommandList
>! .CurSlot = 1
>! Else
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.ElseCommandList
>! .CurSlot = 1
>! End If
>! End If
>! ```
Link to comment
Share on other sites

wait, sorry I did that edit looking at my EM source and I don't think default Event System allows stackable items other then currency. Remove the```

Or Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1).Stackable > 0

```in both changes I posted.
Link to comment
Share on other sites

get "index" not defined, so I added it, itemnum, not defined. then i just get a runtime error 9\. Might want to cleanly add it to the tutorial for default eo 2.3
Link to comment
Share on other sites

lols, sorry errors happen when I can't actually test and am writing these in a VM thats laggy as duck. Also trying to add this to a default EO 2.3 is pointless as my current version is just a default EO 2.3 with just this system added to it. The problem is I cannot compile/test shit with vb6 because I don't have a working PC atm only my mac.

This should work (but it's written in notepad not vb6 as I can't compile/test so it may have some bugs still)

>! Replace:```
>! Case EventType.evChangeItems
>! If Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 0 Then
>! If FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1) > 0 Then
>! Call SetPlayerInvItemValue(i, FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1), Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3)
>! End If
>! ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 1 Then
>! GiveInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3, True
>! ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 2 Then
>! Dim itemAmount As Long
>! ' Check if item is stackable/currency
>! If Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1).Type = ITEM_TYPE_CURRENCY Or Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1).Stackable > 0 Then
>! For z = 1 To MAX_INV ' Loop through inventory checking for the item and making a count of it
>! If GetPlayerInvItemNum(index, z) = itemnum Then
>! itemAmount = itemAmount + 1
>! End If
>! Next
>! If itemAmount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3 Then
>! For z = 1 To itemAmount ' Loop back through inventory taking the item as many times as needed
>! TakeInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, 1
>! Next
>! End If
>! Else
>! itemAmount = HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1)
>! ' Check Amount
>! If itemAmount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3 Then
>! TakeInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3
>! End If
>! End If
>! End If
>! SendInventory i
>! ```
With:```
>! Case EventType.evChangeItems
>! If Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 0 Then
>! If FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1) > 0 Then
>! Call SetPlayerInvItemValue(i, FindItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1), Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3)
>! End If
>! ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 1 Then
>! GiveInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3, True
>! ElseIf Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data2 = 2 Then
>! Dim itemAmount As Long, itemCount As Long
>! ' Check if item is stackable/currency
>! If Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1).Type = ITEM_TYPE_CURRENCY Or Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1).Stackable > 0 Then
>! itemAmount = 0
>! For itemCount = 1 To MAX_INV ' Loop through inventory checking for the item and making a count of it
>! If GetPlayerInvItemNum(i, itemCount) = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1 Then
>! itemAmount = itemAmount + 1
>! End If
>! Next
>! If itemAmount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3 Then
>! For itemCount = 1 To itemAmount ' Loop back through inventory taking the item as many times as needed
>! TakeInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, 1
>! Next
>! End If
>! Else
>! itemAmount = HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1)
>! ' Check Amount
>! If itemAmount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3 Then
>! TakeInvItem i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data3
>! End If
>! End If
>! End If
>! SendInventory i
>! ```
>! Replace:```
>! Case 2
>! If Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1).Type = ITEM_TYPE_CURRENCY Or Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1).Stackable > 0 Then
>! Dim curCount As Byte
>! For z = 1 To MAX_INV
>! If GetPlayerInvItemNum(index, z) = itemnum Then
>! curCount = curCount + 1
>! End If
>! Next
>! If curCount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data2 Then
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.CommandList
>! .CurSlot = 1
>! Else
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.ElseCommandList
>! .CurSlot = 1
>! End If
>! Else
>! If HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1) >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data2 Then
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.CommandList
>! .CurSlot = 1
>! Else
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.ElseCommandList
>! .CurSlot = 1
>! End If
>! End If
>! ```
With:
>! ```
>! Case 2
>! If Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1).Type = ITEM_TYPE_CURRENCY Or Item(Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1).Stackable > 0 Then
>! Dim curCount As Byte, invCount As Long
>! For invCount = 1 To MAX_INV
>! If GetPlayerInvItemNum(i, invCount) = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).Data1 Then
>! curCount = curCount + 1
>! End If
>! Next
>! If curCount >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data2 Then
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.CommandList
>! .CurSlot = 1
>! Else
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.ElseCommandList
>! .CurSlot = 1
>! End If
>! Else
>! If HasItem(i, Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data1) >= Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.Data2 Then
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.CommandList
>! .CurSlot = 1
>! Else
>! .ListLeftOff(.CurList) = .CurSlot
>! .CurList = Map(GetPlayerMap(i)).Events(.eventID).Pages(.pageID).CommandList(.CurList).Commands(.CurSlot).ConditionalBranch.ElseCommandList
>! .CurSlot = 1
>! End If
>! End If
>! ```

Basically index just had to be changed to i and I removed itemnum (which I never declared as anything lol) and replaced it with the code to find the itemnum based on the event.
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...