Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. DLC
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
      7. The Diamond Casino Heist
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
qiangqiang101

Failed to instantiate script because no public default constructor was

Recommended Posts

qiangqiang101

[00:58:47] [ERROR] Failed to instantiate script 'LosSantosBusSimulator.LSBS' because no public default constructor was found. why? Why? WHY? WHYYYYYY?

Imports SystemImports System.Collections.GenericImports System.DrawingImports System.Windows.FormsImports GTAImports GTA.NativeImports GTA.MathImports NativeUIImports System.LinqImports System.TextImports System.Threading.TasksImports System.ReflectionPublic Class LSBS    Inherits Script    Private player As Player    Private playerPed As Ped    Private PlayerCash As Integer    Private LSBS As Vector3    Private lsbsBlip As Blip    Private selectedBus As String    Private selectedRoute As String    Private busPreview As Vehicle    Private lsbsDist As Single    Private ModEnable As Boolean = False    Private curRadius As Integer = 0    Private enableByDefault As Boolean    Dim ver As String = My.Application.Info.Version.ToString    Private mainMenu, busMenu, routeMenu, modMenu As UIMenu    Dim itemBus As New UIMenuItem("Bus Selection")    Dim itemRoute As New UIMenuItem("Route Selection")    Private vehicle As String = Application.StartupPath & "\scripts\LSBS\vehicle.ini"    Private route As String = Application.StartupPath & "\scripts\LSBS\route.ini"    Private pmVehicle As String() = {"[name]", "[model]"}    Private pmRoute As String() = {"[name]", "[desc]", "[file]"}    Private _menuPool As MenuPool    Private Sub New()        Try            player = Game.Player            playerPed = Game.Player.Character            PlayerCash = playerPed.Money            AddHandler Tick, AddressOf OnTick            AddHandler KeyDown, AddressOf OnKeyDown            _menuPool = New MenuPool()            modMenu = New UIMenu("LS Bus Simulator", "~b~VERSION: " & ver)            _menuPool.Add(modMenu)            modMenu.AddItem(New UIMenuItem("Enable", "Enable Mod"))            modMenu.AddItem(New UIMenuItem("Disable", "Disable Mod"))            modMenu.AddItem(New UIMenuItem("Key Settings", "Refresh Keys After you saving config.ini file."))            modMenu.AddItem(New UIMenuItem("About", "About LSBS"))            modMenu.RefreshIndex()            mainMenu = New UIMenu("Bus Depot", "~b~CATEGORIES")            _menuPool.Add(mainMenu)            mainMenu.AddItem(itemBus)            mainMenu.AddItem(itemRoute)            mainMenu.AddItem(New UIMenuItem("Play", "Start the Job."))            mainMenu.RefreshIndex()            ReadVehicle()            ReadRoute()            AddHandler mainMenu.OnMenuClose, AddressOf MenuCloseHandler            AddHandler mainMenu.OnItemSelect, AddressOf ItemSelectHandler            AddHandler modMenu.OnItemSelect, AddressOf ItemSelectHandler            AddHandler busMenu.OnItemSelect, AddressOf BusItemSelectHandler            AddHandler routeMenu.OnItemSelect, AddressOf RouteItemSelectHandler            AddHandler busMenu.OnIndexChange, AddressOf BusIndexChangeHandler            My.Settings.keyModEnable = [Enum].Parse(GetType(Keys), ReadIniValue(".\Scripts\LSBS\config.ini", "OPTIONS", "ModEnableKey"), False)            My.Settings.keyOpenDoor = [Enum].Parse(GetType(Keys), ReadIniValue(".\Scripts\LSBS\config.ini", "OPTIONS", "OpenDoorKey"), False)            My.Settings.keyCloseDoor = [Enum].Parse(GetType(Keys), ReadIniValue(".\Scripts\LSBS\config.ini", "OPTIONS", "CloseDoorKey"), False)            My.Settings.Save()            If ReadIniValue(".\Scripts\LSBS\config.ini", "OPTIONS", "DefaultEnable") = True Then                ModEnable = True                EnableMod()                modMenu.MenuItems(0).SetRightBadge(UIMenuItem.BadgeStyle.Tick)                modMenu.MenuItems(1).SetRightBadge(UIMenuItem.BadgeStyle.None)            Else                modMenu.MenuItems(1).SetRightBadge(UIMenuItem.BadgeStyle.Tick)            End If            UI.Notify("LSBS Enabled")        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub EnableMod()        Try            LSBS = New Vector3(438.448F, -622.731F, 28.7091F)            lsbsBlip = World.CreateBlip(LSBS)            lsbsBlip.Sprite = BlipSprite.VinewoodTours            lsbsBlip.Color = BlipColor.White            lsbsBlip.IsShortRange = True            GTA.Native.Function.Call(Hash.SET_BLIP_NAME_FROM_TEXT_FILE, lsbsBlip, "assassin_bus_enter_bus")        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub ReadVehicle()        Try            Dim format As New BTEFormatReader(vehicle, pmVehicle)            busMenu = New UIMenu("Bus", "~r~BUSES")            _menuPool.Add(busMenu)            For i As Integer = 0 To format.Count - 1                Dim item As New UIMenuItem(format(i)("name"))                busMenu.AddItem(item)                With item                    .SetRightLabel(format(i)("model"))                End With            Next            busMenu.RefreshIndex()            mainMenu.BindMenuToItem(busMenu, itemBus)        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub ReadRoute()        Try            Dim format As New BTEFormatReader(route, pmRoute)            routeMenu = New UIMenu("Route", "~r~ROUTES")            _menuPool.Add(routeMenu)            For i As Integer = 0 To format.Count - 1                Dim item As New UIMenuItem(format(i)("name"))                routeMenu.AddItem(item)                With item                    .Description = format(i)("desc")                    '.SetRightLabel(format(i)("model"))                End With            Next            busMenu.RefreshIndex()            mainMenu.BindMenuToItem(busMenu, itemBus)        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub MenuCloseHandler(sender As UIMenu)        Try            If selectedBus IsNot Nothing Then                busPreview.Delete()            End If            World.DestroyAllCameras()            World.RenderingCamera = Nothing        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub ItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        Try            If selectedItem.Text = "Enable" Then                ModEnable = True                UI.Notify("~r~Los Santos Bus Simulator ~w~Mod Enabled.", True)                EnableMod()                modMenu.Visible = False                sender.MenuItems(0).SetRightBadge(UIMenuItem.BadgeStyle.Tick)                sender.MenuItems(1).SetRightBadge(UIMenuItem.BadgeStyle.None)            ElseIf selectedItem.Text = "Disable" Then                ModEnable = False                UI.Notify("~r~Los Santos Bus Simulator ~w~Mod Disabled.", True)                lsbsBlip.Remove()                modMenu.Visible = False                sender.MenuItems(1).SetRightBadge(UIMenuItem.BadgeStyle.Tick)                sender.MenuItems(0).SetRightBadge(UIMenuItem.BadgeStyle.None)            ElseIf selectedItem.Text = "Key Settings" Then                My.Settings.keyModEnable = [Enum].Parse(GetType(Keys), ReadIniValue(".\Scripts\LSBS\config.ini", "OPTIONS", "ModEnableKey"), False)                My.Settings.keyOpenDoor = [Enum].Parse(GetType(Keys), ReadIniValue(".\Scripts\LSBS\config.ini", "OPTIONS", "OpenDoorKey"), False)                My.Settings.keyCloseDoor = [Enum].Parse(GetType(Keys), ReadIniValue(".\Scripts\LSBS\config.ini", "OPTIONS", "CloseDoorKey"), False)                My.Settings.Save()                modMenu.Visible = False                UI.Notify("Keys has been Saved.", True)            ElseIf selectedItem.Text = "About" Then                modMenu.Visible = False                UI.Notify("Los Santos Bus Simulator v" & ver, True)                UI.Notify("Release Date: 10 Aug 2015", True)                UI.Notify("Mod Author: I'm Not MentaL", True)                UI.Notify("Special Thanks: Rockstar Games, Alexander Blade, Crosire, Guad & EnergyStyle", True)                'UI.Notify("Calm, LCBuffalo, Gang1111, Matt_STS, frodzet, leftas & marhex", True)            End If            If selectedItem.Text = "Play" Then                'Play Selected            End If        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub BusItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        Try            selectedBus = selectedItem.Text            busMenu.GoBack()        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub RouteItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        Try            selectedRoute = selectedItem.Text            busMenu.GoBack()        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub BusIndexChangeHandler(sender As UIMenu, index As Integer)        Try            selectedBus = sender.MenuItems(index).Text            If busPreview = Nothing Then                busPreview = World.CreateVehicle(sender.MenuItems(index).RightLabel, New Vector3(452.378F, -585.375F, 28.4998F), 6.122209F)            Else                busPreview.Delete()                busPreview = World.CreateVehicle(sender.MenuItems(index).RightLabel, New Vector3(452.378F, -585.375F, 28.4998F), 6.122209F)            End If            busPreview.Rotation = New Vector3(0, 0, curRadius)            busPreview.IsDriveable = False            busPreview.DirtLevel = 0F        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub OnTick(o As Object, e As EventArgs)        Try            _menuPool.ProcessMenus()            If ModEnable = True Then                lsbsDist = GTA.World.GetDistance(Game.Player.Character.Position, LSBS)                player = Game.Player                playerPed = Game.Player.Character                PlayerCash = player.Money                If Not playerPed.IsInVehicle AndAlso Not playerPed.IsDead AndAlso lsbsDist < 3.0F AndAlso player.WantedLevel = 0 Then                    Native.Function.Call(Hash.DISPLAY_HELP_TEXT_THIS_FRAME, New InputArgument() {"SHR_MENU", 0})                ElseIf Not playerPed.IsInVehicle AndAlso Not playerPed.IsDead AndAlso lsbsDist < 3.0F AndAlso player.WantedLevel >= 1 Then                    Native.Function.Call(Hash.DISPLAY_HELP_TEXT_THIS_FRAME, New InputArgument() {"LOSE_WANTED", 0})                End If            End If        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End Sub    Public Sub OnKeyDown(o As Object, e As KeyEventArgs)        Try            If Game.IsControlJustPressed(0, GTA.Control.Talk) AndAlso ModEnable = True AndAlso lsbsDist < 3.0F AndAlso Not playerPed.IsInVehicle AndAlso player.WantedLevel = 0 Then                Game.FadeScreenOut(500)                Script.Wait(&H3E8)                mainMenu.Visible = True                World.RenderingCamera = World.CreateCamera(New Vector3(437.485F, -571.734F, 28.4998F), New Vector3(Game.Player.Character.Rotation.X, Game.Player.Character.Rotation.Y, 253.0F), 10.0F)                Game.Player.Character.Position = New Vector3(430.08F, -627.947F, 28.7157F)                Script.Wait(500)                Game.FadeScreenIn(500)            End If            If e.KeyCode = My.Settings.keyModEnable Then                modMenu.Visible = Not mainMenu.Visible                World.DestroyAllCameras()                World.RenderingCamera = Nothing            End If            If e.KeyCode = My.Settings.keyOpenDoor AndAlso ModEnable = True Then                busPreview.OpenDoor(VehicleDoor.FrontLeftDoor, False, False)                busPreview.OpenDoor(VehicleDoor.FrontRightDoor, False, False)                busPreview.OpenDoor(VehicleDoor.BackLeftDoor, False, False)                busPreview.OpenDoor(VehicleDoor.BackRightDoor, False, False)            ElseIf e.KeyCode = My.Settings.keyCloseDoor AndAlso ModEnable = True Then                Native.Function.Call(Hash.SET_VEHICLE_DOORS_SHUT, busPreview, False)            End If        Catch ex As Exception            logger.Log(ex.Message)            logger.Log(ex.InnerException)            logger.Log(ex.StackTrace)        End Try    End SubEnd Class

Share this post


Link to post
Share on other sites
qiangqiang101

bump

Share this post


Link to post
Share on other sites
qiangqiang101

Nevermind, i solve the problem myself

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

This might sound dumb, but the error is quite explanatory to your problem- you're missing a default constructor.

 

I don't know anything about C# but in C++, here's a sample class I just wrote:

class Something{  private:    int x, y, z;  // ...  public:    void something(){        // This is the default constructor where you initialize any variables,        // e.g.: x, y, and/or z.    }        // ...};

And to use the default constructor:

// Declare on heapSomething s = new Something();

Or (at least in C++) you can just declare it on the stack without the need of a constructor, which is what you'd normally do, as follows:

// Declare on stackSomething s;

That said, I don't know anything about C# but hopefully that helps point you in the right direction.

 

EDIT: Didn't see your latest reply... glad you solved it ;)

Edited by ClareXoBearrx3

Share this post


Link to post
Share on other sites
leftas

It's different in VB.net

 

All the best,

Paul.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.