Log in to reply

[Tutorial] - LemonUI Vb.Net Example

  • Hi Guys,

    This is an example to use LemonUI V 1.1 in Vb.Net:

    Public Class HL_Menu_Krlos_Rokr
    Inherits Script
    Private LemonUIPool As LemonUI.ObjectPool
    Private MainMenu As LemonUI.Menus.NativeMenu
    Private SettingsMenu As LemonUI.Menus.NativeMenu

    Private Created As Boolean=False

    Sub New()
        Me.Interval = 5
    End Sub
    Sub CreateMenu()
        LemonUIPool = New LemonUI.ObjectPool
        MainMenu = New LemonUI.Menus.NativeMenu("Menu 1", "Dev: Krlos_Rokr", "This is a Test Menu")
        SettingsMenu = New LemonUI.Menus.NativeMenu("Settings", "Krlos_Rokr", "Change Script Options") 'SubMenu
        Dim TItem As New LemonUI.Menus.NativeItem("Item 1", "~b~Some ~w~Info ~r~/////")
        AddHandler Me.Tick, AddressOf LemonUIPool.Process 'Add the process to the Tick
        AddHandler TItem.Activated, Sub()
                                        UI.Notify("Selected: " & TItem.Title.ToString) 'Add code to the event handler
                                    End Sub
        TItem = New LemonUI.Menus.NativeItem("Item 2 test", "Some info 2")
        AddHandler TItem.Activated, Sub()
                                        UI.Notify("Selected: " & TItem.Title.ToString)
                                    End Sub
    'Add SubMenu
    Dim TitemSM = MainMenu.AddSubMenu(SettingsMenu) 'Works OK but can't display the title, instead it's displayed the subtitle

    'or can be use this way:
    ' Dim TitemSM2 = New LemonUI.Menus.NativeSubmenuItem(SettingsMenu, MainMenu) 'Works OK -> both cases can't display the title instead it's displayed the subtitle
    'MainMenu.Add(TitemSM2) 'Works OK

    TitemSM.Title = SettingsMenu.Title.Text 'Fix the problems With the incorrect name of the created NativeItem **
        Created = True
    End Sub
    Sub DestroyMenu()
        RemoveHandler Me.Tick, AddressOf LemonUIPool.Process
        LemonUIPool = Nothing
        MainMenu = Nothing
        SettingsMenu = Nothing
        Created = False
    End Sub
    Private Sub HL_Menu_Krlos_Rokr_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.L Then
            If Created = False Then
            End If
            If Created = True Then
                MainMenu.Visible = Not MainMenu.Visible
                If MainMenu.Visible = False Then
                End If
            End If
        End If
    End Sub

    End Class

  • @Krlos_Rokr I know this is an old post, but thanks for posting this. I prefer to code in VB.Net but was unable to migrate my working LemonUI to VB.Net using your example. In my code I spawn peds with component variations for example. This works in C# but in VB.Net it is inconsistent. For the most part it spawns multiples of the peds, 4 instead of 2, etc.

    No sure if there is a fix. I'm very new to coding.

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.