[Source] Simple module for games that require buying an item

Discussion in 'Programming General' started by Blupig, Oct 9, 2008.

[Source] Simple module for games that require buying an item
  1. Unread #1 - Oct 9, 2008 at 6:46 PM
  2. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    [Source] Simple module for games that require buying an item

    Add this into a module.

    Code:
    'Made by Blupig. Give credit if you use this in your applications or else I'll hunt you down and gut your dog.
    Function Buy(intCost As Integer, intCash As Integer, strCurrency As String, strItemName As String)
    
        Dim Msg1
            Msg1 = MsgBox("Buy " & strItemName & " for " & strCurrency & intCost & "?", vbYesNo + vbQuestion, "Blupig's Buy Mod")
            
        If Msg1 = vbYes Then
            
            If intCash < intCost Then
                MsgBox "You don't have enough money.", vbInformation, "Blupig's Buy Mod"
            Else: intCash = intCash - intCost
            End If
            
        ElseIf Msg1 = vbNo Then
            Exit Function
        End If
    
    End Function
    
    
    Sub Main()
    
        Dim Cost As Integer
        Dim Cash As Integer
        Dim Curr As String
        Dim Item As String
        
            Cost = 19
            Cash = 20
            Curr = "$"
            Item = "Apple"
        
        Call Buy(Cost, Cash, Curr, Item)
        
        MsgBox Curr & Cash & " remains.", vbInformation, "Blupig's Buy Mod"
    
    End Sub
    
    
     
  3. Unread #2 - Oct 9, 2008 at 7:21 PM
  4. Stuart
    Joined:
    May 5, 2005
    Posts:
    1,580
    Referrals:
    2
    Sythe Gold:
    10

    Stuart Guru
    Banned

    [Source] Simple module for games that require buying an item

    Seems basic enough but if you want to make it a little more efficient I would say you create a custom type and then make an array to store them in.

    Thats how I would do it anyways.
     
  5. Unread #3 - Oct 9, 2008 at 7:39 PM
  6. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    [Source] Simple module for games that require buying an item

    Example? The only way I thought of doing it was to store the data in integers or doubles...
     
  7. Unread #4 - Oct 9, 2008 at 7:43 PM
  8. Stuart
    Joined:
    May 5, 2005
    Posts:
    1,580
    Referrals:
    2
    Sythe Gold:
    10

    Stuart Guru
    Banned

    [Source] Simple module for games that require buying an item

    Something along these lines, I havn't got vb6 installed so I can't try it out. If you google "vb6 type" it will show you how to use them.

    Code:
    private type item
    	name as string
    	cost as integer
    end type
    
    dim cash as integer
    dim items() as item
    
     
< [code] Get your real IP-address | Pwnforce.com >

Users viewing this thread
1 guest


 
 
Adblock breaks this site