Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shop Items in stock...
#1
I've been screwing around for about thirty minutes, and this is what I managed. I haven't gotten to test it, but can you guy see anything that needs to be added/taken from it?

Code:
' ::::::::::::::::::::::::::
' :: Trade request packet ::
' ::::::::::::::::::::::::::
Sub HandleTradeRequest(ByVal Index As Long, _
                       ByRef Parse() As String)
    Dim n As Long
    Dim i As Long
    Dim x As Long
    Dim z As Long
    ' Trade num
    n = CLng(Parse(1))
    
    ' Prevent hacking
    If (n  MAX_TRADES) Then
        Call HackingAttempt(Index, "Trade Request Modification")
        Exit Sub
    End If
    
    ' Index for shop
    i = Map(GetPlayerMap(Index)).Shop
    
    ' Check if inv full
    x = FindOpenInvSlot(Index, Shop(i).TradeItem(n).GetItem)
    
    'If the Demand Increase and Decrease = 0 Then the stock = 10
    '(This is so that, an item that hasn't ever been bought, will be in stock)
    If Shop(i).TradeItem(n).DemandIncrease = 0 And Shop(i).TradeItem(n).DemandDecrease = 0 Then
        Shop(i).TradeItem(n).Stocked = 10
    End If
    
    If x = 0 Then
        Call PlayerMsg(Index, "Trade unsuccessful, inventory full.", BrightRed)
        Exit Sub
    End If

    'Check to see if they have on in stock
    If Shop(i).TradeItem(n).Stocked > 0 Then

        ' Check if they have the item
        If HasItem(Index, Shop(i).TradeItem(n).GiveItem) >= Shop(i).TradeItem(n).GiveValue Then
            Call TakeItem(Index, Shop(i).TradeItem(n).GiveItem, Shop(i).TradeItem(n).GiveValue)
            Call GiveItem(Index, Shop(i).TradeItem(n).GetItem, Shop(i).TradeItem(n).GetValue)
            Call PlayerMsg(Index, "The trade was successful!", Yellow)
            'Minus one from stock
            Shop(i).TradeItem(n).Stocked = Shop(i).TradeItem(n).Stocked - 1
            'Add moar demand
            Shop(i).TradeItem(n).DemandIncrease = Shop(i).TradeItem(n).DemandIncrease + 0.1
            
            '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
            
            '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
        Else
            Call PlayerMsg(Index, "Trade unsuccessful.", BrightRed)
        End If

    Else
        Call PlayerMsg(Index, "This item is not in stock, at the moment!", BrightRed)
    End If

End Sub
Reply
#2
I did some chances, though I'm not sure if they'll work. :\

I need a way to make it check to see if anyone bought that item in the last day/game day.

10 minutes = 1 game hour

Code:
' ::::::::::::::::::::::::::
' :: Trade request packet ::
' ::::::::::::::::::::::::::
Sub HandleTradeRequest(ByVal Index As Long, _
                       ByRef Parse() As String)
    Dim n As Long
    Dim i As Long
    Dim x As Long
    Dim z As Long
    ' Trade num
    n = CLng(Parse(1))
    
    ' Prevent hacking
    If (n  MAX_TRADES) Then
        Call HackingAttempt(Index, "Trade Request Modification")
        Exit Sub
    End If
    
    ' Index for shop
    i = Map(GetPlayerMap(Index)).Shop
    
    ' Check if inv full
    x = FindOpenInvSlot(Index, Shop(i).TradeItem(n).GetItem)
    
    'If the Demand Increase and Decrease = 0 Then the stock = 10
    '(This is so that, an item that hasn't ever been bought, will be in stock)
    If Shop(i).TradeItem(n).DemandIncrease = 0 And Shop(i).TradeItem(n).DemandDecrease = 0 Then
        Shop(i).TradeItem(n).Stocked = 10
    End If
    
    If x = 0 Then
        Call PlayerMsg(Index, "Trade unsuccessful, inventory full.", BrightRed)
        Exit Sub
    End If

    'Check to see if they have on in stock
    If Shop(i).TradeItem(n).Stocked > 0 Then

        ' Check if they have the item
        If HasItem(Index, Shop(i).TradeItem(n).GiveItem) >= Shop(i).TradeItem(n).GiveValue Then
            Call TakeItem(Index, Shop(i).TradeItem(n).GiveItem, Shop(i).TradeItem(n).GiveValue)
            Call GiveItem(Index, Shop(i).TradeItem(n).GetItem, Shop(i).TradeItem(n).GetValue)
            Call PlayerMsg(Index, "The trade was successful!", Yellow)
            'Minus one from stock
            Shop(i).TradeItem(n).Stocked = Shop(i).TradeItem(n).Stocked - 1
            'Add moar demand
            Shop(i).TradeItem(n).DemandIncrease = Shop(i).TradeItem(n).DemandIncrease + 0.1
            
            Select Case Shop(i).TradeItem(n).DemandIncrease
            
                Case 1
                
                    Shop(i).TradeItem(n).Stocked = Shop(i).TradeItem(n).Stocked + 5
                
                Case 5
                    Shop(i).TradeItem(n).Stocked = Shop(i).TradeItem(n).Stocked + 10

                Case 10
                    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
            Select Case Shop(i).TradeItem(n).DemandDecrease
            
                Case 1
                
                    Shop(i).TradeItem(n).Stocked = Shop(i).TradeItem(n).Stocked - 5
                
                Case 5
                    Shop(i).TradeItem(n).Stocked = Shop(i).TradeItem(n).Stocked - 10

                Case 10
                    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

        Else
            Call PlayerMsg(Index, "Trade unsuccessful.", BrightRed)
        End If

    Else
        Call PlayerMsg(Index, "This item is not in stock, at the moment!", BrightRed)
    End If

End Sub
Reply
#3
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
Reply
#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
#5
Lea Wrote:redim parse(n+3)

I got it covered. Smile) Thanks for the response ^^

Going to test now, I think.
Reply
#6
Lea Wrote:lol

that will let it compile, but it wont work right Big Grin

Yeah, I didn't take your fix. I started over in a newer version, and was smarter about the changes I did, and it worked on it's own.
Reply
#7
Really lol, never found the problem then?
Reply
#8
timster0 Wrote:Really lol, never found the problem then?

I'm pretty sure I was parsing wrong. Big Grin
Reply
#9
Alright, I DONT FUCKING GET IT

Subscript out of range
Code:
Stocked = CLng(Parse(n + 4))

I've never had problems with it, until I added
Code:
Stocked = CLng(Parse(n + 4))
         Increase = CLng(Parse(n + 5))
         Decrease = CLng(Parse(n + 6))

To the client.

I have this in the server:
Code:
For i = 1 To MAX_TRADES
        Shop(ShopNum).TradeItem(i).GiveItem = CLng(Parse(N))
        Shop(ShopNum).TradeItem(i).GiveValue = CLng(Parse(N + 1))
        Shop(ShopNum).TradeItem(i).GetItem = CLng(Parse(N + 2))
        Shop(ShopNum).TradeItem(i).GetValue = CLng(Parse(N + 3))
        Shop(ShopNum).TradeItem(i).Stocked = CLng(Parse(N + 4))
        Shop(ShopNum).TradeItem(i).DemandIncrease = CLng(Parse(N + 5))
        Shop(ShopNum).TradeItem(i).DemandDecrease = CLng(Parse(N + 6))
        
        N = N + 7
    Next

And this in the client:
Code:
For i = 1 To MAX_TRADES
         GiveItem = CLng(Parse(n))
         GiveValue = CLng(Parse(n + 1))
         GetItem = CLng(Parse(n + 2))
         GetValue = CLng(Parse(n + 3))
         Stocked = CLng(Parse(n + 4))
         Increase = CLng(Parse(n + 5))
         Decrease = CLng(Parse(n + 6))
        
         If GiveItem > 0 Then
             If GetItem > 0 Then
                 frmTrade.lstTrade.AddItem "Give " & Trim$(Shop(ShopNum).Name) & " " & GiveValue & " " & Trim$(Item(GiveItem).Name) & " for " & Trim$(Item(GetItem).Name & "(" & Stocked & ")")
             End If
         End If
         n = n + 7

Everything seemed to work/compile correctly UNTIL I tried to get the quantity in stock show up in the shop, for each item.
Reply
#10
How are you sending it?
Reply
#11
Dugor Wrote:How are you sending it?

Code:
frmTrade.lstTrade.AddItem "Give " & Trim$(Shop(ShopNum).Name) & " " & GiveValue & " " & Trim$(Item(GiveItem).Name) & " for " & Trim$(Item(GetItem).Name & "(" & Stocked & ")")

That's why I wanted to finish the parsing on both sides, so that I could just do this, but I don't think it would work anyways, and now everythings all screwed because of something I did wrong.
Reply
#12
Dugor helped me with a similar problem. I just changed the clng to val..
Reply
#13
Matt Wrote:Dugor helped me with a similar problem. I just changed the clng to val..

Same thing happens. I can't fucking figure this out. It's lame.
Reply
#14
I meant, what is the exact packet you are sending. I'm willing to bet you aren't sending the right amount of data.
Reply
#15
Dugor Wrote:I meant, what is the exact packet you are sending. I'm willing to bet you aren't sending the right amount of data.

Code:
Public Sub SendSaveShop(ByVal ShopNum As Long)
Dim Packet As String
Dim i As Long

    With Shop(ShopNum)
        Packet = CSaveShop & SEP_CHAR & ShopNum & SEP_CHAR & Trim$(.Name) & SEP_CHAR & Trim$(.JoinSay) & SEP_CHAR & Trim$(.LeaveSay) & SEP_CHAR & .FixesItems
    End With
    
    For i = 1 To MAX_TRADES
        With Shop(ShopNum).TradeItem(i)
            Packet = Packet & SEP_CHAR & .GiveItem & SEP_CHAR & .GiveValue & SEP_CHAR & .GetItem & SEP_CHAR & .GetValue & SEP_CHAR & .Stocked & SEP_CHAR & .DemandIncrease & SEP_CHAR & .DemandDecrease
        End With
    Next
    
    Packet = Packet & END_CHAR
    Call SendData(Packet)
End Sub

Does that help?

Only time i use it in a packet, I believe.
Reply
#16
I can't seem to edit shops now either. I get a RTE 9 on
Code:
GetItem = CLng(Parse(n + 2))

In HandleEditShop

Heres my edit shop:
Code:
' ::::::::::::::::::::::
' :: Edit shop packet ::
' ::::::::::::::::::::::
Sub HandleEditShop(ByRef Parse() As String)
Dim n As Long
Dim i As Long
Dim ShopNum As Long
Dim GiveItem As Long
Dim GiveValue As Long
Dim GetItem As Long
Dim GetValue As Long
Dim Stocked As Long
Dim Increase As Long
Dim Decrease As Long

     ShopNum = CLng(Parse(1))
    
     ' Update the shop
     Shop(ShopNum).Name = Parse(2)
     Shop(ShopNum).JoinSay = Parse(3)
     Shop(ShopNum).LeaveSay = Parse(4)
     Shop(ShopNum).FixesItems = CByte(Parse(5))
    
     n = 6
     For i = 1 To MAX_TRADES
        
         GiveItem = CLng(Parse(n))
         GiveValue = CLng(Parse(n + 1))
         GetItem = CLng(Parse(n + 2))
         GetValue = CLng(Parse(n + 3))
         Stocked = CLng(Parse(n + 4))
        
         Shop(ShopNum).TradeItem(i).GiveItem = GiveItem
         Shop(ShopNum).TradeItem(i).GiveValue = GiveValue
         Shop(ShopNum).TradeItem(i).GetItem = GetItem
         Shop(ShopNum).TradeItem(i).GetValue = GetValue
         Shop(ShopNum).TradeItem(i).Stocked = Stocked
         Shop(ShopNum).TradeItem(i).DemandIncrease = Increase
         Shop(ShopNum).TradeItem(i).DemandDecrease = Decrease
        
         n = n + 5
     Next
    
     ' Initialize the shop editor
     Call ShopEditorInit
    
End Sub

Code:
Public Sub SendSaveShop(ByVal ShopNum As Long)
Dim Packet As String
Dim i As Long

    With Shop(ShopNum)
        Packet = CSaveShop & SEP_CHAR & ShopNum & SEP_CHAR & Trim$(.Name) & SEP_CHAR & Trim$(.JoinSay) & SEP_CHAR & Trim$(.LeaveSay) & SEP_CHAR & .FixesItems
    End With
    
    For i = 1 To MAX_TRADES
        With Shop(ShopNum).TradeItem(i)
            Packet = Packet & SEP_CHAR & .GiveItem & SEP_CHAR & .GiveValue & SEP_CHAR & .GetItem & SEP_CHAR & .GetValue & SEP_CHAR & .Stocked & SEP_CHAR & .DemandIncrease & SEP_CHAR & .DemandDecrease
        End With
    Next
    
    Packet = Packet & END_CHAR
    Call SendData(Packet)
End Sub

Code:
' ::::::::::::::::::
' :: Trade packet ::
' ::::::::::::::::::
Sub HandleTrade(ByRef Parse() As String)
Dim n As Long
Dim i As Long
Dim ShopNum As Long
Dim GiveItem As Long
Dim GiveValue As Long
Dim GetItem As Long
Dim GetValue As Long
Dim Stocked As Long
Dim Increase As Long
Dim Decrease As Long

     ShopNum = CLng(Parse(1))
    
     If CByte(Parse(2)) = 1 Then
         frmTrade.lblFixItem.Visible = True
     Else
         frmTrade.lblFixItem.Visible = False
     End If
    
     n = 3
    
     For i = 1 To MAX_TRADES
         GiveItem = CLng(Parse(n))
         GiveValue = CLng(Parse(n + 1))
         GetItem = CLng(Parse(n + 2))
         GetValue = CLng(Parse(n + 3))
         Stocked = CLng(Parse(n + 4))
         Increase = CLng(Parse(n + 5))
         Decrease = CLng(Parse(n + 6))
        
         If GiveItem > 0 Then
             If GetItem > 0 Then
                 frmTrade.lstTrade.AddItem "Give " & Trim$(Shop(ShopNum).Name) & " " & GiveValue & " " & Trim$(Item(GiveItem).Name) & " for " & Trim$(Item(GetItem).Name & "(" & Stocked & ")")
             End If
         End If
         n = n + 7
     Next
    
     If frmTrade.lstTrade.ListCount > 0 Then
         frmTrade.lstTrade.ListIndex = 0
     End If
     frmTrade.Show vbModal
End Sub

Server

Code:
' ::::::::::::::::::::::
' :: Save shop packet ::
' ::::::::::::::::::::::
Sub HandleSaveShop(ByVal Index As Long, ByRef Parse() As String)
Dim ShopNum As Long
Dim N As Long
Dim i As Long

    ' Prevent hacking
    If GetPlayerAccess(Index) < ADMIN_DEVELOPER Then
        Call HackingAttempt(Index, "Admin Cloning")
        Exit Sub
    End If
    
    ShopNum = CLng(Parse(1))
    
    ' Prevent hacking
    If ShopNum < 0 Or ShopNum > MAX_SHOPS Then
        Call HackingAttempt(Index, "Invalid Shop Index")
        Exit Sub
    End If
    
    ' Update the shop
    Shop(ShopNum).Name = Parse(2)
    Shop(ShopNum).JoinSay = Parse(3)
    Shop(ShopNum).LeaveSay = Parse(4)
    Shop(ShopNum).FixesItems = CByte(Parse(5))
    
    N = 6
    For i = 1 To MAX_TRADES
        Shop(ShopNum).TradeItem(i).GiveItem = CLng(Parse(N))
        Shop(ShopNum).TradeItem(i).GiveValue = CLng(Parse(N + 1))
        Shop(ShopNum).TradeItem(i).GetItem = CLng(Parse(N + 2))
        Shop(ShopNum).TradeItem(i).GetValue = CLng(Parse(N + 3))
        Shop(ShopNum).TradeItem(i).Stocked = CLng(Parse(N + 4))
        Shop(ShopNum).TradeItem(i).DemandIncrease = CLng(Parse(N + 5))
        Shop(ShopNum).TradeItem(i).DemandDecrease = CLng(Parse(N + 6))
        
        N = N + 7
    Next
    
    ' Save it
    Call SendUpdateShopToAll(ShopNum)
    Call SaveShop(ShopNum)
    Call AddLog(GetPlayerName(Index) & " saving shop #" & ShopNum & ".", ADMIN_LOG)
End Sub

Code:
' ::::::::::::::::::::::::::
' :: Trade request packet ::
' ::::::::::::::::::::::::::
Sub HandleTradeRequest(ByVal Index As Long, _
                       ByRef Parse() As String)
    Dim N As Long
    Dim i As Long
    Dim x As Long
    Dim z As Long
    ' Trade num
    N = CLng(Parse(1))
  
    ' Prevent hacking
    If (N  MAX_TRADES) Then
        Call HackingAttempt(Index, "Trade Request Modification")
        Exit Sub
    End If
  
    ' Index for shop
    i = Map(GetPlayerMap(Index)).Shop
  
    ' Check if inv full
    x = FindOpenInvSlot(Index, Shop(i).TradeItem(N).GetItem)
  
    'If the Demand Increase and Decrease = 0 Then the stock = 10
    '(This is so that, an item that hasn't ever been bought, will be in stock)
    If Shop(i).TradeItem(N).DemandIncrease = 0 And Shop(i).TradeItem(N).DemandDecrease = 0 Then
        Shop(i).TradeItem(N).Stocked = 10
    End If
  
    If x = 0 Then
        Call PlayerMsg(Index, "Trade unsuccessful, inventory full.", BrightRed)
        Exit Sub
    End If

    'Check to see if they have on in stock
    If Shop(i).TradeItem(N).Stocked > 0 Then

        ' Check if they have the item
        If HasItem(Index, Shop(i).TradeItem(N).GiveItem) >= Shop(i).TradeItem(N).GiveValue Then
            Call TakeItem(Index, Shop(i).TradeItem(N).GiveItem, Shop(i).TradeItem(N).GiveValue)
            Call GiveItem(Index, Shop(i).TradeItem(N).GetItem, Shop(i).TradeItem(N).GetValue)
            Call PlayerMsg(Index, "The trade was successful!", Yellow)
            'Minus one from stock
            Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked - 1
            'Add moar demand
            Shop(i).TradeItem(N).DemandIncrease = Shop(i).TradeItem(N).DemandIncrease + 0.1
          
'            Select Case Shop(i).TradeItem(N).DemandIncrease
'
'                Case 1
'
'                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked + 5
'
'                Case 5
'                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked + 10
'
'                Case 10
'                    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
'            Select Case Shop(i).TradeItem(N).DemandDecrease
'
'                Case 1
'
'                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked - 5
'
'                Case 5
'                    Shop(i).TradeItem(N).Stocked = Shop(i).TradeItem(N).Stocked - 10
'
'                Case 10
'                    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

        Else
            Call PlayerMsg(Index, "Trade unsuccessful.", BrightRed)
        End If

    Else
        Call PlayerMsg(Index, "This item is not in stock, at the moment!", BrightRed)
    End If

End Sub

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

Code:
If Tick > LastUpdateShopStocks Then
            UpdateShopStocks
            LastUpdateShopStocks = GetTickCount + 600000
        End If
Reply
#17
Triple post o.O

Anyways GIAKEN helped me figure it out. It was so fucking obvious I'm ashamed to even post here anymore. I'll probably start a new topic with the new problems I have. Big Grin

Someone lox this pl0x
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)