我有一个简单的vb.net项目,它基本上是一个名为FiveM的GTAV修改框架的脚本。这并不是很重要的事情,所以FiveM有一个使用Mono的c#运行时。由于我对vb.net比c# tho更了解,所以我决定尝试使用vb.net作为脚本,因为它们都编译成c#。显然,由于运行时是为c#创建的,所以它不包括vb运行时dll (Microsoft.VisualBasic),所以我不得不使用/vbruntime标志和/nostdlib /define:_MYTYPE=\“空\”编译脚本。对于简单的脚本,它可以正常工作,但现在我面临着更大的挑战。这是我的密码:
Imports CitizenFX.Core.Native.API
Imports CitizenFX.Core
Imports System.Threading
Imports System.Threading.Tasks
Imports System
Namespace WarThunderVClient
Public Class WarThunderVClient
Inherits BaseScript
Private flightstate = 1
Public Sub New()
OnTick()
End Sub
Public Sub DrawPlaneHUD()
Dim speed As Double = GetEntitySpeed(GetVehiclePedIsIn(PlayerPedId(), False)) * 1.943844492
Dim altitude As Double = GetEntityCoords(PlayerPedId(), True).Z * 3.28084
Dim heading As Double = GetEntityHeading(GetVehiclePedIsIn(PlayerPedId(), False))
Dim verticalspeed As Double = GetEntityVelocity(GetVehiclePedIsIn(PlayerPedId(), False)).Z * 196.850394
If speed < 40 Then speed = 0
If speed > 200 Then speed = 200
If verticalspeed > 2000 Or verticalspeed < -2000 Then verticalspeed = 2000
If altitude < 0 Then altitude = 0
If Not HasStreamedTextureDictLoaded("flightinstruments") Then
RequestStreamedTextureDict("flightinstruments", True)
While Not HasStreamedTextureDictLoaded("flightinstruments")
Wait(1)
End While
End If
DrawSprite("flightinstruments", "speedometer", 0.9, 0.9, 0.08, 0.08 * 1.77777778, 0, 255, 255, 255, 255)
DrawSprite("flightinstruments", "speedometer_needle", 0.9, 0.9, 0.08, 0.08 * 1.77777778, ((speed - 20) / 20) * 36, 255, 255, 255, 255)
DrawSprite("flightinstruments", "altimeter", 0.8, 0.9, 0.08, 0.08 * 1.77777778, 0, 255, 255, 255, 255)
DrawSprite("flightinstruments", "altimeter-needle100", 0.8, 0.9, 0.08, 0.08 * 1.77777778, altitude / 100 * 36, 255, 255, 255, 255)
DrawSprite("flightinstruments", "altimeter-needle1000", 0.8, 0.9, 0.08, 0.08 * 1.77777778, altitude / 1000 * 36, 255, 255, 255, 255)
DrawSprite("flightinstruments", "altimeter-needle10000", 0.8, 0.9, 0.08, 0.08 * 1.77777778, altitude / 10000 * 36, 255, 255, 255, 255)
DrawSprite("flightinstruments", "heading", 0.7, 0.9, 0.08, 0.08 * 1.77777778, 0, 255, 255, 255, 255)
DrawSprite("flightinstruments", "heading_needle", 0.7, 0.9, 0.08, 0.08 * 1.77777778, heading, 255, 255, 255, 255)
DrawSprite("flightinstruments", "verticalspeedometer", 0.6, 0.9, 0.08, 0.08 * 1.77777778, 0, 255, 255, 255, 255)
DrawSprite("flightinstruments", "verticalspeedometer_needle", 0.6, 0.9, 0.08, 0.08 * 1.77777778, 270 + (verticalspeed / 1000 * 90), 255, 255, 255, 255)
End Sub
Public Sub DrawHelp(text As String, isloop As Integer, isbeep As Integer, isshape As Integer)
If Not IsHelpMessageOnScreen() Then
SetTextComponentFormat("STRING")
AddTextComponentString(text)
DisplayHelpTextFromStringLabel(0, isloop, isbeep, isshape)
End If
End Sub
Public Async Sub OnTick()
While True
If IsPedInAnyPlane(PlayerPedId()) Then
If flightstate.Equals(1) Then
SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), False, False, False)
End If
If Not GetIsVehicleEngineRunning(GetVehiclePedIsIn(PlayerPedId(), False)) Then
DrawHelp("Press ~INPUT_DETONATE~ to perform an engine startup", 0, 1, -1)
If IsControlJustPressed(3, 47) Then
flightstate = 2
SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), True, False, False)
End If
End If
DrawPlaneHUD()
End If
Await Delay(0)
End While
End Sub
End Class
End Namespace因此,在使用vbc使用以下命令编译它时:
vbc /libpath:"C:\Users\admin\source\repos\basic-resource\BasicResourceClient\bin\Release" /reference:CitizenFX.Core.dll /novbruntimeref /target:library WarThunderVClient.vb /vbruntime- /noconfig /nostdlib /define:_MYTYPE=\"Empty\" /out:WarThunderVClient.net.dll /r:system.dll 它最初输出了一个关于"=“操作符的错误:
error BC35000:由于未定义运行库的BC35000函数,请求的操作不可用。
我通过使用.Equals()方法很容易地修复了这个问题,但是现在它输出了另外两个错误,我不知道如何修复这些错误:
error BC35000:由于未定义运行时库BC35000函数,请求的操作不可用。
Public Async Sub OnTick()
While True
If IsPedInAnyPlane(PlayerPedId()) Then
If flightstate.Equals(1) Then
SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), False, False, False)
End If
If Not GetIsVehicleEngineRunning(GetVehiclePedIsIn(PlayerPedId(), False)) Then
DrawHelp("Press ~INPUT_DETONATE~ to perform an engine startup", 0, 1, -1)
If IsControlJustPressed(3, 47) Then
flightstate = 2
SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), True, False, False)
End If
End If
DrawPlaneHUD()
End If
Await Delay(0)
End While
End SubC:\Users\admin\Downloads\server\resources\gg\WarThunderVClient.vb(50):error BC35000:由于未定义运行时库'Microsoft.VisualBasic.CompilerServices.ProjectData.SetProjectError‘函数,请求的操作不可用。
Public Async Sub OnTick()
While True
If IsPedInAnyPlane(PlayerPedId()) Then
If flightstate.Equals(1) Then
SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), False, False, False)
End If
If Not GetIsVehicleEngineRunning(GetVehiclePedIsIn(PlayerPedId(), False)) Then
DrawHelp("Press ~INPUT_DETONATE~ to perform an engine startup", 0, 1, -1)
If IsControlJustPressed(3, 47) Then
flightstate = 2
SetVehicleEngineOn(GetVehiclePedIsIn(PlayerPedId(), False), True, False, False)
End If
End If
DrawPlaneHUD()
End If
Await Delay(0)
End While
End Sub有解决办法吗?
发布于 2018-03-09 15:56:24
ProjectData.ClearProjectError是使用所谓的VB应用框架.该框架的很大一部分是支持与VB6语言特性(如On Error Resume Next )的向后兼容性,这些特性是任何称职的VB.Net程序员都不会使用的。
转到Project菜单->ProjName Properties->Application Tab,并清除“”的复选标记。将"Startup“下拉到"Sub”。
然后,您需要定义一个Sub Main作为程序的入口点。
Module Module1
<STAThread>
Sub Main(args As String())
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Modulehttps://stackoverflow.com/questions/49196991
复制相似问题