Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shop Items in stock...
#4
Fox Wrote:I see what you are doing, and I quite like it.

The only thing I would change would be perhaps instead of checking for the restock each time its opened, check it every 10 minutes on the server - that way sometimes people may go to the shops and find what they want is actually out of stock, and have to come back 10 minutes later, instead of just closing the trade window and opening it again.

Nice work :3

Thanks. Hmm. Could I do the check in the server loop? Could you maybe give an example? (I've never messed with the server loop)

Thanks for the response, I appreciate it.

Edit, I added this to server loop, that checks every ten minutes:

Code:
Private Sub UpdateShopStocks()
    Dim i As Long
    Dim N As Long

    For i = 1 To MAX_SHOPS
        For N = 1 To 8

            'Handle what to do if the demand increases
            Select Case Shop(i).TradeItem(N).DemandIncrease
            
                Case 1
                    'add the stock by five.
                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked + 5
                
                Case 5
                    'add the stock by ten.
                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked + 10
                    
                Case 10
                    'add the stock by twenty
                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked + 20
            End Select
            
            'It's in high demand, lets give a stock increase of five.
            'If Shop(i).TradeItem(n).DemandIncrease > 1 Then
            '    'Add five more to the current stock
            '    Shop(i).TradeItem(n).Stocked = Shop(i).TradeItem(n).Stocked + 5
            'End If
            
            'Handle what to do if the demand decreases
            Select Case Shop(i).TradeItem(N).DemandDecrease
            
                Case 1
                    'minus the stock by five.
                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked - 5
                
                Case 5
                    'minus the stock by 10
                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked - 10

                Case 10
                    'NO stock at all
                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked = 0
            End Select

            'No one buys it, why keep a high stock?
            'If Shop(i).TradeItem(n).DemandDecrease >= 1 Then
            '    Shop(i).TradeItem(n).Stocked = Shop(i).TradeItem(n).Stocked - 5
            'End If
        Next
    Next

End Sub

How's it look now?


Edit: When i try to save a shop, this gets highlighted:
Code:
Shop(ShopNum).TradeItem(i).GetValue = CLng(Parse(N + 3))

The CLng(Parse(N=3)) part is subscript out of range.

Edit2: Can get through without the subscript out of range now, Lets test this shall we?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)