rakijah / CSGSI

A simple C# library to interface with Counter-Strike: Global Offensive's Game State Integration
Other
129 stars 27 forks source link

How to use it in vb net? Is that possible? #8

Closed n1lsik closed 8 years ago

n1lsik commented 8 years ago

Hey. I really liked your project and I want to use it. But I prefer vb.NET. I tried to translate the example of your code here http://converter.telerik.com/ But I get an error on this line "gsl.NewGameState += New NewGameStateHandler(AddressOf OnNewGameState)" (I tried to fix it, but I could not get :() What can I do to fix it? My code:

Imports CSGSI
Imports CSGSI.Nodes
Module Module1

    Dim gsl As GameStateListener

    Sub Main()
        gsl = New GameStateListener(3000)
        gsl.NewGameState += New NewGameStateHandler(AddressOf OnNewGameState)
        If Not gsl.Start() Then
            Environment.[Exit](0)
        End If
        Console.WriteLine("Listening...")
    End Sub

    Dim IsPlanted As Boolean = False

    Private Sub OnNewGameState(gs As GameState)
        If Not IsPlanted AndAlso gs.Round.Phase = RoundPhase.Live AndAlso gs.Round.Bomb = BombState.Planted AndAlso gs.Previously.Round.Bomb = BombState.Undefined Then
            Console.WriteLine("Bomb has been planted.")
            IsPlanted = True
        ElseIf IsPlanted AndAlso gs.Round.Phase = RoundPhase.FreezeTime Then
            IsPlanted = False
        End If
    End Sub
End Module

Please help me.

rakijah commented 8 years ago

Hello, can you try removing the line that gives you an error and then changing the line Private Sub OnNewGameState(gs As GameState) to Private Sub OnNewGameState(gs As GameState) Handles gsl.OnNewGameState I personally haven't used VB in a long time so I'm afraid I can't help you any further than this...

n1lsik commented 8 years ago

Thanks for the answer! Unfortunately, this does not solve the problem. Now an error indicating "gsl" Private Sub OnNewGameState(gs As GameState) Handles gsl.OnNewGameState Error code BC30506 My new code:

Imports CSGSI
Imports CSGSI.Nodes

Module Module1

    Public gsl As GameStateListener

    Sub Main()
        gsl = New GameStateListener(3000)
        If Not gsl.Start() Then
            Environment.[Exit](0)
        End If
        Console.WriteLine("Listening...")
    End Sub

    Dim IsPlanted As Boolean = False

    Private Sub OnNewGameState(gs As GameState) Handles gsl.OnNewGameState

        If Not IsPlanted AndAlso gs.Round.Phase = RoundPhase.Live AndAlso gs.Round.Bomb = BombState.Planted AndAlso gs.Previously.Round.Bomb = BombState.Undefined Then
            Console.WriteLine("Bomb has been planted.")
            IsPlanted = True
        ElseIf IsPlanted AndAlso gs.Round.Phase = RoundPhase.FreezeTime Then
            IsPlanted = False
        End If
    End Sub
End Module
rakijah commented 8 years ago

Revert the change and try replacing the line gsl.NewGameState += New NewGameStateHandler(AddressOf OnNewGameState) with AddHandler gsl.NewGameState, AdressOf OnNewGameState

n1lsik commented 8 years ago

You will not believe), but I found the same solution, and it works! Thank you so much! P.S I did not understand a bit of what is needed gamestate_integration_test.cfg. I'm working on testing and it seems that without it, nothing works( if possible do without him or work with this easy? (Without the addition of this file in the configs)

rakijah commented 8 years ago

The .cfg tells CSGO what data to send and where to send it. For example, if you have an application that only needs map information, you can leave out all the other data (player info etc.) and save bandwidth. It is required to make any game state integration related application to work, sadly.