SkywardRiver Posted March 8, 2013 Author Share Posted March 8, 2013 So here is my code. The problem is, when the recipe calls for 1 item it takes the whole stack regardless and gives just 1 product item. Any help on this?```Private Sub TakePlayerItems(ByVal Index As Long, ByVal itemID As Long, ByVal itemCount As Long, ByVal startSlot As Long)Dim itemsTaken As LongitemsTaken = 0Dim i As LongIf startSlot > 0 And startSlot <= MAX_INV Then If player(Index).Char(TempPlayer(Index).CurChar).Inv(startSlot).num = itemID Then If Item(itemID).Type = ITEM_TYPE_CURRENCY Or Item(itemID).Stackable Then itemsTaken = player(Index).Char(TempPlayer(Index).CurChar).Inv(startSlot).Value Else itemsTaken = 1 End If player(Index).Char(TempPlayer(Index).CurChar).Inv(startSlot).num = 0 player(Index).Char(TempPlayer(Index).CurChar).Inv(startSlot).Value = 0 Call SendInventoryUpdate(Index, startSlot) End IfEnd IfFor i = 1 To MAX_INV If itemsTaken >= itemCount Then Exit Sub If player(Index).Char(TempPlayer(Index).CurChar).Inv(i).num = itemID Then If Item(itemID).Type = ITEM_TYPE_CURRENCY Then If player(Index).Char(TempPlayer(Index).CurChar).Inv(i).Value > (itemCount - itemsTaken) Then player(Index).Char(TempPlayer(Index).CurChar).Inv(i).Value = player(Index).Char(TempPlayer(Index).CurChar).Inv(i).Value - itemCount + itemsTaken itemsTaken = itemCount player(Index).Char(TempPlayer(Index).CurChar).Inv(i).num = 0 Else itemsTaken = itemsTaken + player(Index).Char(TempPlayer(Index).CurChar).Inv(i).Value player(Index).Char(TempPlayer(Index).CurChar).Inv(i).num = 0 End If Else itemsTaken = itemsTaken + 1 player(Index).Char(TempPlayer(Index).CurChar).Inv(i).num = 0 End If Call SendInventoryUpdate(Index, i) End IfNext iEnd Sub``` Link to comment Share on other sites More sharing options...
tslusny Posted March 8, 2013 Share Posted March 8, 2013 Replaced it with Sub TakePlayerItems from Eclipse Reborn Link to comment Share on other sites More sharing options...
SkywardRiver Posted March 9, 2013 Author Share Posted March 9, 2013 Okay, I replaced it, but Now when crafting something, it gives me an error in do recipe logic. here is the code```Public Function DoRecipeLogic(ByVal index As Long, ByVal RIndex As Long, ByVal SlotA As Long, ByVal SlotB As Long, ByVal productionCount As Long) As BooleanDim itemCount As LongDoRecipeLogic = FalseIf Not (CanPlayerUseRecipe(index, RIndex, True)) Then Exit FunctionitemCount = GetPlayerItemCount(index, Recipe(RIndex).itemID)If itemCount < Recipe(RIndex).itemCount Then Call SendBattleMsg(index, "You need " & Recipe(RIndex).itemCount & " " & GetItemName(Recipe(RIndex).itemID) & " to craft a " & GetItemName(Recipe(RIndex).ResultItem), Red) Exit FunctionEnd IfIf Not (Recipe(RIndex).TileRecipe) And Recipe(RIndex).SecondItem > 0 Then If GetPlayerItemCount(index, Recipe(RIndex).SecondItem) < 1 Then Call SendBattleMsg(index, "You need one " & GetItemName(Recipe(RIndex).SecondItem) & " to craft a " & GetItemName(Recipe(RIndex).ResultItem) & ".", Red) Exit Function End IfEnd IfIf Not (HasInventorySpaceFor(index, RIndex)) Then If Item(Recipe(RIndex).ResultItem).Type = ITEM_TYPE_CURRENCY Then Call SendBattleMsg(index, "You need a free inventory slot to craft a " & GetItemName(Recipe(RIndex).ResultItem) & ".", Red) Else Call SendBattleMsg(index, "You need " & Recipe(RIndex).ResultCount & " free inventory spaces to craft a " & GetItemName(Recipe(RIndex).ResultItem) & ".", Red) End If Exit FunctionEnd IfIf Recipe(RIndex).ToolRequired > 0 And Not (HasTool(index, Recipe(RIndex).ToolRequired)) Then Call SendBattleMsg(index, "You need a " & GetToolTypeName(Recipe(RIndex).ToolRequired) & " to create a " & GetItemName(Recipe(RIndex).ResultItem) & ".", Red) Exit FunctionEnd IfDim firstSlot As Long, secondSlot As LongIf player(index).Char(TempPlayer(index).CurChar).Inv(SlotA).num = Recipe(RIndex).itemID Then firstSlot = SlotA secondSlot = SlotBElse firstSlot = SlotB secondSlot = SlotAEnd IfDim i As LongDim made As Longmade = 0Do While True Call TakePlayerItems(index, Recipe(RIndex).itemID, Recipe(RIndex).itemCount, firstSlot) If Not (Recipe(RIndex).TileRecipe) And Recipe(RIndex).SecondItem > 0 Then Call TakePlayerItems(index, Recipe(RIndex).SecondItem, 1, secondSlot) End If Call GivePlayerItems(index, Recipe(RIndex).ResultItem, Recipe(RIndex).ResultCount) Select Case Recipe(RIndex).Type Case 1: GivePlayerEXP index, Crafting, Recipe(RIndex).Exp Case 2: GivePlayerEXP index, Alchemy, Recipe(RIndex).Exp End Select Call CheckTasks(index, QUEST_TYPE_GOGATHER, Recipe(RIndex).ResultItem) made = made + 1 If made >= productionCount And productionCount > 0 Then Exit Do If Not (CanDoRecipe(index, RIndex)) Then Exit DoLoopDoRecipeLogic = TrueEnd Function```Highlights this section Call TakePlayerItems(index, Recipe(RIndex).itemID, Recipe(RIndex).itemCount, firstSlot)If Not (Recipe(RIndex).TileRecipe) And Recipe(RIndex).SecondItem > 0 ThenCall TakePlayerItems(index, Recipe(RIndex).SecondItem, 1, secondSlot)End If Link to comment Share on other sites More sharing options...
escfoe2 Posted March 21, 2013 Share Posted March 21, 2013 What's the error in that highlighted section? Like 'Subscript out of range'? What's the issue and exactly what line is it breaking on? 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